hahaha, sorry to laugh but that's actually pretty funny.   You have to
set the keys as the column names and the values are the actual field
values.  Because you have a one dimensional array cake is using the
numeric index as the column name.

Even though you're importing the schema, you still have to define
columns => values in your records.

Here's an example to work off of:

var $records = array(
  array(
     'id' => 1,
     'name' => 'Awesome name',
     'created' => '2009-06-19 00:00:00'
  ),
  array(
     'id' => 2,
     'name' => 'Lame name',
     'created' => '2009-06-19 00:00:00'
  ),
);


By the way, save yourself the pain and use:
$ cake bake fixture

Let cake do the heavy lifting.  :)

Hope that helps,
Nick


On Jun 11, 9:31 pm, A Smiley <alsti...@gmail.com> wrote:
> 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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to