mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-03-25 07:55:11 +08:00
Updated to laravel 6
This commit is contained in:
parent
140298bd96
commit
cbf9d701af
@ -1,8 +1,8 @@
|
||||
dist: bionic
|
||||
language: php
|
||||
php:
|
||||
- '7.1.3'
|
||||
- '7.2'
|
||||
- '7.3'
|
||||
|
||||
services:
|
||||
- mysql
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use Monolog\Handler\NullHandler;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
|
||||
/**
|
||||
@ -71,6 +72,11 @@ return [
|
||||
'driver' => 'errorlog',
|
||||
'level' => 'debug',
|
||||
],
|
||||
|
||||
'null' => [
|
||||
'driver' => 'monolog',
|
||||
'handler' => NullHandler::class,
|
||||
],
|
||||
],
|
||||
|
||||
];
|
@ -29,6 +29,7 @@ class Kernel extends HttpKernel
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
\BookStack\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\BookStack\Http\Middleware\Localization::class
|
||||
|
@ -5,39 +5,38 @@
|
||||
"license": "MIT",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"ext-json": "*",
|
||||
"ext-tidy": "*",
|
||||
"ext-dom": "*",
|
||||
"ext-xml": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-gd": "*",
|
||||
"php": "^7.2",
|
||||
"ext-curl": "*",
|
||||
"laravel/framework": "5.8.*",
|
||||
"fideloper/proxy": "^4.0",
|
||||
"intervention/image": "^2.5",
|
||||
"laravel/socialite": "^4.2",
|
||||
"league/flysystem-aws-s3-v3": "^1.0",
|
||||
"ext-dom": "*",
|
||||
"ext-gd": "*",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-tidy": "*",
|
||||
"ext-xml": "*",
|
||||
"barryvdh/laravel-dompdf": "^0.8.5",
|
||||
"barryvdh/laravel-snappy": "^0.4.5",
|
||||
"predis/predis": "^1.1",
|
||||
"doctrine/dbal": "^2.9",
|
||||
"fideloper/proxy": "^4.0",
|
||||
"gathercontent/htmldiff": "^0.2.1",
|
||||
"socialiteproviders/slack": "^3.0",
|
||||
"intervention/image": "^2.5",
|
||||
"laravel/framework": "^6.0",
|
||||
"laravel/socialite": "^4.2",
|
||||
"league/flysystem-aws-s3-v3": "^1.0",
|
||||
"predis/predis": "^1.1",
|
||||
"socialiteproviders/discord": "^2.0",
|
||||
"socialiteproviders/gitlab": "^3.0",
|
||||
"socialiteproviders/microsoft-azure": "^3.0",
|
||||
"socialiteproviders/okta": "^1.0",
|
||||
"socialiteproviders/gitlab": "^3.0",
|
||||
"socialiteproviders/twitch": "^3.0",
|
||||
"socialiteproviders/discord": "^2.0",
|
||||
"doctrine/dbal": "^2.9"
|
||||
"socialiteproviders/slack": "^3.0",
|
||||
"socialiteproviders/twitch": "^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"beyondcode/laravel-dump-server": "^1.0",
|
||||
"filp/whoops": "^2.0",
|
||||
"facade/ignition": "^1.4",
|
||||
"fzaninotto/faker": "^1.4",
|
||||
"mockery/mockery": "^1.0",
|
||||
"phpunit/phpunit": "^7.5",
|
||||
"phpunit/phpunit": "^8.0",
|
||||
"nunomaduro/collision": "^3.0",
|
||||
"laravel/browser-kit-testing": "^4.2.1",
|
||||
"laravel/browser-kit-testing": "^5.1",
|
||||
"barryvdh/laravel-ide-helper": "^2.6.4",
|
||||
"barryvdh/laravel-debugbar": "^3.2.8",
|
||||
"squizlabs/php_codesniffer": "^3.4"
|
||||
@ -89,7 +88,7 @@
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true,
|
||||
"platform": {
|
||||
"php": "7.1.3"
|
||||
"php": "7.2.0"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
|
698
composer.lock
generated
698
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -15,8 +15,8 @@ $factory->define(\BookStack\Auth\User::class, function ($faker) {
|
||||
return [
|
||||
'name' => $faker->name,
|
||||
'email' => $faker->email,
|
||||
'password' => str_random(10),
|
||||
'remember_token' => str_random(10),
|
||||
'password' => Str::random(10),
|
||||
'remember_token' => Str::random(10),
|
||||
'email_confirmed' => 1
|
||||
];
|
||||
});
|
||||
@ -24,7 +24,7 @@ $factory->define(\BookStack\Auth\User::class, function ($faker) {
|
||||
$factory->define(\BookStack\Entities\Bookshelf::class, function ($faker) {
|
||||
return [
|
||||
'name' => $faker->sentence,
|
||||
'slug' => str_random(10),
|
||||
'slug' => Str::random(10),
|
||||
'description' => $faker->paragraph
|
||||
];
|
||||
});
|
||||
@ -32,7 +32,7 @@ $factory->define(\BookStack\Entities\Bookshelf::class, function ($faker) {
|
||||
$factory->define(\BookStack\Entities\Book::class, function ($faker) {
|
||||
return [
|
||||
'name' => $faker->sentence,
|
||||
'slug' => str_random(10),
|
||||
'slug' => Str::random(10),
|
||||
'description' => $faker->paragraph
|
||||
];
|
||||
});
|
||||
@ -40,7 +40,7 @@ $factory->define(\BookStack\Entities\Book::class, function ($faker) {
|
||||
$factory->define(\BookStack\Entities\Chapter::class, function ($faker) {
|
||||
return [
|
||||
'name' => $faker->sentence,
|
||||
'slug' => str_random(10),
|
||||
'slug' => Str::random(10),
|
||||
'description' => $faker->paragraph
|
||||
];
|
||||
});
|
||||
@ -49,7 +49,7 @@ $factory->define(\BookStack\Entities\Page::class, function ($faker) {
|
||||
$html = '<p>' . implode('</p>', $faker->paragraphs(5)) . '</p>';
|
||||
return [
|
||||
'name' => $faker->sentence,
|
||||
'slug' => str_random(10),
|
||||
'slug' => Str::random(10),
|
||||
'html' => $html,
|
||||
'text' => strip_tags($html),
|
||||
'revision_count' => 1
|
||||
|
@ -28,7 +28,8 @@
|
||||
<server name="QUEUE_CONNECTION" value="sync"/>
|
||||
<server name="DB_CONNECTION" value="mysql_testing"/>
|
||||
<server name="BCRYPT_ROUNDS" value="4"/>
|
||||
<server name="MAIL_DRIVER" value="log"/>
|
||||
<server name="MAIL_DRIVER" value="array"/>
|
||||
<server name="LOG_CHANNEL" value="null"/>
|
||||
<server name="AUTH_METHOD" value="standard"/>
|
||||
<server name="DISABLE_EXTERNAL_SERVICES" value="true"/>
|
||||
<server name="AVATAR_URL" value=""/>
|
||||
|
@ -7,7 +7,7 @@
|
||||
<div class="my-l"> </div>
|
||||
|
||||
<div class="card content-wrap auto-height">
|
||||
<h1 class="list-heading">{{ title_case(trans('auth.log_in')) }}</h1>
|
||||
<h1 class="list-heading">{{ Str::title(trans('auth.log_in')) }}</h1>
|
||||
|
||||
<form action="{{ url('/login') }}" method="POST" id="login-form" class="mt-l">
|
||||
{!! csrf_field() !!}
|
||||
@ -28,7 +28,7 @@
|
||||
</div>
|
||||
|
||||
<div class="text-right">
|
||||
<button class="button" tabindex="1">{{ title_case(trans('auth.log_in')) }}</button>
|
||||
<button class="button" tabindex="1">{{ Str::title(trans('auth.log_in')) }}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
<div class="my-l"> </div>
|
||||
|
||||
<div class="card content-wrap auto-height">
|
||||
<h1 class="list-heading">{{ title_case(trans('auth.sign_up')) }}</h1>
|
||||
<h1 class="list-heading">{{ Str::title(trans('auth.sign_up')) }}</h1>
|
||||
|
||||
<form action="{{ url("/register") }}" method="POST" class="mt-l stretch-inputs">
|
||||
{!! csrf_field() !!}
|
||||
|
@ -2,7 +2,7 @@
|
||||
<?php $breadcrumbCount = 0; ?>
|
||||
|
||||
{{-- Show top level books item --}}
|
||||
@if (count($crumbs) > 0 && array_first($crumbs) instanceof \BookStack\Entities\Book)
|
||||
@if (count($crumbs) > 0 && ($crumbs[0] ?? null) instanceof \BookStack\Entities\Book)
|
||||
<a href="{{ url('/books') }}" class="text-book icon-list-item outline-hover">
|
||||
<span>@icon('books')</span>
|
||||
<span>{{ trans('entities.books') }}</span>
|
||||
@ -11,7 +11,7 @@
|
||||
@endif
|
||||
|
||||
{{-- Show top level shelves item --}}
|
||||
@if (count($crumbs) > 0 && array_first($crumbs) instanceof \BookStack\Entities\Bookshelf)
|
||||
@if (count($crumbs) > 0 && ($crumbs[0] ?? null) instanceof \BookStack\Entities\Bookshelf)
|
||||
<a href="{{ url('/shelves') }}" class="text-bookshelf icon-list-item outline-hover">
|
||||
<span>@icon('bookshelf')</span>
|
||||
<span>{{ trans('entities.shelves') }}</span>
|
||||
|
@ -153,7 +153,7 @@ class SocialAuthTest extends TestCase
|
||||
config()->set('services.google.select_account', 'true');
|
||||
|
||||
$resp = $this->get('/login/service/google');
|
||||
$this->assertContains('prompt=select_account', $resp->headers->get('Location'));
|
||||
$this->assertStringContainsString('prompt=select_account', $resp->headers->get('Location'));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class PageContentTest extends TestCase
|
||||
$resp->assertStatus(302);
|
||||
|
||||
$page = Page::find($page->id);
|
||||
$this->assertContains($includeTag, $page->html);
|
||||
$this->assertStringContainsString($includeTag, $page->html);
|
||||
$this->assertEquals('', $page->text);
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
<?php namespace Tests;
|
||||
|
||||
use BookStack\Entities\Book;
|
||||
use BookStack\Entities\Bookshelf;
|
||||
use BookStack\Entities\Chapter;
|
||||
use BookStack\Entities\Entity;
|
||||
use BookStack\Entities\Page;
|
||||
use BookStack\Entities\Repos\EntityRepo;
|
||||
@ -12,6 +10,7 @@ use BookStack\Auth\Permissions\PermissionService;
|
||||
use BookStack\Entities\Repos\PageRepo;
|
||||
use BookStack\Settings\SettingService;
|
||||
use BookStack\Uploads\HttpFetcher;
|
||||
use Illuminate\Support\Env;
|
||||
|
||||
trait SharedTestHelpers
|
||||
{
|
||||
@ -77,6 +76,7 @@ trait SharedTestHelpers
|
||||
/**
|
||||
* Regenerate the permission for an entity.
|
||||
* @param Entity $entity
|
||||
* @throws \Throwable
|
||||
*/
|
||||
protected function regenEntityPermissions(Entity $entity)
|
||||
{
|
||||
@ -116,6 +116,7 @@ trait SharedTestHelpers
|
||||
* Create and return a new test page
|
||||
* @param array $input
|
||||
* @return Page
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function newPage($input = ['name' => 'test page', 'html' => 'My new test page']) {
|
||||
$book = Book::first();
|
||||
@ -204,4 +205,58 @@ trait SharedTestHelpers
|
||||
->andReturn($returnData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a set test with the given env variable.
|
||||
* Remembers the original and resets the value after test.
|
||||
* @param string $name
|
||||
* @param $value
|
||||
* @param callable $callback
|
||||
*/
|
||||
protected function runWithEnv(string $name, $value, callable $callback)
|
||||
{
|
||||
Env::disablePutenv();
|
||||
$originalVal = $_ENV[$name] ?? null;
|
||||
|
||||
if (is_null($value)) {
|
||||
unset($_ENV[$name]);
|
||||
unset($_SERVER[$name]);
|
||||
} else {
|
||||
$_ENV[$name] = $value;
|
||||
$_SERVER[$name] = $value;
|
||||
}
|
||||
|
||||
$this->refreshApplication();
|
||||
$callback();
|
||||
|
||||
if (is_null($originalVal)) {
|
||||
unset($_SERVER[$name]);
|
||||
unset($_ENV[$name]);
|
||||
} else {
|
||||
$_SERVER[$name] = $originalVal;
|
||||
$_ENV[$name] = $originalVal;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the keys and properties in the given map to include
|
||||
* exist, albeit not exclusively, within the map to check.
|
||||
* @param array $mapToInclude
|
||||
* @param array $mapToCheck
|
||||
* @param string $message
|
||||
*/
|
||||
protected function assertArrayMapIncludes(array $mapToInclude, array $mapToCheck, string $message = '') : void
|
||||
{
|
||||
$passed = true;
|
||||
|
||||
foreach ($mapToInclude as $key => $value) {
|
||||
if (!isset($mapToCheck[$key]) || $mapToCheck[$key] !== $mapToInclude[$key]) {
|
||||
$passed = false;
|
||||
}
|
||||
}
|
||||
|
||||
$toIncludeStr = print_r($mapToInclude, true);
|
||||
$toCheckStr = print_r($mapToCheck, true);
|
||||
self::assertThat($passed, self::isTrue(), "Failed asserting that given map:\n\n{$toCheckStr}\n\nincludes:\n\n{$toIncludeStr}");
|
||||
}
|
||||
|
||||
}
|
@ -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));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -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]);
|
||||
|
@ -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');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -78,7 +78,7 @@ class AttachmentTest extends TestCase
|
||||
$upload->assertStatus(200);
|
||||
|
||||
$attachment = Attachment::query()->orderBy('id', 'desc')->first();
|
||||
$this->assertNotContains($fileName, $attachment->path);
|
||||
$this->assertStringNotContainsString($fileName, $attachment->path);
|
||||
$this->assertStringEndsWith('.txt', $attachment->path);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user