Skip to content

Commit 7f93048

Browse files
committed
Fixing tests for Mysql databases
1 parent fdd30fc commit 7f93048

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

system/Database/MigrationRunner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ public function version(string $targetVersion, string $namespace = null, string
254254
$this->checkMigrations($migrations, $method, $targetVersion);
255255

256256
// loop migration for each namespace (module)
257-
258257
$migrationStatus = false;
259258
foreach ($migrations as $version => $migration)
260259
{
@@ -263,6 +262,7 @@ public function version(string $targetVersion, string $namespace = null, string
263262
{
264263
$migrationStatus = false;
265264
include_once $migration->path;
265+
266266
// Get namespaced class name
267267
$class = $this->namespace . '\Database\Migrations\Migration_' . ($migration->name);
268268

tests/system/Database/Live/ForgeTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,11 @@ public function testDropTableSuccess()
724724

725725
$this->forge->dropTable('droptest', true);
726726

727-
$this->assertCount(0, $this->db->getIndexData('droptest'));
727+
$this->assertFalse($this->db->tableExists('dropTest'));
728+
729+
if ($this->db->DBDriver === 'SQLite3')
730+
{
731+
$this->assertCount(0, $this->db->getIndexData('droptest'));
732+
}
728733
}
729734
}

tests/system/Database/Migrations/MigrationRunnerTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,13 +279,17 @@ public function testVersionWithNoClassInFile()
279279

280280
vfsStream::newFile('001_some_migration.php')->at($this->root);
281281

282-
$version = $runner->version(0);
282+
$version = $runner->version(1);
283283

284284
$this->assertFalse($version);
285285
}
286286

287287
public function testVersionReturnsUpDownSuccess()
288288
{
289+
$forge = \Config\Database::forge();
290+
$forge->dropTable('migrations', true);
291+
$forge->dropTable('foo', true);
292+
289293
$config = $this->config;
290294
$config->type = 'sequential';
291295
$runner = new MigrationRunner($config);
@@ -298,15 +302,15 @@ public function testVersionReturnsUpDownSuccess()
298302
$this->root
299303
);
300304

301-
$version = $runner->version(1);
305+
$version = $runner->version('001');
302306

303307
$this->assertEquals('001', $version);
304308
$this->seeInDatabase('foo', ['key' => 'foobar']);
305309

306310
$version = $runner->version(0);
307311

308312
$this->assertEquals('000', $version);
309-
$this->assertFalse(db_connect()->tableExists('foo'));
313+
$this->assertFalse($this->db->tableExists('foo'));
310314
}
311315

312316
public function testLatestSuccess()

0 commit comments

Comments
 (0)