Friday, June 11, 2010

Unit tests fail - fixtures trying to execute INSERT INTO `table` (*, `1`, `2`...)

We've set up the CakePHP unit testing framework for our project, but
the individual who originally set it up didn't use fixtures, so the
unit tests are basically unrunnable because they interact with the
data on the environment they're run on.

I'm modifying it to use fixtures, so we can avoid this pain. I
followed the guide fairly closely; I wanted the fixture to use the
schema from the existing tables, but specify test data, so I used
this:

<?
class ContentSubmissionFixture extends CakeTestFixture {
var $name = 'ContentSubmission';

var $import = 'ContentSubmission';

var $records = array(
array(null, 1, 1, 'af', 'Man', 1, '2009-06-19
03:06:44', 4, 0, null, 0),
array(null, 1, 1, 'af', 'Vrou', 1, '2009-06-19
03:06:10', 3, 0, null, 0)
);
}
?>

However - when I execute my tests at the command line, I get this
error:

<pre><p style = "text-align:left"><b>Query:</b> INSERT INTO
`test_suite_content_submissions` (*, `1`, `2`, `3`, `4`, `5`, `6`,
`7`, `8`, `9`, `10`) VALUES (NULL, 1, 1, 'af', 'Man', 1, '2009-06-19
03:06:44', 4, 0, NULL, 0), (NULL, 1, 1, 'af', 'Vrou', 1, '2009-06-19
03:06:10', 3, 0, NULL, 0) </p></pre>E_USER_WARNING: <span style =
"color:Red;text-align:left"><b>SQL Error:</b> 1064: You have an error
in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near '*, `1`, `2`, `3`,
`4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12`, `13`, `14`, `1' at
line 1</span> in /workplace/experimental/wwwroot/cake/libs/model/
datasources/dbo_source.php on line 552

Our DB runs on MySQL with the InnoDB engine. Test configuration uses
the same DB as the app configuration. I'm perplexed about why it's
trying to insert into... well, asterisk. Am I misusing the import
functionality for the fixture in some way?

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate