From 62d64c3b8bb2f475c185178e6ee0d6eda95af1f6 Mon Sep 17 00:00:00 2001 From: dantleech Date: Mon, 5 Dec 2016 17:51:31 +0000 Subject: [PATCH] Throw appropriate exception if no paths provided to finder --- lib/VersionFinder.php | 5 +++++ tests/Unit/VersionFinderTest.php | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/VersionFinder.php b/lib/VersionFinder.php index f36885a..7a364d0 100644 --- a/lib/VersionFinder.php +++ b/lib/VersionFinder.php @@ -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; } diff --git a/tests/Unit/VersionFinderTest.php b/tests/Unit/VersionFinderTest.php index f1a0098..275ff54 100644 --- a/tests/Unit/VersionFinderTest.php +++ b/tests/Unit/VersionFinderTest.php @@ -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(); + } }