Skip to content

Commit f2c0d34

Browse files
committed
Update DB test namespaces
1 parent 3f214b6 commit f2c0d34

4 files changed

Lines changed: 29 additions & 18 deletions

File tree

system/Test/CIDatabaseTestCase.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ class CIDatabaseTestCase extends CIUnitTestCase
6767
protected $seed = '';
6868

6969
/**
70-
* The path to where we can find the migrations
71-
* and seeds directories. Allows overriding
72-
* the default application directories.
70+
* The path to where we can find the seeds directory.
71+
* Allows overriding the default application directories.
7372
*
7473
* @var string
7574
*/

tests/_support/Config/MockServices.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ class MockServices extends BaseService
77
{
88

99
public $psr4 = [
10-
'Tests/Support' => TESTPATH . '_support/',
10+
'Tests/Support' => TESTPATH . '_support/',
11+
'Tests/Support/DatabaseTestMigrations' => TESTPATH . '_support/DatabaseTestMigrations',
12+
'Tests/Support/MigrationTestMigrations' => TESTPATH . '_support/MigrationTestMigrations',
1113
];
1214
public $classmap = [];
1315

tests/system/Database/Migrations/MigrationRunnerTest.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,22 @@ public function testFindMigrationsSuccessTimestamp()
176176
$runner = $runner->setNamespace('Tests\Support\MigrationTestMigrations');
177177

178178
$mig1 = (object)[
179-
'name' => 'Some_migration',
180-
'path' => TESTPATH . '_support/MigrationTestMigrations/Database/Migrations/2018-01-24-102301_Some_migration.php',
181-
'version' => '2018-01-24-102301',
182-
'class' => 'Tests\Support\MigrationTestMigrations\Database\Migrations\Migration_some_migration',
179+
'name' => 'Some_migration',
180+
'path' => TESTPATH . '_support/MigrationTestMigrations/Database/Migrations/2018-01-24-102301_Some_migration.php',
181+
'version' => '2018-01-24-102301',
182+
'class' => 'Tests\Support\MigrationTestMigrations\Database\Migrations\Migration_some_migration',
183+
'namespace' => 'Tests\Support\MigrationTestMigrations',
183184
];
185+
$mig1->uid = $runner->getObjectUid($mig1);
186+
184187
$mig2 = (object)[
185-
'name' => 'Another_migration',
186-
'path' => TESTPATH . '_support/MigrationTestMigrations/Database/Migrations/2018-01-24-102302_Another_migration.php',
187-
'version' => '2018-01-24-102302',
188-
'class' => 'Tests\Support\MigrationTestMigrations\Database\Migrations\Migration_another_migration',
188+
'name' => 'Another_migration',
189+
'path' => TESTPATH . '_support/MigrationTestMigrations/Database/Migrations/2018-01-24-102302_Another_migration.php',
190+
'version' => '2018-01-24-102302',
191+
'class' => 'Tests\Support\MigrationTestMigrations\Database\Migrations\Migration_another_migration',
192+
'namespace' => 'Tests\Support\MigrationTestMigrations',
189193
];
194+
$mig1->uid = $runner->getObjectUid($mig1);
190195

191196
$migrations = $runner->findMigrations();
192197

@@ -217,7 +222,7 @@ public function testMigrationThrowsDisabledException()
217222
$this->expectException(ConfigException::class);
218223
$this->expectExceptionMessage('Migrations have been loaded but are disabled or setup incorrectly.');
219224

220-
$runner->version(1);
225+
$runner->progress();
221226
}
222227

223228
public function testVersionReturnsUpDownSuccess()
@@ -235,7 +240,7 @@ public function testVersionReturnsUpDownSuccess()
235240
$runner->progress();
236241
$version = $runner->getBatchEnd($runner->getLastBatch());
237242

238-
$this->assertEquals('2018-01-24-102301', $version);
243+
$this->assertEquals('2018-01-24-102302', $version);
239244
$this->seeInDatabase('foo', ['key' => 'foobar']);
240245

241246
$runner->version(0);

user_guide_src/source/testing/database.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,15 @@ test data prior to every test running.
9494

9595
**$basePath**
9696

97-
By default, CodeIgniter will look in **tests/_support/database/migrations** and **tests/_support_database/seeds**
98-
to locate the migrations and seeds that it should run during testing. You can change this directory by specifying
99-
the path in the ``$basePath`` property. This should not include the **migrations** or **seeds** directories, but
100-
the path to the single directory that holds both of those sub-directories.
97+
By default, CodeIgniter will look in **tests/_support/Database/Seeds** to locate the seeds that it should run during testing.
98+
You can change this directores by specifying the ``$basePath`` property. This should not include the **seeds** directory,
99+
but the path to the single directory that holds the sub-directory.
100+
101+
**$namespace**
102+
103+
By default, CodeIgniter will look in **tests/_support/DatabaseTestMigrations/Database/Migrations** to locate the migrations
104+
that it should run during testing. You can change this location by specifying a new namespace in the ``$namespace`` properties.
105+
This should not include the **Database/Migrations** path, just the base namespace.
101106

102107
Helper Methods
103108
==============

0 commit comments

Comments
 (0)