addNamespace() public method

Add a namespace for the mock environment.
public addNamespace ( string $namespace ) : SleepEnvironmentBuilder
$namespace string A namespace for the mock environment.
return SleepEnvironmentBuilder
Beispiel #1
0
 protected function setUp()
 {
     parent::setUp();
     $sleepBuilder = new SleepEnvironmentBuilder();
     $sleepBuilder->addNamespace(__NAMESPACE__);
     $sleepBuilder->addNamespace('malkusch\\lock\\util');
     $sleep = $sleepBuilder->build();
     $sleep->enable();
     $this->registerForTearDown($sleep);
 }
 protected function setUp()
 {
     $builder = new SleepEnvironmentBuilder();
     $builder->addNamespace(__NAMESPACE__)->addNamespace("bandwidthThrottle\\tokenBucket\\converter")->setTimestamp(1417011228);
     $this->sleepEnvironent = $builder->build();
     $this->sleepEnvironent->enable();
 }
Beispiel #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());
 }