Keep numbers in raw files, as they aren't sorted anyway. Fixes #26

This commit is contained in:
Stéphane Goetz 2018-06-05 21:28:54 +02:00
parent 41c355edb1
commit eb89664473
2 changed files with 26 additions and 2 deletions

View File

@ -99,7 +99,7 @@ class Builder
$config = $parent->getConfig(); $config = $parent->getConfig();
if (!in_array($file->getExtension(), $config['valid_content_extensions'])) { if (!in_array($file->getExtension(), $config['valid_content_extensions'])) {
$uri = static::removeSortingInformations($file->getFilename()); $uri = $file->getFilename();
$entry = new Raw($parent, $uri, $file); $entry = new Raw($parent, $uri, $file);
$entry->setTitle(str_replace('_', ' ', static::removeSortingInformations($name))); $entry->setTitle(str_replace('_', ' ', static::removeSortingInformations($name)));

View File

@ -1,6 +1,7 @@
<?php <?php
namespace Todaymade\Daux\Tree; namespace Todaymade\Daux\Tree;
use org\bovigo\vfs\vfsStream;
use Todaymade\Daux\Config; use Todaymade\Daux\Config;
use Todaymade\Daux\Daux; use Todaymade\Daux\Daux;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
@ -47,7 +48,6 @@ class BuilderTest extends TestCase
$config->setDocumentationDirectory(''); $config->setDocumentationDirectory('');
$root = new Root($config); $root = new Root($config);
$dir = Builder::getOrCreateDir($root, 'directory'); $dir = Builder::getOrCreateDir($root, 'directory');
$this->assertSame($root, $dir->getParent()); $this->assertSame($root, $dir->getParent());
@ -147,4 +147,28 @@ class BuilderTest extends TestCase
$this->assertEquals('file.json', $entry->getUri()); $this->assertEquals('file.json', $entry->getUri());
$this->assertInstanceOf('Todaymade\Daux\Tree\ComputedRaw', $entry); $this->assertInstanceOf('Todaymade\Daux\Tree\ComputedRaw', $entry);
} }
public function testScanner()
{
$structure = [
'Page.md' => 'another page',
'Button.md' => 'another page',
'22.png' => ''
];
$root = vfsStream::setup('root', null, $structure);
$config = new Config;
$config->setDocumentationDirectory($root->url());
$config['valid_content_extensions'] = ['md'];
$config['mode'] = Daux::STATIC_MODE;
$config['index_key'] = 'index.html';
$tree = new Root($config);
Builder::build($tree, []);
$this->assertEquals(
['22.png', 'Button.html', 'Page.html'],
array_keys($tree->getEntries())
);
}
} }