From 3d58a5bee4efc3453f68d1a613975dfaf6100d81 Mon Sep 17 00:00:00 2001 From: Austin Collier Date: Wed, 27 Dec 2023 16:56:02 -0700 Subject: [PATCH] added phpunit config for testing coverage --- .gitignore | 3 +++ phpunit.xml | 22 ++++++++++++++++++++++ tests/FlightTest.php | 7 +++++++ tests/RequestTest.php | 7 +++++++ tests/RouterTest.php | 7 +++++++ 5 files changed, 46 insertions(+) create mode 100644 phpunit.xml diff --git a/.gitignore b/.gitignore index a5ec20f..2161d40 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ vendor/ composer.phar composer.lock +.phpunit.result.cache +coverage/ +.vscode/settings.json diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..76d1463 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,22 @@ + + + + + flight/ + + + + + tests/ + + + + diff --git a/tests/FlightTest.php b/tests/FlightTest.php index 19dfdd3..d002eb6 100644 --- a/tests/FlightTest.php +++ b/tests/FlightTest.php @@ -18,9 +18,16 @@ class FlightTest extends PHPUnit\Framework\TestCase { protected function setUp(): void { + $_SERVER = []; + $_REQUEST = []; Flight::init(); } + protected function tearDown(): void { + unset($_REQUEST); + unset($_SERVER); + } + // Checks that default components are loaded public function testDefaultComponents() { diff --git a/tests/RequestTest.php b/tests/RequestTest.php index 842c1bc..05c8c49 100644 --- a/tests/RequestTest.php +++ b/tests/RequestTest.php @@ -17,6 +17,8 @@ class RequestTest extends PHPUnit\Framework\TestCase protected function setUp(): void { + $_SERVER = []; + $_REQUEST = []; $_SERVER['REQUEST_URI'] = '/'; $_SERVER['SCRIPT_NAME'] = '/index.php'; $_SERVER['REQUEST_METHOD'] = 'GET'; @@ -34,6 +36,11 @@ class RequestTest extends PHPUnit\Framework\TestCase $this->request = new Request(); } + protected function tearDown(): void { + unset($_REQUEST); + unset($_SERVER); + } + public function testDefaults() { self::assertEquals('/', $this->request->url); diff --git a/tests/RouterTest.php b/tests/RouterTest.php index 686d91f..5b4069f 100644 --- a/tests/RouterTest.php +++ b/tests/RouterTest.php @@ -23,11 +23,18 @@ class RouterTest extends PHPUnit\Framework\TestCase protected function setUp(): void { + $_SERVER = []; + $_REQUEST = []; $this->router = new Router(); $this->request = new Request(); $this->dispatcher = new Dispatcher(); } + protected function tearDown(): void { + unset($_REQUEST); + unset($_SERVER); + } + // Simple output public function ok() {