From 9c08905e345a8a143fd7d96c398b9e5f218eb050 Mon Sep 17 00:00:00 2001 From: Edgard Lorraine Messias Date: Mon, 20 Jul 2015 08:48:08 -0300 Subject: [PATCH] Fixed QueryBuilderTest; --- tests/QueryBuilderTest.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/QueryBuilderTest.php b/tests/QueryBuilderTest.php index 110465f..1e1f1c9 100644 --- a/tests/QueryBuilderTest.php +++ b/tests/QueryBuilderTest.php @@ -272,23 +272,24 @@ public function testCreateTableWithAutoIncrement() 'description' => Schema::TYPE_STRING, ]; $this->getConnection(false)->createCommand($qb->createTable('autoincrement_table', $columns))->execute(); + $qb->db->getTableSchema('autoincrement_table', true); //Force update schema + + $this->assertEquals(1, $this->getConnection(false)->getSchema()->insert('autoincrement_table', ['description' => 'auto increment 1'])['id']); + $this->assertEquals(2, $this->getConnection(false)->getSchema()->insert('autoincrement_table', ['description' => 'auto increment 2'])['id']); + $this->assertEquals(3, $this->getConnection(false)->getSchema()->insert('autoincrement_table', ['description' => 'auto increment 3'])['id']); + $this->assertEquals(4, $this->getConnection(false)->getSchema()->insert('autoincrement_table', ['description' => 'auto increment 4'])['id']); - $this->getConnection(false)->createCommand()->insert('autoincrement_table', ['description' => 'auto increment 1'])->execute(); - $this->getConnection(false)->createCommand()->insert('autoincrement_table', ['description' => 'auto increment 2'])->execute(); - $this->getConnection(false)->createCommand()->insert('autoincrement_table', ['description' => 'auto increment 3'])->execute(); - $this->getConnection(false)->createCommand()->insert('autoincrement_table', ['description' => 'auto increment 4'])->execute(); - $this->assertEquals(4, (new Query())->from('autoincrement_table')->max('id', $this->getConnection(false))); //Drop and recreate, for test sequences $this->getConnection(false)->createCommand($qb->dropTable('autoincrement_table'))->execute(); $this->getConnection(false)->createCommand($qb->createTable('autoincrement_table', $columns))->execute(); - $this->getConnection(false)->createCommand()->insert('autoincrement_table', ['description' => 'auto increment 1'])->execute(); - $this->getConnection(false)->createCommand()->insert('autoincrement_table', ['description' => 'auto increment 2'])->execute(); - $this->getConnection(false)->createCommand()->insert('autoincrement_table', ['description' => 'auto increment 3'])->execute(); - $this->getConnection(false)->createCommand()->insert('autoincrement_table', ['description' => 'auto increment 4'])->execute(); - + $this->assertEquals(1, $this->getConnection(false)->getSchema()->insert('autoincrement_table', ['description' => 'auto increment 1'])['id']); + $this->assertEquals(2, $this->getConnection(false)->getSchema()->insert('autoincrement_table', ['description' => 'auto increment 2'])['id']); + $this->assertEquals(3, $this->getConnection(false)->getSchema()->insert('autoincrement_table', ['description' => 'auto increment 3'])['id']); + $this->assertEquals(4, $this->getConnection(false)->getSchema()->insert('autoincrement_table', ['description' => 'auto increment 4'])['id']); + $this->assertEquals(4, (new Query())->from('autoincrement_table')->max('id', $this->getConnection(false))); } }