diff --git a/src/Concise/Version.php b/src/Concise/Version.php index e25a2ee5..44c6fbe2 100644 --- a/src/Concise/Version.php +++ b/src/Concise/Version.php @@ -4,9 +4,11 @@ class Version { - public function findVendorFolder() + public function findVendorFolder($path = null) { - $path = __DIR__; + if (null === $path) { + $path = __DIR__; + } for ($i = 0; $i < 10; ++$i) { $dir = scandir($path); if (in_array('vendor', $dir)) { @@ -14,6 +16,8 @@ public function findVendorFolder() } $path .= "/.."; } + + return null; } public function getVersionForPackage($packageName) diff --git a/tests/Concise/VersionTest.php b/tests/Concise/VersionTest.php index 3fd6efae..cdb461d7 100644 --- a/tests/Concise/VersionTest.php +++ b/tests/Concise/VersionTest.php @@ -37,4 +37,12 @@ public function testReturnEmptyStringIfVendorFolderCannotBeFound() ->done(); $this->assert($version->getConciseVersion(), is_blank); } + + public function testFindVendorFolderWillReturnNullIfTheVendorFolderCouldNotBeFound() + { + $version = $this->niceMock('Concise\Version') + ->expose('findVendorFolder') + ->done(); + $this->assert($version->findVendorFolder('/tmp'), is_null); + } }