58 lines
1.6 KiB
PHP
58 lines
1.6 KiB
PHP
<?php
|
|
namespace JHodges\GiteaBotPHPUnit;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use PHPUnit\Framework\TestListener;
|
|
use PHPUnit\Framework\Test as PHPUnit_Framework_Test;
|
|
use PHPUnit\Framework\Test;
|
|
use PHPUnit\Framework\AssertionFailedError as PHPUnit_Framework_AssertionFailedError;
|
|
use PHPUnit\Framework\TestSuite as PHPUnit_Framework_TestSuite;
|
|
use PHPUnit\Framework\Warning;
|
|
use Exception;
|
|
|
|
class Listener implements TestListener{
|
|
|
|
private $stack=[];
|
|
|
|
public function addWarning(Test $test, Warning $e, $time){
|
|
die("wrank");
|
|
print_r($test->getName());
|
|
}
|
|
|
|
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time){
|
|
die("err");
|
|
print_r($test->getName());
|
|
}
|
|
|
|
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time){
|
|
$name=get_class($test).'::'.$test->getName();
|
|
$message=$e->getMessage();
|
|
echo("##### $name\n$message\n");
|
|
}
|
|
|
|
public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time){}
|
|
|
|
public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time){}
|
|
|
|
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time){}
|
|
|
|
public function startTest(PHPUnit_Framework_Test $test){}
|
|
|
|
public function endTest(PHPUnit_Framework_Test $test, $time){
|
|
print_r( $test->getActualOutput());
|
|
}
|
|
|
|
public function startTestSuite(PHPUnit_Framework_TestSuite $suite){
|
|
$this->stack[$suite->getName()]='yes';
|
|
}
|
|
|
|
public function endTestSuite(PHPUnit_Framework_TestSuite $suite){
|
|
unset($this->stack[$suite->getName()]);
|
|
if(count($this->stack)==0){
|
|
echo "\n\nALLDONE\n\n";
|
|
}
|
|
}
|
|
|
|
}
|
|
|