Skip to content

Commit

Permalink
Fix failing tests related to table counts.
Browse files Browse the repository at this point in the history
The table counts will not always be exact now that we have more tests
with fixtures. In addition SQLite is being silly again, and requires the
schema to only be made once per test run.
  • Loading branch information
markstory committed Apr 2, 2014
1 parent 74c6eff commit dd201c6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
5 changes: 2 additions & 3 deletions tests/TestCase/Database/Schema/MysqlSchemaTest.php
Expand Up @@ -228,9 +228,8 @@ public function testListTables() {
$result = $schema->listTables();

$this->assertInternalType('array', $result);
$this->assertCount(2, $result);
$this->assertEquals('schema_articles', $result[0]);
$this->assertEquals('schema_authors', $result[1]);
$this->assertContains('schema_articles', $result);
$this->assertContains('schema_authors', $result);
}

/**
Expand Down
5 changes: 2 additions & 3 deletions tests/TestCase/Database/Schema/PostgresSchemaTest.php
Expand Up @@ -234,9 +234,8 @@ public function testListTables() {
$schema = new SchemaCollection($connection);
$result = $schema->listTables();
$this->assertInternalType('array', $result);
$this->assertCount(2, $result);
$this->assertEquals('schema_articles', $result[0]);
$this->assertEquals('schema_authors', $result[1]);
$this->assertContains('schema_articles', $result);
$this->assertContains('schema_authors', $result);
}

/**
Expand Down
17 changes: 11 additions & 6 deletions tests/TestCase/Database/Schema/SqliteSchemaTest.php
Expand Up @@ -193,8 +193,15 @@ public function testConvertCompositePrimaryKey() {
*/
protected function _createTables($connection) {
$this->_needsConnection();
$connection->execute('DROP TABLE IF EXISTS schema_articles');
$connection->execute('DROP TABLE IF EXISTS schema_authors');

$schema = new SchemaCollection($connection);
$result = $schema->listTables();
if (
in_array('schema_articles', $result) &&
in_array('schema_authors', $result)
) {
return;
}

$table = <<<SQL
CREATE TABLE schema_authors (
Expand Down Expand Up @@ -235,10 +242,8 @@ public function testListTables() {
$result = $schema->listTables();

$this->assertInternalType('array', $result);
$this->assertCount(3, $result);
$this->assertEquals('schema_articles', $result[0]);
$this->assertEquals('schema_authors', $result[1]);
$this->assertEquals('sqlite_sequence', $result[2]);
$this->assertContains('schema_articles', $result);
$this->assertContains('schema_authors', $result);
}

/**
Expand Down

0 comments on commit dd201c6

Please sign in to comment.