Skip to content

Throw appropriate exception if no paths provided to finder #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/VersionFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ class VersionFinder

public function __construct(array $paths)
{
if (empty($paths)) {
throw new \RuntimeException(
'No paths were provided to the version finder.'
);
}
$this->paths = $paths;
}

Expand Down
12 changes: 12 additions & 0 deletions tests/Unit/VersionFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,16 @@ public function testGetCollection()
$versions = $collection->getAllVersions();
$this->assertCount(3, $versions);
}

/**
* It should do nothing if no migrations paths are given.
*
* @expectedException \RuntimeException
* @expectedExceptionMessage No paths were provided
*/
public function testNoMigrationPaths()
{
$collection = (new VersionFinder(array()))->getCollection();
$versions = $collection->getAllVersions();
}
}