Thursday, November 25, 2010

Re: Dynamic data in fixtures

Well, I tried it that way and this is what Simpletest returns:
Fatal error: Call to a member function _build() on a non-object in /
home/jacobsteringa/Documenten/cake/tests/lib/cake_test_fixture.php on
line 142


On 24 nov, 07:18, Amit Badkas <amit.sanis...@gmail.com> wrote:
> Hi,
>
> Yes, exactly like that.
>
> Amit Badkas
>
> PHP Applications for E-Biz:http://www.sanisoft.com
>
> On Wed, Nov 24, 2010 at 3:41 AM, Jacob <jacobsteri...@gmail.com> wrote:
> > You mean like this?
>
> > class AnyFixture {
>
> > var $today;
> > var $tomorrow;
>
> > function __construct() {
> >    $this->today = date('Y-m-d H:i:s');
> >    $this->tomorrow = date('Y-m-d H:i:s', strtotime('+1 day'));
> > }
> > }
>
> > On 22 nov, 07:21, Amit Badkas <amit.sanis...@gmail.com> wrote:
> > > Hi,
>
> > > You can't assign default values to class properties using expressions
> > like
> > > functions etc. Try to populate the data for class property in constructor
> > of
> > > the class.
>
> > > Amit Badkas
>
> > > PHP Applications for E-Biz:http://www.sanisoft.com
>
> > > On Thu, Nov 18, 2010 at 7:24 PM, Jacob <jacobsteri...@gmail.com> wrote:
> > > > Hello all,
>
> > > > today I started with unit testing with SimpleTest and ran into a
> > > > problem. In some model i have a method 'findToday', which finds
> > > > records where 'day' is set to today's date. It's is a very simple
> > > > function which works but to become familiar with unit testing I wrote
> > > > a test en a fixture for it. While writing the fixture I realized that
> > > > the 'day' field had to be dynamic for the tests to succeed so i made a
> > > > variable $today which contains todays date date('Y/m/d'). This
> > > > variable I put in the fixed data.
> > > > I ran the test and it gave me an error:
> > > >  'Parse error: syntax error, unexpected '(', expecting ',' or ';'
> > > > in ........ on line 18'
> > > > I ran in to some information which said that fixture data is really
> > > > fixed, so there can't be any dynamic data in it.
> > > > How should I fix this problem? I don't want to update my fixtures
> > > > every time I want to test my function.
>
> > > > Greetz Jacob
>
> > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp
> > 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<cake-php%2Bunsubscribe@googlegroups.com>
> > <cake-php%2Bunsubscribe@googlegroups.com<cake-php%252Bunsubscribe@googlegroups.com>>For
> > more options, visit this group at
> > > >http://groups.google.com/group/cake-php?hl=en
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd 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<cake-php%2Bunsubscribe@googlegroups.com>For more options, visit this group at
> >http://groups.google.com/group/cake-php?hl=en

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

No comments: