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);
        ->will($this->returnValue(true));
$this->User->expects($this->any())
        ->method('_removeUploadedFile')
        ->with($data, Configure::read('App.myDirectory'))
        ->will($this->returnValue(true));

Since any operation with the database raises the following error:

        "Database table mock__user_b6241a4cs for model User was not found."

I redefined the table:

        $this->User->alias = 'User';
        $this->User->useTable = 'users';

Now the test works well, but it's using the default database in
database.php instead of the test one.

What can be happening? Why the database configuration for testing
changes when using mocked objects?

Could it be related to database permissions that causes the mocked
object not being able to create its custom tables?

Thanks!

-- 
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
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to