2019-08-08 14:14:56 +02:00
|
|
|
<?php namespace Todaymade\Daux\Server;
|
|
|
|
|
2020-04-22 22:24:52 +02:00
|
|
|
use org\bovigo\vfs\vfsStream;
|
2019-08-08 14:14:56 +02:00
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use Symfony\Component\Console\Output\NullOutput;
|
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
2019-12-05 21:25:58 +01:00
|
|
|
use Todaymade\Daux\ConfigBuilder;
|
2019-08-08 14:14:56 +02:00
|
|
|
use Todaymade\Daux\Daux;
|
2020-04-22 22:24:52 +02:00
|
|
|
use Todaymade\Daux\Format\HTML\RawPage;
|
2019-08-08 14:14:56 +02:00
|
|
|
|
|
|
|
class ServerTest extends TestCase
|
|
|
|
{
|
2020-04-22 21:55:53 +02:00
|
|
|
public function testCreateResponse()
|
|
|
|
{
|
2019-08-08 14:14:56 +02:00
|
|
|
$structure = [
|
|
|
|
'index.md' => 'first page',
|
|
|
|
'Page.md' => 'another page',
|
|
|
|
'somefile.css' => 'body {}',
|
2020-04-22 22:24:52 +02:00
|
|
|
'22.png' => '',
|
2019-08-08 14:14:56 +02:00
|
|
|
];
|
|
|
|
$root = vfsStream::setup('root', null, $structure);
|
|
|
|
|
2019-12-05 21:25:58 +01:00
|
|
|
$config = ConfigBuilder::withMode(Daux::LIVE_MODE)
|
|
|
|
->withDocumentationDirectory($root->url())
|
|
|
|
->build();
|
|
|
|
|
|
|
|
$daux = new Daux($config, new NullOutput());
|
|
|
|
|
2019-08-08 14:14:56 +02:00
|
|
|
$daux->generateTree();
|
|
|
|
|
|
|
|
$page = new RawPage($daux->tree['somefile.css']->getPath());
|
|
|
|
|
|
|
|
$server = new Server($daux);
|
|
|
|
$response = $server->createResponse($page)->prepare(Request::createFromGlobals());
|
|
|
|
|
2020-04-22 22:24:52 +02:00
|
|
|
$this->assertEquals('text/css', $response->headers->get('Content-Type'));
|
2019-08-08 14:14:56 +02:00
|
|
|
}
|
|
|
|
}
|