Skip to content

Commit

Permalink
testFindVendorFolderWillReturnNullIfTheVendorFolderCouldNotBeFound
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotchance committed Sep 3, 2014
1 parent 420865f commit 350f1c8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Concise/Version.php
Expand Up @@ -4,16 +4,20 @@

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)) {
return "$path/vendor";
}
$path .= "/..";
}

return null;
}

public function getVersionForPackage($packageName)
Expand Down
8 changes: 8 additions & 0 deletions tests/Concise/VersionTest.php
Expand Up @@ -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);
}
}

0 comments on commit 350f1c8

Please sign in to comment.