public function testWithPHPUnitTest_Fail2()
 {
     try {
         $mock = \StaticMock::mock('StaticMock\\Car');
         $mock->shouldReceive('beep')->with(1)->andReturn('BEEP!');
         $p = new Person();
         $this->assertEquals('BEEP!', $p->warn(5));
         $this->assertStaticMock($mock);
         $this->fail();
     } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals('Failed asserting that mocked method should be called with (1) but called with (5).', $e->getMessage());
     }
 }
Exemple #2
0
 public function testAndReturnWithAnonymousFunction()
 {
     $mock = \StaticMock::mock('StaticMock\\Car');
     $mock->shouldReceive('beep')->times(1)->andImplement(function ($x) {
         return $x * 3;
     });
     $p = new Person();
     $actual = $p->warn(5);
     $this->assertEquals(15, $actual);
     $mock->assert();
 }