Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
],
"require": {
"phpunit/phpunit": "^4.0|^5.0|^6.0"
"phpunit/phpunit": "^6.0"
},
"autoload": {
"classmap": [
Expand Down
3 changes: 1 addition & 2 deletions solano.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ tests:
php:
php_version:
SPLIT:
- '5.3'
- '5.5'
- '7.0'
- '7.1'

hooks:
pre_setup: composer install
Expand Down
93 changes: 51 additions & 42 deletions src/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
*
*/

use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\TestListener;
use PHPUnit\Framework\TestSuite;
use PHPUnit\Framework\Warning;
use PHPUnit\Util\Filter;
use PHPUnit\Util\Printer;

if (getenv('TDDIUM')):

/**
Expand All @@ -16,7 +25,7 @@
* @copyright Solano Labs https://www.solanolabs.com/
* @link https://www.solanolabs.com/
*/
class SolanoLabs_PHPUnit_Listener extends PHPUnit_Util_Printer implements PHPUnit_Framework_TestListener
class SolanoLabs_PHPUnit_Listener extends Printer implements TestListener
{
/**
* @var string
Expand Down Expand Up @@ -65,17 +74,17 @@ public function __construct($outputFile = '', $excludeFiles = '')
/**
* A test started.
*
* @param PHPUnit_Framework_Test $test
* @param Test $test
*/
public function startTest(PHPUnit_Framework_Test $test)
public function startTest(Test $test)
{
if (getenv('TDDIUM')) {
global $tddium_output_buffer;
$tddium_output_buffer = "";
}
if (!$test instanceof PHPUnit_Framework_Warning) {
if (!$test instanceof Warning) {
$testcase = array('id' => '', 'address' => '', 'status' => '', 'stderr' => '', 'stdout' => '', 'file' => '');
if ($test instanceof PHPUnit_Framework_TestCase) {
if ($test instanceof TestCase) {
$class = new ReflectionClass($test);
$className = $class->getName();
$testName = $test->getName();
Expand All @@ -98,10 +107,10 @@ public function startTest(PHPUnit_Framework_Test $test)
/**
* A test ended.
*
* @param PHPUnit_Framework_Test $test
* @param float $time
* @param Test $test
* @param float $time
*/
public function endTest(PHPUnit_Framework_Test $test, $time)
public function endTest(Test $test, $time)
{
$testcase = $this->currentTestcase;
if (!$testcase['status']) {
Expand All @@ -122,71 +131,71 @@ public function endTest(PHPUnit_Framework_Test $test, $time)
/**
* An error occurred.
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
* @param Test $test
* @param Exception $e
* @param float $time
*/
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
public function addError(Test $test, Exception $e, $time)
{
$this->addNonPassTest('error', $test, $e, $time);
}

/**
* A failure occurred.
*
* @param PHPUnit_Framework_Test $test
* @param PHPUnit_Framework_AssertionFailedError $e
* @param float $time
* @param Test $test
* @param AssertionFailedError $e
* @param float $time
*/
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
public function addFailure(Test $test, AssertionFailedError $e, $time)
{
$this->addNonPassTest('fail', $test, $e, $time);
}

/**
* A warning occurred.
*
* @param PHPUnit_Framework_Test $test
* @param PHPUnit_Framework_Warning $e
* @param float $time
* @param Test $test
* @param Warning $e
* @param float $time
*/
public function addWarning(PHPUnit_Framework_Test $test, PHPUnit_Framework_Warning $e, $time)
public function addWarning(Test $test, Warning $e, $time)
{
$this->addNonPassTest('error', $test, $e, $time);
}

/**
* Incomplete test.
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
* @param Test $test
* @param Exception $e
* @param float $time
*/
public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time)
public function addIncompleteTest(Test $test, Exception $e, $time)
{
$this->addNonPassTest('skip', $test, $e, $time, 'Incomplete Test: ');
}

/**
* Risky test.
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
* @param Test $test
* @param Exception $e
* @param float $time
*/
public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time)
public function addRiskyTest(Test $test, Exception $e, $time)
{
$this->addNonPassTest('error', $test, $e, $time, 'Risky Test: ');
}

/**
* Skipped test.
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
* @param Test $test
* @param Exception $e
* @param float $time
*/
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
public function addSkippedTest(Test $test, Exception $e, $time)
{
if (count($this->currentTestcase)) {
$this->addNonPassTest('skip', $test, $e, $time, 'Skipped Test: ');
Expand All @@ -201,20 +210,20 @@ public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time
/**
* Add a non-passing test to the output
*
* @param string $status
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param string $stderrPrefix
* @param string $status
* @param Test $test
* @param Exception $e
* @param string $stderrPrefix
*/
private function addNonPassTest($status, PHPUnit_Framework_Test $test, Exception $e, $time, $stderrPrefix = '')
private function addNonPassTest($status, Test $test, Exception $e, $time, $stderrPrefix = '')
{
$this->currentTestcase['status'] = $status;
$this->currentTestcase['time'] = $time;
if (method_exists($test, 'hasOutput') && $test->hasOutput()) {
$this->currentTestcase['stdout'] = $test->getActualOutput();
}
$this->currentTestcase['stderr'] = $stderrPrefix . $e->getMessage();
$traceback = PHPUnit_Util_Filter::getFilteredStacktrace($e, false);
$traceback = Filter::getFilteredStacktrace($e, false);
// Strip path from traceback?
for($i = 0; $i < count($traceback); $i++) {
if (0 === strpos($traceback[$i]['file'], $this->stripPath)) {
Expand All @@ -227,19 +236,19 @@ private function addNonPassTest($status, PHPUnit_Framework_Test $test, Exception
/**
* A testsuite started.
*
* @param PHPUnit_Framework_TestSuite $suite
* @param TestSuite $suite
*/
public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
public function startTestSuite(TestSuite $suite)
{
$this->currentTestSuiteName = $suite->getName();
}

/**
* A testsuite ended.
*
* @param PHPUnit_Framework_TestSuite $suite
* @param TestSuite $suite
*/
public function endTestSuite(PHPUnit_Framework_TestSuite $suite)
public function endTestSuite(TestSuite $suite)
{
$this->currentTestSuiteName = '';
$this->currentTestSuiteAddress = '';
Expand Down
Loading