Cleanup tests
This commit is contained in:
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
namespace ProVM\Performance;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use PHPUnit\Framework;
|
||||
|
||||
class APITest extends Framework\TestCase
|
||||
{
|
||||
public function testLoad(): void
|
||||
{
|
||||
$client = new Client(['base_uri' => 'http://proxy']);
|
||||
$start = microtime(true);
|
||||
$response = $client->get('/api', ['headers' => ['Authorization' => 'Bearer ' . md5($_ENV['API_KEY'])]]);
|
||||
$end = microtime(true);
|
||||
$this->assertLessThanOrEqual(1000, $end - $start);
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
namespace ProVM\Test\Common\Alias;
|
||||
|
||||
use Incoviba\Common\Alias\View;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
class ViewTest extends TestCase
|
||||
{
|
||||
public function testRender(): void
|
||||
{
|
||||
$contents = <<<HTML
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf8" />
|
||||
<title>Test</title>
|
||||
</head>
|
||||
<body>
|
||||
Test
|
||||
</body>
|
||||
</html>
|
||||
HTML;
|
||||
mkdir('/tmp/views');
|
||||
mkdir('/tmp/cache', 777);
|
||||
file_put_contents('/tmp/views/test.blade.php', $contents);
|
||||
$view = new View('/tmp/views', '/tmp/cache');
|
||||
$body = $this->getMockBuilder(StreamInterface::class)->getMock();
|
||||
$body->method('getContents')->willReturn($contents);
|
||||
$response = $this->getMockBuilder(ResponseInterface::class)->getMock();
|
||||
$response->method('getBody')->willReturn($body);
|
||||
$output = $view->render($response, 'test');
|
||||
$this->assertEquals($contents, $output->getBody()->getContents());
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
namespace ProVM\Test\Common\Implement;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ConnectionTest extends TestCase
|
||||
{
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
<?php
|
||||
namespace ProVM\Test\Service;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Model;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
|
||||
class MenuTest extends TestCase
|
||||
{
|
||||
public function testBuild(): void
|
||||
{
|
||||
$tests = mt_rand(10, 100);
|
||||
for ($i = 0; $i < $tests; $i ++) {
|
||||
list($expected, $menu) = $this->generateBuildTest();
|
||||
$this->assertEquals($expected, $menu->build(1));
|
||||
}
|
||||
}
|
||||
protected function generateBuildTest(): array
|
||||
{
|
||||
$modelCount = mt_rand(3, 100);
|
||||
$expected = [];
|
||||
$models = [];
|
||||
for ($j = 0; $j < $modelCount; $j ++) {
|
||||
$model = $this->generateModel();
|
||||
$models []= $model;
|
||||
$expected []= "<a class=\"item\" href=\"http://localhost/url{$model->id}\">title{$model->id}</a>";
|
||||
}
|
||||
$expected = implode(PHP_EOL, $expected);
|
||||
$connection = $this->getMockBuilder(Define\Connection::class)->getMock();
|
||||
$repository = $this->getMockBuilder(Repository\Menu::class)->setConstructorArgs(compact('connection'))->getMock();
|
||||
$permissionsRepository = $this->getMockBuilder(Repository\Permission::class)->setConstructorArgs(compact('connection'))->getMock();
|
||||
$permissions = $this->getMockBuilder(Service\Permission::class)->setConstructorArgs([$permissionsRepository])->getMock();
|
||||
$repository->method('fetchByUser')->willReturn($models);
|
||||
$menu = new Service\Menu($repository, $permissions, (object) ['base' => 'http://localhost']);
|
||||
|
||||
return [$expected, $menu];
|
||||
}
|
||||
protected function generateModel(): Model\Menu
|
||||
{
|
||||
$id = mt_rand(1, 100000);
|
||||
$model = $this->getMockBuilder(Model\Menu::class)->getMock();
|
||||
$model->id = $id;
|
||||
$model->url = "url{$id}";
|
||||
$model->title = "title{$id}";
|
||||
|
||||
return $model;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user