Skip to content

Commit

Permalink
Fix exception detection in Project unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
falvarez committed Aug 31, 2016
1 parent 3426b9b commit ff6e499
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/Infrastructure/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ public function getBinPath()
*
* @param string $path May be directory or file
* @param string[] $excludedPaths
* @return string[]
* @return \string[]
* @throws \Exception
*/
public function listFiles($path, $excludedPaths = [])
{
$realpath = realpath($path);

if (!$realpath) {
throw new \Exception('Path does not exist');
}

$finder = new Finder();
$finder
->files()
Expand Down
4 changes: 2 additions & 2 deletions tests/ProjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ private function setUpTempFiles()
public function testInvalidFile()
{
$this->setUpTempFiles();
$this->setExpectedException('InvalidArgumentException');
$this->setExpectedException('Exception', 'Path does not exist');
$files = $this->project->listFiles($this->tmpdir . '/invalidFile.php');
}

public function testInvalidPath()
{
$this->setUpTempFiles();
$this->setExpectedException('InvalidArgumentException');
$this->setExpectedException('Exception', 'Path does not exist');
$files = $this->project->listFiles($this->tmpdir . '/foo');
}

Expand Down

0 comments on commit ff6e499

Please sign in to comment.