Builds a sleep(), usleep(), date(), time() and microtime() mock environment.
public build ( ) : |
||
리턴 |
protected function setUp() { $builder = new SleepEnvironmentBuilder(); $builder->addNamespace(__NAMESPACE__)->addNamespace("bandwidthThrottle\\tokenBucket\\converter")->setTimestamp(1417011228); $this->sleepEnvironent = $builder->build(); $this->sleepEnvironent->enable(); }
protected function setUp() { parent::setUp(); $builder = new SleepEnvironmentBuilder(); $builder->addNamespace(__NAMESPACE__); $sleep = $builder->build(); $sleep->enable(); $this->registerForTearDown($sleep); }
/** * 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()); }