Skip to content

Commit d80056b

Browse files
committed
Fix and test for re-initialize exception
1 parent 2d93777 commit d80056b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/Migrator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(
4141
public function initialize()
4242
{
4343
if ($this->versionStorage->hasVersioningNode()) {
44-
throw MigratorException('Will not re-initialize');
44+
throw new MigratorException('This repository has already been initialized. Will not re-initialize.');
4545
}
4646

4747
foreach (array_keys($this->versionCollection->getAllVersions()) as $timestamp) {

tests/Functional/MigrationTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,20 @@ public function testInitialize()
159159
$this->assertCount(2, $nodes);
160160
}
161161

162+
/**
163+
* It should throw an exception if trying to reiniitialize.
164+
*
165+
* @expectedException PHPCR\Migrations\Exception\MigratorException
166+
* @expectedExceptionMessage Will not re-initialize
167+
*/
168+
public function testReinitialize()
169+
{
170+
$this->addVersion(self::VERSION1);
171+
$this->addVersion(self::VERSION2);
172+
$this->getMigrator()->initialize();
173+
$this->getMigrator()->initialize();
174+
}
175+
162176
/**
163177
* It should migrate to the next version.
164178
*/

0 commit comments

Comments
 (0)