Abstracts
This commit is contained in:
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