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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -