/** * (re)create table * * @param DriverInterface $driver * @param string $tableName */ private function createTable(DriverInterface $driver, $tableName) { /** @var $createMigration Migration */ $createMigration = $driver->createSchemaMigration($this->conn, $tableName, MigrationInterface::CREATE_TABLE); $createMigration->importFromSchema($this->schema); if ($this->conn->getScheme() === 'mysql') { // TODO tableOptions should be defined by Schema $createMigration->setTableOption('engine', 'InnoDB'); $createMigration->setTableOption('collation', 'utf8_unicode_ci'); } $createMigration->execute(); }
/** * @dataProvider provideGetScheme * @param string $dsn * @param string $expected * @param bool $throwsException */ public function testGetScheme($dsn, $expected, $throwsException) { /** @var \Dive\Connection\Driver\DriverInterface $driver */ $driver = $this->getMockForAbstractClass('\\Dive\\Connection\\Driver\\DriverInterface'); if ($throwsException) { $this->setExpectedException('\\InvalidArgumentException'); } $conn = new Connection($driver, $dsn); $this->assertEquals($expected, $conn->getScheme()); }
/** * constructor * * @param Connection $conn * @param DataTypeMapper $dataTypeMapper * @param string $recordNamespace */ public function __construct(Connection $conn, DataTypeMapper $dataTypeMapper = null, $recordNamespace = '\\') { $this->conn = $conn; $this->recordNamespace = $recordNamespace; if ($dataTypeMapper === null) { // TODO potential security issue!! $class = '\\Dive\\Schema\\DataTypeMapper\\' . ucfirst($conn->getScheme()) . 'DataTypeMapper'; $dataTypeMapper = new $class(); } $this->dataTypeMapper = $dataTypeMapper; }