-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TestHandler: list TestCase methods by running with TestCase::LIST_MET…
…HODS argument [Closes #61]
- Loading branch information
Showing
7 changed files
with
146 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
use Tester\Assert, | ||
Tester\Runner\Runner; | ||
|
||
require __DIR__ . '/bootstrap.php'; | ||
require __DIR__ . '/../Tester/Runner/OutputHandler.php'; | ||
require __DIR__ . '/../Tester/Runner/TestHandler.php'; | ||
require __DIR__ . '/../Tester/Runner/PhpExecutable.php'; | ||
require __DIR__ . '/../Tester/Runner/Runner.php'; | ||
|
||
if (PHP_VERSION_ID < 50400) { | ||
Tester\Environment::skip('Requires constant PHP_BINARY available since PHP 5.4.0'); | ||
} | ||
|
||
|
||
class Logger implements Tester\Runner\OutputHandler | ||
{ | ||
public $results = array(); | ||
|
||
function result($testName, $result, $message) | ||
{ | ||
$this->results[basename($testName)] = array($result, $message); | ||
} | ||
|
||
function begin() {} | ||
function end() {} | ||
} | ||
|
||
$runner = new Runner(new Tester\Runner\PhpExecutable(PHP_BINARY)); | ||
$runner->paths[] = __DIR__ . '/multiple-fails/*.phptx'; | ||
$runner->outputHandlers[] = $logger = new Logger; | ||
$runner->run(); | ||
|
||
Assert::match( | ||
"TestCase in file '%a%testcase-no-methods.phptx' does not contain test methods.", | ||
$logger->results['testcase-no-methods.phptx'][1] | ||
); | ||
Assert::same( Runner::SKIPPED, $logger->results['testcase-no-methods.phptx'][0] ); | ||
|
||
Assert::match( | ||
"Cannot list TestCase methods in file '%a%testcase-not-call-run.phptx'. Do you call TestCase::run() in it?", | ||
$logger->results['testcase-not-call-run.phptx'][1] | ||
); | ||
Assert::same( Runner::FAILED, $logger->results['testcase-not-call-run.phptx'][0] ); | ||
|
||
Assert::same( 2, count($logger->results) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
/** | ||
* @testcase | ||
*/ | ||
|
||
use Tester\TestCase; | ||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
class MyTest extends TestCase | ||
{ | ||
} | ||
|
||
$testCase = new MyTest; | ||
$testCase->run(isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : NULL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
/** | ||
* @testcase | ||
*/ | ||
|
||
use Tester\TestCase; | ||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
class MyTest extends TestCase | ||
{ | ||
|
||
public function testFoo() | ||
{ | ||
exit(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters