1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-10-13 11:47:56 +03:00

Updated to laravel 6

This commit is contained in:
Dan Brown
2019-09-14 14:12:39 +01:00
parent 140298bd96
commit cbf9d701af
17 changed files with 573 additions and 328 deletions

View File

@@ -12,22 +12,19 @@ class ConfigTest extends TestCase
public function test_filesystem_images_falls_back_to_storage_type_var()
{
putenv('STORAGE_TYPE=local_secure');
$this->checkEnvConfigResult('STORAGE_IMAGE_TYPE', 's3', 'filesystems.images', 's3');
$this->checkEnvConfigResult('STORAGE_IMAGE_TYPE', null, 'filesystems.images', 'local_secure');
putenv('STORAGE_TYPE=local');
$this->runWithEnv('STORAGE_TYPE', 'local_secure', function() {
$this->checkEnvConfigResult('STORAGE_IMAGE_TYPE', 's3', 'filesystems.images', 's3');
$this->checkEnvConfigResult('STORAGE_IMAGE_TYPE', null, 'filesystems.images', 'local_secure');
});
}
public function test_filesystem_attachments_falls_back_to_storage_type_var()
{
putenv('STORAGE_TYPE=local_secure');
$this->checkEnvConfigResult('STORAGE_ATTACHMENT_TYPE', 's3', 'filesystems.attachments', 's3');
$this->checkEnvConfigResult('STORAGE_ATTACHMENT_TYPE', null, 'filesystems.attachments', 'local_secure');
putenv('STORAGE_TYPE=local');
$this->runWithEnv('STORAGE_TYPE', 'local_secure', function() {
$this->checkEnvConfigResult('STORAGE_ATTACHMENT_TYPE', 's3', 'filesystems.attachments', 's3');
$this->checkEnvConfigResult('STORAGE_ATTACHMENT_TYPE', null, 'filesystems.attachments', 'local_secure');
});
}
public function test_app_url_blank_if_old_default_value()
@@ -49,15 +46,9 @@ class ConfigTest extends TestCase
*/
protected function checkEnvConfigResult(string $envName, $envVal, string $configKey, string $expectedResult)
{
$originalVal = getenv($envName);
$envString = $envName . (is_null($envVal) ? '' : '=') . ($envVal ?? '');
putenv($envString);
$this->refreshApplication();
$this->assertEquals($expectedResult, config($configKey));
$envString = $envName . (empty($originalVal) ? '' : '=') . ($originalVal ?? '');
putenv($envString);
$this->runWithEnv($envName, $envVal, function() use ($configKey, $expectedResult) {
$this->assertEquals($expectedResult, config($configKey));
});
}
}

View File

@@ -22,19 +22,19 @@ class PageRepoTest extends TestCase
$navMap = $this->pageRepo->getPageNav($content);
$this->assertCount(3, $navMap);
$this->assertArraySubset([
$this->assertArrayMapIncludes([
'nodeName' => 'h1',
'link' => '#testa',
'text' => 'Hello',
'level' => 1,
], $navMap[0]);
$this->assertArraySubset([
$this->assertArrayMapIncludes([
'nodeName' => 'h2',
'link' => '#testb',
'text' => 'There',
'level' => 2,
], $navMap[1]);
$this->assertArraySubset([
$this->assertArrayMapIncludes([
'nodeName' => 'h3',
'link' => '#testc',
'text' => 'Donkey',
@@ -48,7 +48,7 @@ class PageRepoTest extends TestCase
$navMap = $this->pageRepo->getPageNav($content);
$this->assertCount(1, $navMap);
$this->assertArraySubset([
$this->assertArrayMapIncludes([
'nodeName' => 'h1',
'link' => '#testa',
'text' => 'Hello'
@@ -61,15 +61,15 @@ class PageRepoTest extends TestCase
$navMap = $this->pageRepo->getPageNav($content);
$this->assertCount(3, $navMap);
$this->assertArraySubset([
$this->assertArrayMapIncludes([
'nodeName' => 'h4',
'level' => 1,
], $navMap[0]);
$this->assertArraySubset([
$this->assertArrayMapIncludes([
'nodeName' => 'h5',
'level' => 2,
], $navMap[1]);
$this->assertArraySubset([
$this->assertArrayMapIncludes([
'nodeName' => 'h6',
'level' => 3,
], $navMap[2]);

View File

@@ -16,18 +16,16 @@ class UrlTest extends TestCase
public function test_url_helper_takes_custom_url_into_account()
{
putenv('APP_URL=http://example.com/bookstack');
$this->refreshApplication();
$this->assertEquals('http://example.com/bookstack/books', url('/books'));
putenv('APP_URL=');
$this->runWithEnv('APP_URL', 'http://example.com/bookstack', function() {
$this->assertEquals('http://example.com/bookstack/books', url('/books'));
});
}
public function test_url_helper_sets_correct_scheme_even_when_request_scheme_is_different()
{
putenv('APP_URL=https://example.com/');
$this->refreshApplication();
$this->get('http://example.com/login')->assertSee('https://example.com/dist/styles.css');
putenv('APP_URL=');
$this->runWithEnv('APP_URL', 'https://example.com/', function() {
$this->get('http://example.com/login')->assertSee('https://example.com/dist/styles.css');
});
}
}