Ejemplo n.º 1
0
 /**
  * Test des fonctionnalité du manager
  */
 public function testManageConfig()
 {
     $config = ConfigManager::getInstance();
     $this->assertEquals($config->getObjectId(), ConfigManager::getInstance()->getObjectId());
     $config->addContainer(__DIR__ . '/../Test/test.php');
     $this->assertCount(1, $config->configs);
     $config->addContainer(__DIR__ . '/../Test/test2.php');
     $this->assertCount(2, $config->configs);
     $config->addContainer(__DIR__ . '/../Test/test.php');
     $this->assertCount(2, $config->configs);
     $config->addContainer(__DIR__ . '/../Test/test2.php');
     $this->assertCount(2, $config->configs);
     $this->assertInstanceOf(ConfigContainer::class, $config->test);
     $this->assertNull($config->test3);
     $this->assertFalse(isset($config->test3));
     $catched = false;
     try {
         $value = 'salut';
         $config->yolo = $value;
     } catch (MissingPropertyException $e) {
         $this->assertEquals('yolo', $e->getPropertyName());
         $catched = true;
     }
     $this->assertTrue($catched);
     $catched = false;
     try {
         $value = 'salut';
         $config->configs = $value;
     } catch (MissingPropertyException $e) {
         $this->assertEquals('configs', $e->getPropertyName());
         $catched = true;
     }
     $this->assertTrue($catched);
 }
Ejemplo n.º 2
0
 /**
  * Test de la facade
  */
 public function testFacadeConfig()
 {
     $configManager = ConfigManager::getInstance();
     $this->assertCount(0, $configManager->configs);
     Config::add(__DIR__ . '/../Test/test.php');
     $this->assertCount(1, $configManager->configs);
     Config::add(__DIR__ . '/../Test/test2.php');
     $this->assertCount(2, $configManager->configs);
     Config::add(__DIR__ . '/../Test/test.php');
     $this->assertCount(2, $configManager->configs);
     Config::add(__DIR__ . '/../Test/test2.php');
     $this->assertCount(2, $configManager->configs);
     $this->assertTrue(Config::exist('test'));
     $this->assertTrue(Config::exist('test2'));
     $this->assertFalse(Config::exist('test3'));
     $this->assertEquals('Test\\Table', Config::get('test')->namespace['table']);
     $this->assertNull(Config::get('test3'));
     $this->assertNull(Config::get('test')->unknown);
 }