Abstracts
This commit is contained in:
15
app/tests/integration/AbstractIntegration.php
Normal file
15
app/tests/integration/AbstractIntegration.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace ProVM\Integration;
|
||||
|
||||
use Psr\Http\Client\ClientInterface;
|
||||
use GuzzleHttp\Client;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class AbstractIntegration extends TestCase
|
||||
{
|
||||
protected ClientInterface $client;
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->client = new Client(['base_uri' => $_ENV['APP_URL']]);
|
||||
}
|
||||
}
|
@ -1,17 +1,10 @@
|
||||
<?php
|
||||
namespace ProVM\Integration;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use GuzzleHttp\Client;
|
||||
require __DIR__ . '/AbstractIntegration.php';
|
||||
|
||||
class HomeTest extends TestCase
|
||||
class HomeTest extends AbstractIntegration
|
||||
{
|
||||
protected Client $client;
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->client = new Client(['base_uri' => $_ENV['APP_URL']]);
|
||||
}
|
||||
|
||||
public function testLoad(): void
|
||||
{
|
||||
$response = $this->client->get('/');
|
||||
|
17
app/tests/performance/AbstractPerformance.php
Normal file
17
app/tests/performance/AbstractPerformance.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace ProVM\Performance;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
abstract class AbstractPerformance extends TestCase
|
||||
{
|
||||
protected float $startTime;
|
||||
protected function start(): void
|
||||
{
|
||||
$this->startTime = microtime(true);
|
||||
}
|
||||
protected function end(): float
|
||||
{
|
||||
return microtime(true) - $this->startTime;
|
||||
}
|
||||
}
|
@ -1,10 +1,11 @@
|
||||
<?php
|
||||
namespace ProVM\Performance;
|
||||
|
||||
use PHPUnit\Framework;
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
class HomeTest extends Framework\TestCase
|
||||
require __DIR__ . '/AbstractPerformance.php';
|
||||
|
||||
class HomeTest extends AbstractPerformance
|
||||
{
|
||||
protected Client $client;
|
||||
protected function setUp(): void
|
||||
@ -14,9 +15,9 @@ class HomeTest extends Framework\TestCase
|
||||
|
||||
public function testLoad(): void
|
||||
{
|
||||
$start = microtime(true);
|
||||
$this->start();
|
||||
$this->client->get('/');
|
||||
$end = microtime(true);
|
||||
$this->assertLessThanOrEqual(1000, $end - $start);
|
||||
$time = $this->end();
|
||||
$this->assertLessThanOrEqual(1000, $time);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user