Se mueve todo a extension de pruebas
This commit is contained in:
15
app/tests/extension/AbstractIntegration.php
Normal file
15
app/tests/extension/AbstractIntegration.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
namespace ProVM\Tests\Extension;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Http\Client\ClientInterface;
|
||||
|
||||
abstract class AbstractIntegration extends TestCase
|
||||
{
|
||||
protected ClientInterface $client;
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->client = new Client(['base_uri' => $_ENV['APP_URL']]);
|
||||
}
|
||||
}
|
10
app/tests/extension/AbstractModel.php
Normal file
10
app/tests/extension/AbstractModel.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace ProVM\Tests\Extension;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Incoviba\Common\Define\Model;
|
||||
|
||||
abstract class AbstractModel extends TestCase
|
||||
{
|
||||
protected Model $model;
|
||||
}
|
17
app/tests/extension/AbstractPerformance.php
Normal file
17
app/tests/extension/AbstractPerformance.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace ProVM\Tests\Extension;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
10
app/tests/extension/ObjectHasMethodTrait.php
Normal file
10
app/tests/extension/ObjectHasMethodTrait.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
namespace ProVM\Tests\Extension;
|
||||
|
||||
trait ObjectHasMethodTrait
|
||||
{
|
||||
public function assertObjectHasMethod(string $method, object $object): void
|
||||
{
|
||||
$this->assertTrue(method_exists($object, $method), sprintf('The object %s does not have the method %s', get_class($object), $method));
|
||||
}
|
||||
}
|
18
app/tests/extension/testMethodsTrait.php
Normal file
18
app/tests/extension/testMethodsTrait.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
namespace ProVM\Tests\Extension;
|
||||
|
||||
trait testMethodsTrait
|
||||
{
|
||||
use ObjectHasMethodTrait;
|
||||
|
||||
public function testMethods(): void
|
||||
{
|
||||
$object = $this->model;
|
||||
|
||||
foreach ($this->methods as $method) {
|
||||
$this->assertObjectHasMethod($method, $object);
|
||||
}
|
||||
}
|
||||
|
||||
protected array $methods = [];
|
||||
}
|
24
app/tests/extension/testPropertiesTrait.php
Normal file
24
app/tests/extension/testPropertiesTrait.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace ProVM\Tests\Extension;
|
||||
|
||||
use Incoviba\Common\Define\Model;
|
||||
|
||||
trait testPropertiesTrait
|
||||
{
|
||||
use ObjectHasMethodTrait;
|
||||
|
||||
public function testProperties(): void
|
||||
{
|
||||
$model = $this->model;
|
||||
|
||||
$this->assertProperties($model);
|
||||
}
|
||||
|
||||
protected array $properties = [];
|
||||
protected function assertProperties(Model $model): void
|
||||
{
|
||||
foreach ($this->properties as $key) {
|
||||
$this->assertObjectHasProperty($key, $model);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user