Merge pull request #1 from n0nag0n/patch-1

added phpunit config for testing coverage
pull/498/head
n0nag0n 1 year ago committed by GitHub
commit e7757678fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

3
.gitignore vendored

@ -2,3 +2,6 @@
vendor/ vendor/
composer.phar composer.phar
composer.lock composer.lock
.phpunit.result.cache
coverage/
.vscode/settings.json

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
executionOrder="random"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
convertDeprecationsToExceptions="true"
stopOnError="true"
stopOnFailure="true"
verbose="true"
colors="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">flight/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="default">
<directory>tests/</directory>
</testsuite>
</testsuites>
<logging/>
</phpunit>

@ -18,9 +18,16 @@ class FlightTest extends PHPUnit\Framework\TestCase
{ {
protected function setUp(): void protected function setUp(): void
{ {
$_SERVER = [];
$_REQUEST = [];
Flight::init(); Flight::init();
} }
protected function tearDown(): void {
unset($_REQUEST);
unset($_SERVER);
}
// Checks that default components are loaded // Checks that default components are loaded
public function testDefaultComponents() public function testDefaultComponents()
{ {

@ -17,6 +17,8 @@ class RequestTest extends PHPUnit\Framework\TestCase
protected function setUp(): void protected function setUp(): void
{ {
$_SERVER = [];
$_REQUEST = [];
$_SERVER['REQUEST_URI'] = '/'; $_SERVER['REQUEST_URI'] = '/';
$_SERVER['SCRIPT_NAME'] = '/index.php'; $_SERVER['SCRIPT_NAME'] = '/index.php';
$_SERVER['REQUEST_METHOD'] = 'GET'; $_SERVER['REQUEST_METHOD'] = 'GET';
@ -34,6 +36,11 @@ class RequestTest extends PHPUnit\Framework\TestCase
$this->request = new Request(); $this->request = new Request();
} }
protected function tearDown(): void {
unset($_REQUEST);
unset($_SERVER);
}
public function testDefaults() public function testDefaults()
{ {
self::assertEquals('/', $this->request->url); self::assertEquals('/', $this->request->url);

@ -23,11 +23,18 @@ class RouterTest extends PHPUnit\Framework\TestCase
protected function setUp(): void protected function setUp(): void
{ {
$_SERVER = [];
$_REQUEST = [];
$this->router = new Router(); $this->router = new Router();
$this->request = new Request(); $this->request = new Request();
$this->dispatcher = new Dispatcher(); $this->dispatcher = new Dispatcher();
} }
protected function tearDown(): void {
unset($_REQUEST);
unset($_SERVER);
}
// Simple output // Simple output
public function ok() public function ok()
{ {

Loading…
Cancel
Save