Skip to content

Commit b0de541

Browse files
committed
Update how config is set so Migration tests will run.
1 parent 6daf5c6 commit b0de541

1 file changed

Lines changed: 25 additions & 32 deletions

File tree

tests/system/Database/Migrations/MigrationRunnerTest.php

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,24 @@ class MigrationRunnerTest extends CIDatabaseTestCase
88
{
99
protected $root;
1010
protected $start;
11+
protected $config;
1112

1213
public function setUp()
1314
{
1415
parent::setUp();
1516

16-
$this->root = vfsStream::setup('root');
17-
$this->start = $this->root->url() . '/';
17+
$this->root = vfsStream::setup('root');
18+
$this->start = $this->root->url() . '/';
19+
$this->config = new Migrations();
20+
$this->config->enabled = true;
1821
}
1922

2023
/**
2124
* @expectedException \CodeIgniter\Exceptions\ConfigException
2225
*/
2326
public function testThrowsOnInvalidMigrationType()
2427
{
25-
$config = new Migrations();
28+
$config = $this->config;
2629
$config->type = 'narwhal';
2730

2831
$runner = new MigrationRunner($config);
@@ -31,8 +34,7 @@ public function testThrowsOnInvalidMigrationType()
3134
public function testLoadsDefaultDatabaseWhenNoneSpecified()
3235
{
3336
$dbConfig = new \Config\Database();
34-
$config = new Migrations();
35-
$runner = new MigrationRunner($config);
37+
$runner = new MigrationRunner($this->config);
3638

3739
$db = $this->getPrivateProperty($runner, 'db');
3840

@@ -43,8 +45,7 @@ public function testLoadsDefaultDatabaseWhenNoneSpecified()
4345

4446
public function testGetCliMessages()
4547
{
46-
$config = new Migrations();
47-
$runner = new MigrationRunner($config);
48+
$runner = new MigrationRunner($this->config);
4849

4950
$messages = [
5051
'foo',
@@ -58,8 +59,7 @@ public function testGetCliMessages()
5859

5960
public function testGetHistory()
6061
{
61-
$config = new Migrations();
62-
$runner = new MigrationRunner($config);
62+
$runner = new MigrationRunner($this->config);
6363

6464
$tableMaker = $this->getPrivateMethodInvoker($runner, 'ensureTable');
6565
$tableMaker();
@@ -79,8 +79,7 @@ public function testGetHistory()
7979

8080
public function testGetHistoryReturnsEmptyArrayWithNoResults()
8181
{
82-
$config = new Migrations();
83-
$runner = new MigrationRunner($config);
82+
$runner = new MigrationRunner($this->config);
8483

8584
$tableMaker = $this->getPrivateMethodInvoker($runner, 'ensureTable');
8685
$tableMaker();
@@ -90,8 +89,7 @@ public function testGetHistoryReturnsEmptyArrayWithNoResults()
9089

9190
public function testGetMigrationNumber()
9291
{
93-
$config = new Migrations();
94-
$runner = new MigrationRunner($config);
92+
$runner = new MigrationRunner($this->config);
9593

9694
$method = $this->getPrivateMethodInvoker($runner, 'getMigrationNumber');
9795

@@ -100,8 +98,7 @@ public function testGetMigrationNumber()
10098

10199
public function testGetMigrationNumberReturnsZeroIfNoneFound()
102100
{
103-
$config = new Migrations();
104-
$runner = new MigrationRunner($config);
101+
$runner = new MigrationRunner($this->config);
105102

106103
$method = $this->getPrivateMethodInvoker($runner, 'getMigrationNumber');
107104

@@ -110,8 +107,7 @@ public function testGetMigrationNumberReturnsZeroIfNoneFound()
110107

111108
public function testSetSilentStoresValue()
112109
{
113-
$config = new Migrations();
114-
$runner = new MigrationRunner($config);
110+
$runner = new MigrationRunner($this->config);
115111

116112
$runner->setSilent(true);
117113
$this->assertTrue($this->getPrivateProperty($runner, 'silent'));
@@ -122,34 +118,31 @@ public function testSetSilentStoresValue()
122118

123119
public function testSetNameStoresValue()
124120
{
125-
$config = new Migrations();
126-
$runner = new MigrationRunner($config);
121+
$runner = new MigrationRunner($this->config);
127122

128123
$runner->setName('foo');
129124
$this->assertEquals('foo', $this->getPrivateProperty($runner, 'name'));
130125
}
131126

132127
public function testSetGroupStoresValue()
133128
{
134-
$config = new Migrations();
135-
$runner = new MigrationRunner($config);
129+
$runner = new MigrationRunner($this->config);
136130

137131
$runner->setGroup('foo');
138132
$this->assertEquals('foo', $this->getPrivateProperty($runner, 'group'));
139133
}
140134

141135
public function testSetNamespaceStoresValue()
142136
{
143-
$config = new Migrations();
144-
$runner = new MigrationRunner($config);
137+
$runner = new MigrationRunner($this->config);
145138

146139
$runner->setNamespace('foo');
147140
$this->assertEquals('foo', $this->getPrivateProperty($runner, 'namespace'));
148141
}
149142

150143
public function testFindMigrationsReturnsEmptyArrayWithNoneFound()
151144
{
152-
$config = new Migrations();
145+
$config = $this->config;
153146
$config->type = 'timestamp';
154147
$runner = new MigrationRunner($config);
155148

@@ -160,7 +153,7 @@ public function testFindMigrationsReturnsEmptyArrayWithNoneFound()
160153

161154
public function testFindMigrationsSuccessTimestamp()
162155
{
163-
$config = new Migrations();
156+
$config = $this->config;
164157
$config->type = 'timestamp';
165158
$runner = new MigrationRunner($config);
166159

@@ -191,7 +184,7 @@ public function testFindMigrationsSuccessTimestamp()
191184

192185
public function testFindMigrationsSuccessOrder()
193186
{
194-
$config = new Migrations();
187+
$config = $this->config;
195188
$config->type = 'sequential';
196189
$runner = new MigrationRunner($config);
197190

@@ -225,7 +218,7 @@ public function testFindMigrationsSuccessOrder()
225218
*/
226219
public function testVersionThrowsMigrationGapException()
227220
{
228-
$config = new Migrations();
221+
$config = $this->config;
229222
$config->type = 'sequential';
230223
$runner = new MigrationRunner($config);
231224

@@ -240,7 +233,7 @@ public function testVersionThrowsMigrationGapException()
240233

241234
public function testVersionReturnsTrueWhenNothingToDo()
242235
{
243-
$config = new Migrations();
236+
$config = $this->config;
244237
$config->type = 'sequential';
245238
$runner = new MigrationRunner($config);
246239

@@ -259,7 +252,7 @@ public function testVersionReturnsTrueWhenNothingToDo()
259252
*/
260253
public function testVersionWithNoClassInFile()
261254
{
262-
$config = new Migrations();
255+
$config = $this->config;
263256
$config->type = 'sequential';
264257
$runner = new MigrationRunner($config);
265258
$runner->setSilent(false);
@@ -275,7 +268,7 @@ public function testVersionWithNoClassInFile()
275268

276269
public function testVersionReturnsUpDownSuccess()
277270
{
278-
$config = new Migrations();
271+
$config = $this->config;
279272
$config->type = 'sequential';
280273
$runner = new MigrationRunner($config);
281274
$runner->setSilent(false);
@@ -300,7 +293,7 @@ public function testVersionReturnsUpDownSuccess()
300293

301294
public function testLatestSuccess()
302295
{
303-
$config = new Migrations();
296+
$config = $this->config;
304297
$config->type = 'sequential';
305298
$runner = new MigrationRunner($config);
306299
$runner->setSilent(false);
@@ -320,7 +313,7 @@ public function testLatestSuccess()
320313

321314
public function testCurrentSuccess()
322315
{
323-
$config = new Migrations();
316+
$config = $this->config;
324317
$config->type = 'sequential';
325318
$config->currentVersion = 1;
326319
$runner = new MigrationRunner($config);

0 commit comments

Comments
 (0)