Files
oficial/app/tests/units/common/Alias/ViewTest.php
Juan Pablo Vial 6617a92f5f Tests
2024-03-20 13:49:58 -03:00

37 lines
1017 B
PHP

<?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());
}
}