Re: Creating a mocked model uses default database instead of test in PHPUnit

2011-11-30 Thread elitalon
It worked, but in addition I have to set the model alias: $this-User-alias = 'User'; because a simple `$this-User-read(null, 1)` raised an error saying that 'User.a_column' couldn't be found. On Nov 24, 3:22 pm, José Lorenzo jose@gmail.com wrote: When mocking a model it is recommended

Re: Creating a mocked model uses default database instead of test in PHPUnit

2011-11-24 Thread José Lorenzo
When mocking a model it is recommended that you pass the correct parameters to the contstructor: $this-User = $this-getMock('User', array('_saveUploadedFile', '_removeUploadedFile'), array(false, 'users', 'test')); The third parameter indicates that you want to use the 'users' table and the

Creating a mocked model uses default database instead of test in PHPUnit

2011-11-23 Thread elitalon
Hi, I am testing a model in CakePHP 2 and have mocked a model like this: $this-User = $this-getMock('User', array('_saveUploadedFile', '_removeUploadedFile')); $this-User-expects($this-any()) -method('_saveUploadedFile') -with($data, Configure::read('App.myDirectory'), true);