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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Missing tables in Test Database


Go to End


3 Posts   1678 Views

Avatar
fab-s

Community Member, 2 Posts

22 December 2010 at 11:50pm

Edited: 23/12/2010 1:11am

Hello,

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:

ProductSearchServiceConfigurationItem:
	conf_1:
		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:

global $_CLASS_MANIFEST;
echo '<pre>';
var_dump($_CLASS_MANIFEST['productsearchservice']);
var_dump($_CLASS_MANIFEST['productsearchserviceconfigurationitem']);

and got

[Notice] Undefined index: productsearchservice

The same goes with $_ALL_CLASSES

now how can I influence the test manifest?

Avatar
apiening

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?

cheers

andy

Avatar
fab-s

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

Fab