Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions /

Missing tables in Test Database

Go to End

3 Posts   884 Views


Community Member, 2 Posts

22 December 2010 at 11:50pm

Edited: 23/12/2010 1:11am


I have a problem with testing and fixtures. The message says:

Couldn't run query: 
INSERT INTO "ProductSearchServiceConfigurationItem" ("Name", "Value") VALUES ('user', 'foo123') 

Table 'tmpdb1796961.ProductSearchServiceConfigurationItem' doesn't exist

ProductSearchServiceConfigurationItem is a custom DataObject introduced in the module I want to test. I ran /dev/build and in the production database the table exists but obviously SaphireTest does not create the corresponding table in the tmp database.

Is there anything I missed to set up?

If it helps, here is the code of the class:

class ProductSearchServiceConfigurationItem extends DataObject
	static $db = array('Name' => 'Varchar',
	                   'Value' => 'Varchar'
	static $has_one = array('SearchService' => 'ProductSearchService');

	public function getCMSFields()
		$fields = new FieldSet(new TextField('Name', 'Name'),
		                       new TextField('Value', 'Value')
		return $fields;

and the relevant part of the fixture file:

		Name: user
		Value: foo123

Edit: It is getting stranger the more i try...

?debugmanifest=1 appended to the test case URL shows that the classes are correctly defined in the manifest

  'productsearchservice' => '/var/www/[...]/code/ProductSearchService.php',
  'productsearchserviceconfigurationitem' => '/var/www/[...]/code/ProductSearchServiceConfigurationItem.php',

but if I try to autoload them with this code at the beginning of the test case file:

class_exists('ProductSearchService') or die('class ProductSearchService not found');
class_exists('ProductSearchServiceConfigurationItem') or die('class ProductSearchServiceConfigurationItem not found'); 

it fails:

class ProductSearchService not found

Edit 2: okay, debugmanifest does not show the manifest actually used by the tests... I added these lines to the test case file:

echo '<pre>';

and got

[Notice] Undefined index: productsearchservice

The same goes with $_ALL_CLASSES

now how can I influence the test manifest?


Community Member, 60 Posts

23 December 2010 at 1:57pm

hi fab-s,

all you need to do is dev/build?flush=all. to be on the safe side you could empty your cache folder manually. how does your test look like? does that error give you a backtrace?




Community Member, 2 Posts

23 December 2010 at 11:45pm

Thank you very much Andy, emptying the cache folder did the trick! Sometimes the solution is just too easy...

Cheers and Merry Christmas