Skip to content

Commit 025265e

Browse files
authored
Merge pull request #7 from phpcr/finder_error
Throw appropriate exception if no paths provided to finder
2 parents 644f414 + 62d64c3 commit 025265e

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/VersionFinder.php

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ class VersionFinder
2020

2121
public function __construct(array $paths)
2222
{
23+
if (empty($paths)) {
24+
throw new \RuntimeException(
25+
'No paths were provided to the version finder.'
26+
);
27+
}
2328
$this->paths = $paths;
2429
}
2530

tests/Unit/VersionFinderTest.php

+12
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,16 @@ public function testGetCollection()
3535
$versions = $collection->getAllVersions();
3636
$this->assertCount(3, $versions);
3737
}
38+
39+
/**
40+
* It should do nothing if no migrations paths are given.
41+
*
42+
* @expectedException \RuntimeException
43+
* @expectedExceptionMessage No paths were provided
44+
*/
45+
public function testNoMigrationPaths()
46+
{
47+
$collection = (new VersionFinder(array()))->getCollection();
48+
$versions = $collection->getAllVersions();
49+
}
3850
}

0 commit comments

Comments
 (0)