Пример #1
0
 /**
  * Make sure the test listener will validate any
  * object created during a test at the end of the test
  *
  * @return void
  * @test
  */
 public function testListener()
 {
     $classMocker = new ClassMocker();
     $classMocker->mock('TestListenerTest_SomeClass');
     $classMocker->autoload('TestListenerTest_SomeClass');
     $testCase = $this->getMockForAbstractClass(\PHPUnit_Framework_TestCase::class);
     $listener = new TestListener();
     $listener->startTest($testCase);
     $testObject = new \TestListenerTest_SomeClass();
     $testObject->expects($this->once())->method('test');
     try {
         $listener->endTest($testCase, 0);
         $this->fail("Should fail");
     } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertStringStartsWith('Expectation failed for method name is equal to', $e->getMessage());
     }
     // everything has been reset so no error should be thrown
     $listener->endTest($testCase, 0);
 }
Пример #2
0
 /**
  * @return InvocationMocker
  */
 public function __phpunit_getInvocationMocker()
 {
     if ($this->__phpunit_invocationMocker === null) {
         $this->__phpunit_invocationMocker = new InvocationMocker();
         if (self::$__classMock_activeListener) {
             self::$__classMock_activeListener->registerMock($this);
         }
     }
     return $this->__phpunit_invocationMocker;
 }