build() public method

Builds a sleep(), usleep(), date(), time() and microtime() mock environment.
public build ( ) : MockEnvironment
return MockEnvironment
 protected function setUp()
 {
     $builder = new SleepEnvironmentBuilder();
     $builder->addNamespace(__NAMESPACE__)->addNamespace("bandwidthThrottle\\tokenBucket\\converter")->setTimestamp(1417011228);
     $this->sleepEnvironent = $builder->build();
     $this->sleepEnvironent->enable();
 }
Example #2
0
 protected function setUp()
 {
     parent::setUp();
     $builder = new SleepEnvironmentBuilder();
     $builder->addNamespace(__NAMESPACE__);
     $sleep = $builder->build();
     $sleep->enable();
     $this->registerForTearDown($sleep);
 }
Example #3
0
 /**
  * Tests the example from the documentation.
  *
  * @test
  */
 public function testExample3()
 {
     $builder = new SleepEnvironmentBuilder();
     $builder->addNamespace(__NAMESPACE__)->setTimestamp(12345);
     $environment = $builder->build();
     $environment->enable();
     sleep(10);
     assert(12345 + 10 == time());
     $this->assertEquals(12345 + 10, time());
 }