#121 Add tests to make sure it doesn't break again
This commit is contained in:
parent
a17b3d7e5e
commit
61eaad45e2
@ -488,6 +488,11 @@ class DauxHelper
|
||||
* @return false|null|string
|
||||
*/
|
||||
public static function findLocation($path, $basedir, $var, $type) {
|
||||
// VFS, used only in tests
|
||||
if (substr($path, 0, 6) == "vfs://") {
|
||||
return $path;
|
||||
}
|
||||
|
||||
// When running through `daux --serve` we set an environment variable to know where we started from
|
||||
$env = getenv($var);
|
||||
if ($env && DauxHelper::is($env, $type)) {
|
||||
|
39
tests/Server/ServerTest.php
Normal file
39
tests/Server/ServerTest.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php namespace Todaymade\Daux\Server;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Output\NullOutput;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Todaymade\Daux\Format\HTML\RawPage;
|
||||
use Todaymade\Daux\Config;
|
||||
use Todaymade\Daux\Daux;
|
||||
use Todaymade\Daux\Server\Server;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
|
||||
class ServerTest extends TestCase
|
||||
{
|
||||
function testCreateResponse() {
|
||||
|
||||
$structure = [
|
||||
'index.md' => 'first page',
|
||||
'Page.md' => 'another page',
|
||||
'somefile.css' => 'body {}',
|
||||
'22.png' => ''
|
||||
];
|
||||
$root = vfsStream::setup('root', null, $structure);
|
||||
|
||||
$daux = new Daux(Daux::LIVE_MODE, new NullOutput());
|
||||
$daux->getParams()->setDocumentationDirectory($root->url());
|
||||
|
||||
$daux->initializeConfiguration();
|
||||
$daux->getParams()['index_key'] = 'index';
|
||||
$daux->generateTree();
|
||||
|
||||
$page = new RawPage($daux->tree['somefile.css']->getPath());
|
||||
|
||||
$server = new Server($daux);
|
||||
$response = $server->createResponse($page)->prepare(Request::createFromGlobals());
|
||||
|
||||
$this->assertEquals("text/css", $response->headers->get('Content-Type'));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user