Пример #1
0
 private static function getDataBaseDriver(DataSourceType $type)
 {
     $driverName = $type->__toString();
     if (array_key_exists($driverName, self::$drivers)) {
         return self::$drivers[$driverName];
     }
     $className = "\\picon\\" . $driverName . 'Driver';
     if (class_exists($className)) {
         self::$drivers[$driverName] = new $className();
         return self::$drivers[$driverName];
     }
     throw new \InvalidArgumentException(sprintf('Database driver %s does not exist', $driverName));
 }
Пример #2
0
 private static function processDataSources(\DOMDocument $xml, Config &$config)
 {
     $sources = $xml->getElementsByTagName(self::DATA_SOURCE_ELEMENT);
     foreach ($sources as $source) {
         $type = DataSourceType::valueOf($source->getAttribute('type'));
         $name = $source->getAttribute('name');
         $host = $source->getElementsByTagName('host')->item(0)->nodeValue;
         $port = $source->getElementsByTagName('port')->length == 0 ? null : $source->getElementsByTagName('port')->item(0)->nodeValue;
         $username = $source->getElementsByTagName('username')->item(0)->nodeValue;
         $password = $source->getElementsByTagName('password')->item(0)->nodeValue;
         $database = $source->getElementsByTagName('database')->item(0)->nodeValue;
         $dataSource = new DataSourceConfig($type, $name, $host, $port, $username, $password, $database);
         $config->addDataSource($dataSource);
     }
 }
Пример #3
0
 public function testValidConfig()
 {
     $config = ConfigLoader::load(dirname(__FILE__) . '/../../config/picon.xml');
     $this->assertSame('HomePage', $config->getHomePage());
     $this->assertSame('auto', $config->getStartUp());
     $config = ConfigLoader::load(dirname(__FILE__) . '/../../config/full.xml');
     $this->assertSame('HomePage', $config->getHomePage());
     $this->assertSame('auto', $config->getStartUp());
     $this->assertTrue($config->getProfile()->isCacheMarkup());
     $this->assertFalse($config->getProfile()->isShowPiconTags());
     $this->assertFalse($config->getProfile()->isCleanBeforeOutput());
     $sources = $config->getDataSources();
     $this->assertCount(1, $sources);
     $source = $sources[0];
     $this->assertSame($source->name, 'testSource');
     $this->assertEquals($source->type, DataSourceType::valueOf("MySQL"));
     $this->assertSame($source->port, '3306');
     $this->assertSame($source->host, 'localhost');
     $this->assertSame($source->username, 'someuser');
     $this->assertSame($source->password, 'somepassword');
     $this->assertSame($source->database, 'somedb');
 }