Skip to content

Commit

Permalink
Nette\Test: added skip reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
kravco authored and dg committed Sep 9, 2012
1 parent e512382 commit b1f2640
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions Tester/NetteTestCase.php
Expand Up @@ -72,7 +72,8 @@ public function run()
// pre-skip?
$options = $this->sections['options'];
if (isset($options['skip'])) {
throw new NetteTestCaseException('Skipped.', NetteTestCaseException::SKIPPED);
$message = $options['skip'] ? $options['skip'] : 'No message.';
throw new NetteTestCaseException($message, NetteTestCaseException::SKIPPED);

} elseif (isset($options['phpversion']) && version_compare($options['phpversion'], $this->phpVersion, '>')) {
throw new NetteTestCaseException("Requires PHP version $options[phpversion].", NetteTestCaseException::SKIPPED);
Expand All @@ -85,7 +86,7 @@ public function run()

// post-skip?
if (isset($headers['x-nette-test-skip'])) {
throw new NetteTestCaseException('Skipped.', NetteTestCaseException::SKIPPED);
throw new NetteTestCaseException($headers['x-nette-test-skip'], NetteTestCaseException::SKIPPED);
}

// compare output
Expand Down
4 changes: 2 additions & 2 deletions Tester/NetteTestHelpers.php
Expand Up @@ -273,9 +273,9 @@ public static function saveCoverage()
* Skips this test.
* @return void
*/
public static function skip()
public static function skip($message = 'No message.')
{
header('X-Nette-Test-Skip: 1');
header('X-Nette-Test-Skip: '. $message);
exit;
}

Expand Down
6 changes: 3 additions & 3 deletions Tester/RunTests.php
Expand Up @@ -107,7 +107,7 @@ public function run()
} catch (NetteTestCaseException $e) {
if ($e->getCode() === NetteTestCaseException::SKIPPED) {
echo 's';
$skipped[] = array($testCase->getName(), $entry);
$skipped[] = array($testCase->getName(), $entry, $e->getMessage());

} else {
echo 'F';
Expand All @@ -130,8 +130,8 @@ public function run()
if ($this->displaySkipped && $skippedCount) {
echo "\n\nSkipped:\n";
foreach ($skipped as $i => $item) {
list($name, $file) = $item;
echo "\n", ($i + 1), ") $name\n $file\n";
list($name, $file, $message) = $item;
echo "\n", ($i + 1), ") $name\n $message\n $file\n";
}
}

Expand Down

0 comments on commit b1f2640

Please sign in to comment.