Esempio n. 1
0
 public function testCreateTable()
 {
     $db = $this->getDb();
     $adapter = new SqliteTypeAdapter($db);
     $db->expects($this->exactly(3))->method('execute')->withConsecutive([$this->equalTo('CREATE TABLE "foo_bar" (' . 'id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, ' . 'foo TEXT(255) NOT NULL DEFAULT "bar")')], [$this->equalTo('CREATE INDEX "foo_bar_foo_id" ON "foo_bar" (foo, id)')], [$this->equalTo('CREATE UNIQUE INDEX "foo_bar_foo" ON "foo_bar" (foo)')]);
     $def = new \Jivoo\Data\DefinitionBuilder();
     $def->addAutoIncrementId();
     $def->foo = DataType::string(255, false, "bar");
     $def->addKey(['foo', 'id']);
     $def->addUnique('foo');
     $adapter->createTable('FooBar', $def);
 }
Esempio n. 2
0
 public function testCreateTable()
 {
     $db = $this->getDb();
     $adapter = new PostgresqlTypeAdapter($db);
     $db->expects($this->exactly(3))->method('execute')->withConsecutive([$this->equalTo('CREATE TABLE {FooBar} (' . 'id serial NOT NULL, ' . 'foo varchar(255) NOT NULL DEFAULT "bar", ' . 'CONSTRAINT "foo_bar_PRIMARY" PRIMARY KEY (id))')], [$this->equalTo('CREATE INDEX "foo_bar_foo_id" ON {FooBar} (foo, id)')], [$this->equalTo('CREATE UNIQUE INDEX "foo_bar_foo" ON {FooBar} (foo)')]);
     $def = new \Jivoo\Data\DefinitionBuilder();
     $def->addAutoIncrementId();
     $def->foo = DataType::string(255, false, "bar");
     $def->addKey(['foo', 'id']);
     $def->addUnique('foo');
     $adapter->createTable('FooBar', $def);
 }
Esempio n. 3
0
 public function testCreateTable()
 {
     $db = $this->getDb();
     $adapter = new MysqlTypeAdapter($db);
     $db->expects($this->once())->method('execute')->with($this->equalTo('CREATE TABLE `foo_bar` (' . 'id INT UNSIGNED NOT NULL AUTO_INCREMENT, ' . 'foo VARCHAR(255) NOT NULL DEFAULT "bar", ' . 'PRIMARY KEY (id), ' . 'INDEX (foo, id), ' . 'UNIQUE (foo)' . ') CHARACTER SET utf8'));
     $def = new \Jivoo\Data\DefinitionBuilder();
     $def->addAutoIncrementId();
     $def->foo = DataType::string(255, false, "bar");
     $def->addKey(['foo', 'id']);
     $def->addUnique('foo');
     $adapter->createTable('FooBar', $def);
 }