[FEATURE] add phpunit code coverage

This commit is contained in:
Marco Stoll 2019-06-25 15:58:15 +02:00
parent 0901216702
commit 9abde34a32
9 changed files with 55 additions and 3 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
.idea/
/build
/logs
/vendor
composer.lock

2
bin/phpdox.bat Normal file
View File

@ -0,0 +1,2 @@
@ECHO OFF
vendor\bin\phpdox -f phpdox.xml

View File

@ -0,0 +1,3 @@
@ECHO OFF
SET PROJECT_HOME=C:\dev\ffe\fastforward\FF
php -dxdebug.coverage_enable=1 %PROJECT_HOME%\vendor\phpunit\phpunit\phpunit --coverage-xml %PROJECT_HOME%\logs\phpunit --configuration %PROJECT_HOME%\tests\testsuite.xml --teamcity

View File

@ -103,11 +103,10 @@
<!-- <coverage path="" /> -->
<!-- @path - the directory where the xml code coverage report can be found -->
<!--</source>-->
<!--
<source type="phpunit">
<filter directory="${phpDox.project.source}" />
<coverage path="../logs/phpunit" />
</source>
-->
</enrich>

View File

@ -27,7 +27,7 @@ class RenderedDocument
*/
public function __construct(string $contents)
{
$this->contents = $contents;
$this->setContents($contents);
}
/**

View File

@ -45,6 +45,20 @@ namespace FF\Tests\Factories {
ServicesFactory::getInstance();
}
/**
* Tests the namesake method/feature
*/
public function testClearInstance()
{
$this->expectException(ConfigurationException::class);
$instance = new ServicesFactory(self::TEST_OPTIONS);
$instance->getClassLocator()->prependNamespaces('FF\Tests');
ServicesFactory::setInstance($instance);
ServicesFactory::clearInstance();
ServicesFactory::getInstance();
}
/**
* Tests the namesake method/feature
*/

View File

@ -114,6 +114,17 @@ namespace FF\Tests\Services\Dispatching {
new Dispatcher();
}
/**
* Tests the namesake method/feature
*/
public function testSetGetFireEvents()
{
$value = false;
$same = $this->uut->setFireEvents($value);
$this->assertSame($this->uut, $same);
$this->assertSame($value, $this->uut->getFireEvents());
}
/**
* Tests the namesake method/feature
*/

View File

@ -86,9 +86,14 @@ class ExceptionHandlerTest extends TestCase
/**
* @param Exception $event
* @throws \Exception
*/
public static function listener(Exception $event)
{
if ($event->getException()->getMessage() == 'cascade') {
throw new \Exception('cascade failure');
}
self::$lastEvent = $event;
}
@ -141,6 +146,18 @@ class ExceptionHandlerTest extends TestCase
$this->assertSame($e, self::$lastEvent->getException());
}
/**
* Tests the namesake method/feature
*/
public function testTriggerExceptionCascade()
{
$e = new \Exception('cascade');
$this->uut->register()
->onException($e);
$this->assertNull(self::$lastEvent);
}
/**
* Tests the namesake method/feature
*/

View File

@ -5,4 +5,9 @@
<directory>./</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">../src/</directory>
</whitelist>
</filter>
</phpunit>