Skip to content

Commit

Permalink
Added new FUTException for PHPUnit 3.6. Tests all restored to passing…
Browse files Browse the repository at this point in the history
… state.
  • Loading branch information
Pádraic Brady committed Jan 29, 2012
1 parent a4bcbb0 commit 42c03ea
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion library/Mutagenesis/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function getMutables()
public function setSourceDirectory($sourceDirectory)
{
if (!is_dir($sourceDirectory) || !is_readable($sourceDirectory)) {
throw new \Exception('Invalid source directory: "'.$sourceDirectory.'"');
throw new \Mutagenesis\FUTException('Invalid source directory: "'.$sourceDirectory.'"');
}
$this->_sourceDirectory = $sourceDirectory;
}
Expand Down
16 changes: 8 additions & 8 deletions library/Mutagenesis/Runner/RunnerAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function setBaseDirectory($dir)
{
$dir = rtrim($dir, ' \\/');
if (!is_dir($dir) || !is_readable($dir)) {
throw new \Exception('Invalid base directory: "'.$dir.'"');
throw new \Mutagenesis\FUTException('Invalid base directory: "'.$dir.'"');
}
$this->_baseDirectory = $dir;
return $this;
Expand All @@ -195,7 +195,7 @@ public function setSourceDirectory($dir)
{
$dir = rtrim($dir, ' \\/');
if (!is_dir($dir) || !is_readable($dir)) {
throw new \Exception('Invalid source directory: "'.$dir.'"');
throw new \Mutagenesis\FUTException('Invalid source directory: "'.$dir.'"');
}
$this->_sourceDirectory = $dir;
return $this;
Expand All @@ -220,7 +220,7 @@ public function setTestDirectory($dir)
{
$dir = rtrim($dir, ' \\/');
if (!is_dir($dir) || !is_readable($dir)) {
throw new \Exception('Invalid test directory: "'.$dir.'"');
throw new \Mutagenesis\FUTException('Invalid test directory: "'.$dir.'"');
}
$this->_testDirectory = $dir;
return $this;
Expand All @@ -245,7 +245,7 @@ public function setCacheDirectory($dir)
{
$dir = rtrim($dir, ' \\/');
if (!is_dir($dir) || !is_readable($dir)) {
throw new \Exception('Invalid cache directory: "'.$dir.'"');
throw new \Mutagenesis\FUTException('Invalid cache directory: "'.$dir.'"');
}
$this->_cacheDirectory = $dir;
return $this;
Expand Down Expand Up @@ -356,7 +356,7 @@ public function getAdapter()
$file = '/Adapter/' . $name . '.php';
$class = 'Mutagenesis\\Adapter\\' . $name;
if (!file_exists(dirname(dirname(__FILE__)) . $file)) {
throw new \Exception('Invalid Adapter name: ' . strtolower($name));
throw new \Mutagenesis\FUTException('Invalid Adapter name: ' . strtolower($name));
}
$this->_adapter = new $class;
}
Expand Down Expand Up @@ -407,7 +407,7 @@ public function getRenderer()
$name = ucfirst(strtolower($this->getRendererName()));
$class = 'Mutagenesis\\Renderer\\' . $name;
if (!class_exists($class)) {
throw new \Exception('Invalid Renderer name: ' . strtolower($name));
throw new \Mutagenesis\FUTException('Invalid Renderer name: ' . strtolower($name));
}
$this->_renderer = new $class;
}
Expand Down Expand Up @@ -446,7 +446,7 @@ public function getRunkit()
{
if (is_null($this->_runkit)) {
if(!in_array('runkit', get_loaded_extensions())) {
throw new \Exception(
throw new \Mutagenesis\FUTException(
'Runkit extension is not loaded. Unfortunately, runkit'
. ' is essential for Mutagenesis. Please see the manual or'
. ' README which explains how to install an updated runkit'
Expand Down Expand Up @@ -577,7 +577,7 @@ public function setBootstrap($file)
return $this;
}
if (!file_exists($file) || !is_readable($file)) {
throw new \Exception('Invalid bootstrap file: "'.$file.'"');
throw new \Mutagenesis\FUTException('Invalid bootstrap file: "'.$file.'"');
}
$this->_bootstrap = $file;
return $this;
Expand Down
2 changes: 1 addition & 1 deletion library/Mutagenesis/Utility/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static function run($source, $timeout = 120)
'stderr' => $stderr
);
} else {
throw new \Exception('Unable to open a new process');
throw new \Mutagenesis\FUTException('Unable to open a new process');
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Mutagenesis/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function testShouldStoreSourceDirectoryValue()
}

/**
* @expectedException Exception
* @expectedException \Mutagenesis\FUTException
*/
public function testShouldThrowExceptionOnNonexistingDirectory()
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Mutagenesis/Runner/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testShouldStoreSourceDirectoryValue()
}

/**
* @expectedException Exception
* @expectedException \Mutagenesis\FUTException
*/
public function testShouldThrowExceptionOnNonexistingDirectoryWhenSettingSourceDirectory()
{
Expand All @@ -60,7 +60,7 @@ public function testShouldStoreTestDirectoryValue()
}

/**
* @expectedException Exception
* @expectedException \Mutagenesis\FUTException
*/
public function testShouldThrowExceptionOnNonexistingDirectoryWhenSettingTestDirectory()
{
Expand Down Expand Up @@ -166,7 +166,7 @@ public function testShouldCreateDefaultTextRendererIfOtherInstanceOrNameNotAlrea
}

/**
* @expectedException Exception
* @expectedException \Mutagenesis\FUTException
*/
public function testShouldThrowExceptionIfAdapterNameGivenIsNotSupported()
{
Expand Down
5 changes: 3 additions & 2 deletions tests/Mutagenesis/Utility/ProcTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,21 @@ public function testExecutesGivenScriptInSeparateProcess()
$return = $process->run(
"<?php echo 'It\'s alive!';"
);
$this->assertEquals('It\'s alive!', $return);
$this->assertEquals('It\'s alive!', $return['stdout']);
}

/**
* @group separateprocess
*/
public function testSeparateProcessTimesOut()
{
$this->markTestIncomplete();
$process = new \Mutagenesis\Utility\Process;
$return = $process->run(
"<?php sleep(5);",
1
);
$this->assertEquals('It\'s alive!', $return);
$this->assertEquals('It\'s alive!', $return['stdout']);
}

}

0 comments on commit 42c03ea

Please sign in to comment.