enable() 공개 메소드

Enables this mock.
또한 보기: Mock::disable()
또한 보기: Mock::disableAll()
public enable ( )
예제 #1
0
 /**
  * Tests redefining mocks in a different namespace.
  *
  * @test
  * @dataprovider provideTestNamespace
  */
 public function testRedefiningNamespaces()
 {
     $this->builder->setNamespace(__NAMESPACE__);
     $this->mock = $this->builder->build();
     $this->mock->enable();
     $this->assertEquals(1234, time());
 }
예제 #2
0
 /**
  * Tests case insensitive mocks.
  *
  * @param string $mockName  The mock function name.
  *
  * @test
  * @dataProvider provideTestCaseSensitivity
  */
 public function testCaseSensitivity($mockName)
 {
     $builder = new MockBuilder();
     $builder->setNamespace(__NAMESPACE__)->setName($mockName)->setFunctionProvider(new FixedValueFunction(1234));
     $this->mock = $builder->build();
     $this->mock->enable();
     $this->assertEquals(1234, time(), "time() is not mocked");
     $this->assertEquals(1234, Time(), "Time() is not mocked");
     $this->assertEquals(1234, TIME(), "TIME() is not mocked");
 }
 /**
  * Tests disabling the mock.
  *
  * @test
  */
 public function testEndTest()
 {
     $min = new Mock(__NAMESPACE__, "min", "max");
     $min->enable();
     $this->assertEquals(9, min(1, 9));
     $disabler = new MockDisabler($min);
     $disabler->endTest($this, 1);
     $this->assertEquals(1, min(1, 9));
 }
예제 #4
0
 /**
  * Tests the example from the documentation.
  *
  * @test
  */
 public function testExample5()
 {
     $time = new Mock(__NAMESPACE__, "time", function () {
         return 3;
     });
     $time->enable();
     assert(3 == time());
 }