Re: Cake 2.0 RC3 / PHPUnit - How to make mock for a model?

2011-10-10 Thread Sway
Thanks for reply. Actually I have some checks like if (!class_exists('RatePlanMock')) {...} they were removed to simplify code (and it actually works when there is only 1 test) User and RatePlan classes were imported also Trick was in 2nd argument of $this->getMock(). It appeared that for model

Re: Cake 2.0 RC3 / PHPUnit - How to make mock for a model?

2011-10-06 Thread José Lorenzo
Mocks should be done inside each test method, but if you are doing them inside setUp() then, you should not specify the class name for the mock, because you will get duplicate defined class errors. So lets say you want to mock the save method for a model App::uses('User', 'Model') //It is impor

Cake 2.0 RC3 / PHPUnit - How to make mock for a model?

2011-10-06 Thread Sway
Hi, I have a problem with creating mocks for models which have related models. Models looks like: class User extends AppModel { public $hasAndBelongsToMany = array( 'RatePlan', ); } class RatePlan extends AppModel { public $hasAndBelongsToMany = array( 'User', )