Skip to content

Commit

Permalink
Fixed QueryBuilderTest;
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Jul 20, 2015
1 parent 890365b commit 9c08905
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions tests/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}

0 comments on commit 9c08905

Please sign in to comment.