Tests
This commit is contained in:
36
app/tests/units/common/Alias/ViewTest.php
Normal file
36
app/tests/units/common/Alias/ViewTest.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user