Skip to content

Commit b46c3fe

Browse files
committed
Some migration runner test fixes
1 parent dbd6fea commit b46c3fe

2 files changed

Lines changed: 9 additions & 22 deletions

File tree

system/Database/MigrationRunner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public function version(string $targetVersion, string $namespace = null, string
258258
$migrationStatus = false;
259259
foreach ($migrations as $version => $migration)
260260
{
261-
// Only include migrations within the scoop
261+
// Only include migrations within the scope
262262
if (($method === 'up' && $version > $currentVersion && $version <= $targetVersion) || ( $method === 'down' && $version <= $currentVersion && $version > $targetVersion))
263263
{
264264
$migrationStatus = false;

tests/system/Database/Migrations/MigrationRunnerTest.php

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
*/
1111
class MigrationRunnerTest extends CIDatabaseTestCase
1212
{
13+
protected $refresh = true;
14+
1315
protected $root;
1416
protected $start;
1517
protected $config;
@@ -217,15 +219,15 @@ public function testFindMigrationsSuccessOrder()
217219
}
218220

219221
/**
220-
* @expectedException \CodeIgniter\Exceptions\ConfigException
221-
* @expectedExceptionMessage Migrations have been loaded but are disabled or setup incorrectly.
222+
* @expectedException \CodeIgniter\Exceptions\ConfigException
223+
* @expectedExceptionMessage Migrations have been loaded but are disabled or setup incorrectly.
222224
*/
223225
public function testMigrationThrowsDisabledException()
224226
{
225-
$config = $this->config;
226-
$config->type = 'sequential';
227+
$config = $this->config;
228+
$config->type = 'sequential';
227229
$config->enabled = false;
228-
$runner = new MigrationRunner($config);
230+
$runner = new MigrationRunner($config);
229231

230232
$runner->setSilent(false);
231233

@@ -262,21 +264,6 @@ public function testVersionThrowsMigrationGapException()
262264
$this->assertFalse($version);
263265
}
264266

265-
public function testVersionReturnsFalseWhenNothingToDo()
266-
{
267-
$config = $this->config;
268-
$config->type = 'sequential';
269-
$runner = new MigrationRunner($config);
270-
271-
$runner = $runner->setPath($this->start);
272-
273-
vfsStream::newFile('001_some_migration.php')->at($this->root);
274-
275-
$version = $runner->version(0);
276-
277-
$this->assertFalse($version);
278-
}
279-
280267
/**
281268
* @expectedException \RuntimeException
282269
* @expectedExceptionMessage The migration class "App\Database\Migrations\Migration_some_migration" could not be found.
@@ -292,7 +279,7 @@ public function testVersionWithNoClassInFile()
292279

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

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

297284
$this->assertFalse($version);
298285
}

0 commit comments

Comments
 (0)