Thursday, April 26, 2012

Mock testing , don't save data.

$Posts = $this->generate('Posts', array(
        'models' => array('Post' => array('save'))
));
    $Posts->Post->expects($this->any())->method('save');
        $this->testAction('/user/posts/add', array(
                  'data' => array(
                          'Post' => array(
                      'body' => 'test',
                      'guest' => 'hello',
                      'thread_id' => '1'
        ),
        ),
         'method' => 'post'
 ));

$this->assertTrue(is_array($Posts->Post->findByGuest('hello')));  // return false

 In this case , data wasn't saved. How can i do test mock save data ?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
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

No comments: