unit testing - how to have class return mock on new Class()? -
in phpunit, want test controller. part of need return mock when new class() called.
i have tried:
$mockentity = $this->getmock( 'vet', array( '__construct', 'setdoctrine', 'setcontainer' ) ); $mockform = $this->getmock( 'vettype', array( 'handlerequest', 'isvalid', 'createview' ) ); $mockentity->expects( $this->once() )->method( '__construct')->willreturn( $this->returnvalue( $mockentity ) );
and simply:
$mockentity = $this->getmock( 'vet', array( 'setdoctrine', 'setcontainer' ) ); $mockform = $this->getmock( 'vettype', array( 'handlerequest', 'isvalid', 'createview' ) );
both return "vet" object, not mock. possible phpunit 4.0.20, or need add getnewvet() function?
this symfony2 controller
Comments
Post a Comment