From f3a5fa2cdcbffe1951e3b248bbbd470b6c7f1be3 Mon Sep 17 00:00:00 2001 From: Juan Pablo Vial Date: Wed, 20 Mar 2024 23:06:38 -0300 Subject: [PATCH] Tests --- app/phpunit.xml | 5 ++++- app/tests/acceptance/HomeTest.php | 22 ---------------------- app/tests/acceptance/LoginTest.php | 30 ------------------------------ app/tests/performance/APITest.php | 17 +++++++++++++++++ app/tests/performance/HomeTest.php | 17 +++++++++++++++++ 5 files changed, 38 insertions(+), 53 deletions(-) delete mode 100644 app/tests/acceptance/HomeTest.php delete mode 100644 app/tests/acceptance/LoginTest.php create mode 100644 app/tests/performance/APITest.php create mode 100644 app/tests/performance/HomeTest.php diff --git a/app/phpunit.xml b/app/phpunit.xml index b49ef82..f5f346b 100644 --- a/app/phpunit.xml +++ b/app/phpunit.xml @@ -15,7 +15,10 @@ tests/units - tests/acceptance + tests/integration + + + tests/performance diff --git a/app/tests/acceptance/HomeTest.php b/app/tests/acceptance/HomeTest.php deleted file mode 100644 index d2ac559..0000000 --- a/app/tests/acceptance/HomeTest.php +++ /dev/null @@ -1,22 +0,0 @@ - 'http://proxy']); - $home = $client->get(''); - $home = $home->getBody()->getContents(); - - $expected = [ - '', - 'Incoviba', - 'logo', - 'Bienvenid@ a Incoviba' - ]; - foreach ($expected as $segment) { - $this->assertStringContainsString($segment, $home); - } - } -} diff --git a/app/tests/acceptance/LoginTest.php b/app/tests/acceptance/LoginTest.php deleted file mode 100644 index aff26df..0000000 --- a/app/tests/acceptance/LoginTest.php +++ /dev/null @@ -1,30 +0,0 @@ -getClient(); - $response = $client->get('/login'); - $login = $response->getBody()->getContents(); - $expected = [ - '', - '', - '' - ]; - foreach ($expected as $segment) { - $this->assertStringContainsString($segment, $login); - } - } - public function testDoLogin(): void - { - $client = $this->getClient(); - $response = $client->get('/login'); - } - - protected function getClient(): GuzzleHttp\Client - { - return new GuzzleHttp\Client(['base_uri' => 'http://proxy']); - } -} diff --git a/app/tests/performance/APITest.php b/app/tests/performance/APITest.php new file mode 100644 index 0000000..eff09ca --- /dev/null +++ b/app/tests/performance/APITest.php @@ -0,0 +1,17 @@ + 'http://proxy']); + $start = microtime(true); + $response = $client->get('/api', ['headers' => ['Authorization' => 'Bearer ' . md5($_ENV['API_KEY'])]]); + $end = microtime(true); + $this->assertLessThanOrEqual(1000, $end - $start); + } +} diff --git a/app/tests/performance/HomeTest.php b/app/tests/performance/HomeTest.php new file mode 100644 index 0000000..9f978b8 --- /dev/null +++ b/app/tests/performance/HomeTest.php @@ -0,0 +1,17 @@ + 'http://proxy']); + $start = microtime(true); + $response = $client->get(''); + $end = microtime(true); + $this->assertLessThanOrEqual(1000, $end - $start); + } +}