php - PhpUnit @depends annotation and MockObject -


this code example:

class testtest extends \phpunit_framework_testcase {     public function testfirst() {         $factory_mock =             $this->getmockbuilder('factory')                 ->disableoriginalconstructor()                 ->disableoriginalclone()                 ->getmock();          $factory_mock             ->expects($this->any())             ->method('getdata')             ->will($this->returnvalue('123'));          var_dump($factory_mock->getdata());         var_dump($factory_mock->getdata());      return $factory_mock; }      /**      * @depends testfirst      */     public function testsecond(factory $factory) {         var_dump($factory->getdata());     }  } 

this result get:

    .string(3) "123"     string(3) "123"     .null 

i expect third "getdata" method invocation give me same result first two, won't happen. don't understand why. please, share knowledge inner workings of phpunit.

phpunit v3.7.29, php v5.4.23

if var_dump of mock factory in both tests see first 1 has phpunit_framework_mockobject_invocationmocker , in second test property null. mocked method being reset after test has completed running. end mock not have methods set.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -