Exemplo n.º 1
0
 /**
  * Test creation from array.
  *
  * @covers \BrightNucleus\Config\ConfigFactory::createFromArray
  *
  * @since  0.3.0
  */
 public function testCreateFromArray()
 {
     $config = ConfigFactory::createFromArray(['some_key' => 'some_value']);
     $this->assertInstanceOf('\\BrightNucleus\\Config\\ConfigInterface', $config);
     $this->assertInstanceOf('\\BrightNucleus\\Config\\AbstractConfig', $config);
     $this->assertInstanceOf('\\BrightNucleus\\Config\\Config', $config);
     $this->assertTrue($config->hasKey('some_key'));
     $this->assertEquals('some_value', $config->getKey('some_key'));
 }
Exemplo n.º 2
0
 public function testPreparationsThroughConfig()
 {
     $injector = new Injector(ConfigFactory::createFromArray(['preparations' => ['stdClass' => function ($obj, $injector) {
         $obj->testval = 42;
     }, 'BrightNucleus\\Injector\\Test\\SomeInterface' => function ($obj, $injector) {
         $obj->testProp = 42;
     }]]));
     $obj1 = $injector->make('stdClass');
     $this->assertSame(42, $obj1->testval);
     $obj2 = $injector->make('BrightNucleus\\Injector\\Test\\PreparesImplementationTest');
     $this->assertSame(42, $obj2->testProp);
 }
Exemplo n.º 3
0
 /**
  * Get the configuration to use in the ViewBuilder.
  *
  * @since 0.2.0
  *
  * @return ConfigInterface Configuration passed in through the constructor.
  */
 protected function getConfig($config = null)
 {
     $defaults = ConfigFactory::create(__DIR__ . '/../../config/defaults.php', $config);
     $config = $config ? ConfigFactory::createFromArray(array_merge_recursive($defaults->getArrayCopy(), $config->getArrayCopy())) : $defaults;
     return $config->getSubConfig('BrightNucleus\\View');
 }