mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-30 04:23:11 +03:00
19
tests/Unit/HelpersTest.php
Normal file
19
tests/Unit/HelpersTest.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
class HelpersTest extends TestCase
|
||||
{
|
||||
|
||||
public function test_base_url_takes_config_into_account()
|
||||
{
|
||||
config()->set('app.url', 'http://example.com/bookstack');
|
||||
$result = baseUrl('/');
|
||||
$this->assertEquals('http://example.com/bookstack/', $result);
|
||||
}
|
||||
|
||||
public function test_base_url_takes_extra_path_into_account_on_forced_domain()
|
||||
{
|
||||
config()->set('app.url', 'http://example.com/bookstack');
|
||||
$result = baseUrl('http://example.com/bookstack/', true);
|
||||
$this->assertEquals('http://example.com/bookstack/', $result);
|
||||
}
|
||||
}
|
32
tests/Unit/PageRepoTest.php
Normal file
32
tests/Unit/PageRepoTest.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace Tests;
|
||||
|
||||
use BookStack\Entities\Repos\PageRepo;
|
||||
|
||||
class PageRepoTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var PageRepo $pageRepo
|
||||
*/
|
||||
protected $pageRepo;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->pageRepo = app()->make(PageRepo::class);
|
||||
}
|
||||
|
||||
public function test_get_page_nav_does_not_show_empty_titles()
|
||||
{
|
||||
$content = '<h1 id="testa">Hello</h1><h2 id="testb"> </h2><h3 id="testc"></h3>';
|
||||
$navMap = $this->pageRepo->getPageNav($content);
|
||||
|
||||
$this->assertCount(1, $navMap);
|
||||
$this->assertArraySubset([
|
||||
'nodeName' => 'h1',
|
||||
'link' => '#testa',
|
||||
'text' => 'Hello'
|
||||
], $navMap[0]);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user