コード例 #1
0
 /**
  * @param array $parameters
  *
  * @throws \RuntimeException
  */
 public function __construct(array $parameters)
 {
     $reader = new AdapterParameterReader($parameters);
     if (false === $reader->isValid()) {
         throw new \RuntimeException('Provided configuration is invalid');
     }
     if (true === empty($this->adapterMap[$reader->getType()])) {
         throw new \RuntimeException('Database type is not supported.');
     }
     $phinxParameters = array_merge(['user' => $parameters[Reader::USER], 'pass' => $parameters[Reader::PASS], 'name' => $parameters[Reader::DATABASE][Reader::DB_NAME], 'charset' => $this->getDefaultCharset($parameters), 'default_migration_table' => $this->getMigrationTable($parameters)], $parameters[Reader::DATABASE]);
     $this->adapter = $this->getNewAdapterInstance($phinxParameters, $reader->getType());
 }
 /**
  * @test
  */
 public function testGetType()
 {
     $config = $this->getSqliteConfig();
     $adapter = new AdapterParameterReader($config);
     $this->assertSame('sqlite', $adapter->getType());
 }