Hi,

I want to test a function of Users (display) which calls a component
(Country) its function "countryName" respectively. Now I want to mock
this component and have it return a predefined value.
I thought of using testAction and setup my test like below.
the problem: the mock doesn't seem to work, the component still gets
called and I dont get "testCountry" in the result. do I have any
errors in the code?

thx a lot!

--- snip ---

loadController('Users');
loadComponent('Country');
Mock::generatePartial('CountryComponent', 'MockCountryComponent',
array('countryName'));

class UsersControllerTest extends CakeTestCase {

        function setUp(){
                $this->UsersController =& new UsersController( );
                $this->UsersController->Country =& new MockCountryComponent( );
        }

        function testDisplay(){
                $this->UsersController->Country->setReturnValue('countryName',
'testCountry');
                $result = $this->testAction(
                        '/users/display',
                        array(
                                'return' => 'vars'
                        )
                );
                debug( $result );
        }
}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to