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 Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.1-cli
FROM php:5.6-cli

# Work out of this directory
WORKDIR /usr/flaptastic
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
}
],
"require": {
"php": ">=7.1.0",
"php": ">=5.6.0",
"guzzlehttp/guzzle": ">=6.0.0"
},
"require-dev": {
"phpunit/phpunit": ">=7.0.0"
"phpunit/phpunit": ">=4.0.0 <5.0.0"
},
"autoload": {
"psr-4": {
Expand Down
34 changes: 20 additions & 14 deletions src/FlaptasticListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

namespace BlockJon\PHPUnit\Listener;

use PHPUnit\Framework\TestListener;


/**
* Integrates with flaptastic.com to expose flappy test information.
*/
class FlaptasticListener implements TestListener
class FlaptasticListener implements \PHPUnit_Framework_TestListener
{
public static $FLAPTASTIC_INTRODUCED = false;

Expand Down Expand Up @@ -37,6 +34,15 @@ function __construct() {
}

public function getTestFailureFileAndLine($e) {
if (is_subclass_of($e, '\PHPUnit_Framework_Exception')) {
$result = explode(":", trim(\PHPUnit_Util_Filter::getFilteredStacktrace($e)));
if (count($result) == 2) {
return (object) [
"file" => $result[0],
"line" => $result[1]
];
}
}
return (object) [
"file" => $e->getFile(),
"line" => $e->getLine()
Expand Down Expand Up @@ -160,47 +166,47 @@ private function missingEnvVarsDetected() {
return false;
}

public function addError(\PHPUnit\Framework\Test $test, \Throwable $e, float $time): void
public function addError(\PHPUnit_Framework_Test $test, Exception $e, $time)
{
$this->testType = 'error';
$this->testException = $e;
}

public function addWarning(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\Warning $e, float $time): void
public function addWarning(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_Warning $e, $time)
{
$this->testType = 'warning';
}

public function addFailure(\PHPUnit\Framework\Test $test, \PHPUnit\Framework\AssertionFailedError $e, float $time): void
public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time)
{
$this->testType = 'failure';
$this->testException = $e;
}

public function addIncompleteTest(\PHPUnit\Framework\Test $test, \Throwable $e, float $time): void
public function addIncompleteTest(\PHPUnit_Framework_Test $test, Exception $e, $time)
{
// We are not interested in incomplete tests and they are ultimately ignored.
$this->testType = 'incomplete';
}

public function addRiskyTest(\PHPUnit\Framework\Test $test, \Throwable $e, float $time): void
public function addRiskyTest(\PHPUnit_Framework_Test $test, Exception $e, $time)
{
// We dont care if php happens to deem a test is risky.
}

public function addSkippedTest(\PHPUnit\Framework\Test $test, \Throwable $e, float $time): void
public function addSkippedTest(\PHPUnit_Framework_Test $test, Exception $e, $time)
{
$this->testType = 'skipped';
}

public function startTest(\PHPUnit\Framework\Test $test): void
public function startTest(\PHPUnit_Framework_Test $test)
{
// Assume tests all pass.
$this->testType = 'passed';
$this->testException = null;
}

public function endTest(\PHPUnit\Framework\Test $test, float $time): void
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
if ($this->testType == 'passed') {
$this->addPassedTest($test);
Expand All @@ -209,7 +215,7 @@ public function endTest(\PHPUnit\Framework\Test $test, float $time): void
}
}

public function startTestSuite(\PHPUnit\Framework\TestSuite $suite): void
public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
{
$this->testSuite = $suite;
if (!static::$FLAPTASTIC_INTRODUCED) {
Expand All @@ -228,7 +234,7 @@ public function startTestSuite(\PHPUnit\Framework\TestSuite $suite): void
}
}

public function endTestSuite(\PHPUnit\Framework\TestSuite $suite): void
public function endTestSuite(\PHPUnit_Framework_TestSuite $suite)
{
if (count($this->buffer)) {
$this->occasionallyDeliver();
Expand Down