Compare commits

...

1 Commits

Author SHA1 Message Date
James
eb81b0e965 didnt work but useful example 2019-09-22 16:27:31 +01:00
2 changed files with 76 additions and 0 deletions

19
src/Extention.php Normal file
View File

@ -0,0 +1,19 @@
<?php declare(strict_types=1);
namespace JHodges\GiteaBitPHPUnit;
use PHPUnit\Runner\BeforeFirstTestHook;
use PHPUnit\Runner\AfterLastTestHook;
final class Extension implements BeforeFirstTestHook, AfterLastTestHook{
public function executeBeforeFirstTest(): void
{
// called before the first test is being run
echo "AAAAAA";
}
public function executeAfterLastTest(): void
{
echo "ZZZZZZZ";
// called after the last test has been run
}
}

57
src/Listener.php Normal file
View File

@ -0,0 +1,57 @@
<?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";
}
}
}