mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-01-03 23:42:28 +03:00
Laravel 7.x Shift (#3011)
* Apply Laravel coding style * Shift bindings * Shift core files * Shift to Throwable * Add laravel/ui dependency * Shift Eloquent methods * Shift config files * Shift Laravel dependencies * Shift cleanup * Shift test config and references * Applied styleci changes * Applied fixes post shift to laravel 7 Co-authored-by: Shift <shift@laravelshift.com>
This commit is contained in:
@@ -325,6 +325,6 @@ class AttachmentsApiTest extends TestCase
|
||||
*/
|
||||
protected function getTestFile(string $fileName): UploadedFile
|
||||
{
|
||||
return new UploadedFile(base_path('tests/test-data/test-file.txt'), $fileName, 'text/plain', 55, null, true);
|
||||
return new UploadedFile(base_path('tests/test-data/test-file.txt'), $fileName, 'text/plain', null, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class MfaConfigurationTest extends TestCase
|
||||
$this->assertTrue($svg === $revisitSvg);
|
||||
$secret = decrypt(session()->get('mfa-setup-totp-secret'));
|
||||
|
||||
$resp->assertSee(htmlentities("?secret={$secret}&issuer=BookStack&algorithm=SHA1&digits=6&period=30"));
|
||||
$resp->assertSee("?secret={$secret}&issuer=BookStack&algorithm=SHA1&digits=6&period=30");
|
||||
|
||||
// Successful confirmation
|
||||
$google2fa = new Google2FA();
|
||||
@@ -180,7 +180,7 @@ class MfaConfigurationTest extends TestCase
|
||||
|
||||
$resp = $this->get('/mfa/totp/generate');
|
||||
$resp->assertSeeText('Mobile App Setup');
|
||||
$resp->assertDontSee('otpauth://totp/BookStack:guest%40example.com');
|
||||
$resp->assertSee('otpauth://totp/BookStack:admin%40admin.com');
|
||||
$resp->assertDontSee('otpauth://totp/BookStack:guest%40example.com', false);
|
||||
$resp->assertSee('otpauth://totp/BookStack:admin%40admin.com', false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class Saml2Test extends TestCase
|
||||
$req = $this->get('/saml2/metadata');
|
||||
$req->assertSee('https://example.com/super-cats');
|
||||
$req->assertSee('md:ContactPerson');
|
||||
$req->assertSee('<md:GivenName>Barry Scott</md:GivenName>');
|
||||
$req->assertSee('<md:GivenName>Barry Scott</md:GivenName>', false);
|
||||
}
|
||||
|
||||
public function test_login_option_shows_on_login_page()
|
||||
|
||||
@@ -290,7 +290,7 @@ class BookShelfTest extends TestCase
|
||||
$shelf = Bookshelf::first();
|
||||
$resp = $this->asAdmin()->get($shelf->getUrl('/permissions'));
|
||||
$resp->assertSeeText('Copy Permissions');
|
||||
$resp->assertSee("action=\"{$shelf->getUrl('/copy-permissions')}\"");
|
||||
$resp->assertSee("action=\"{$shelf->getUrl('/copy-permissions')}\"", false);
|
||||
|
||||
$child = $shelf->books()->first();
|
||||
$editorRole = $this->getEditor()->roles()->first();
|
||||
|
||||
@@ -187,7 +187,7 @@ class BookTest extends TestCase
|
||||
'name' => 'информация',
|
||||
]);
|
||||
|
||||
$this->assertEquals('informatsiya', $book->slug);
|
||||
$this->assertEquals('informaciya', $book->slug);
|
||||
|
||||
$book = $this->newBook([
|
||||
'name' => '¿Qué?',
|
||||
|
||||
@@ -88,7 +88,7 @@ class CommentTest extends TestCase
|
||||
]);
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertSee('<h1>My Title</h1>');
|
||||
$pageView->assertSee('<h1>My Title</h1>', false);
|
||||
}
|
||||
|
||||
public function test_html_cannot_be_injected_via_comment_content()
|
||||
@@ -102,7 +102,7 @@ class CommentTest extends TestCase
|
||||
]);
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertDontSee($script);
|
||||
$pageView->assertDontSee($script, false);
|
||||
$pageView->assertSee('sometextinthecomment');
|
||||
|
||||
$comment = $page->comments()->first();
|
||||
@@ -111,7 +111,7 @@ class CommentTest extends TestCase
|
||||
]);
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertDontSee($script);
|
||||
$pageView->assertDontSee($script, false);
|
||||
$pageView->assertSee('sometextinthecommentupdated');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ class ExportTest extends TestCase
|
||||
$this->setSettings(['app-custom-head' => $customHeadContent]);
|
||||
|
||||
$resp = $this->asEditor()->get($page->getUrl('/export/html'));
|
||||
$resp->assertSee($customHeadContent);
|
||||
$resp->assertSee($customHeadContent, false);
|
||||
}
|
||||
|
||||
public function test_page_html_export_does_not_break_with_only_comments_in_custom_head()
|
||||
@@ -151,7 +151,7 @@ class ExportTest extends TestCase
|
||||
|
||||
$resp = $this->asEditor()->get($page->getUrl('/export/html'));
|
||||
$resp->assertStatus(200);
|
||||
$resp->assertSee($customHeadContent);
|
||||
$resp->assertSee($customHeadContent, false);
|
||||
}
|
||||
|
||||
public function test_page_html_export_use_absolute_dates()
|
||||
@@ -188,7 +188,7 @@ class ExportTest extends TestCase
|
||||
Storage::disk('local')->delete('uploads/images/gallery/svg_test.svg');
|
||||
|
||||
$resp->assertStatus(200);
|
||||
$resp->assertSee('<img src="data:image/svg+xml;base64');
|
||||
$resp->assertSee('<img src="data:image/svg+xml;base64', false);
|
||||
}
|
||||
|
||||
public function test_page_image_containment_works_on_multiple_images_within_a_single_line()
|
||||
@@ -224,9 +224,9 @@ class ExportTest extends TestCase
|
||||
$storageDisk->delete('uploads/images/gallery/svg_test.svg');
|
||||
$storageDisk->delete('uploads/svg_test.svg');
|
||||
|
||||
$resp->assertDontSee('http://localhost/uploads/images/gallery/svg_test.svg');
|
||||
$resp->assertDontSee('http://localhost/uploads/images/gallery/svg_test.svg', false);
|
||||
$resp->assertSee('http://localhost/uploads/svg_test.svg');
|
||||
$resp->assertSee('src="/uploads/svg_test.svg"');
|
||||
$resp->assertSee('src="/uploads/svg_test.svg"', false);
|
||||
}
|
||||
|
||||
public function test_page_export_contained_html_does_not_allow_upward_traversal_with_local()
|
||||
@@ -333,7 +333,7 @@ class ExportTest extends TestCase
|
||||
$page->save();
|
||||
|
||||
$resp = $this->asEditor()->get($page->getUrl('/export/markdown'));
|
||||
$resp->assertSee("# Dogcat\n\n<p class=\"callout info\">Some callout text</p>\n\nAnother line");
|
||||
$resp->assertSee("# Dogcat\n\n<p class=\"callout info\">Some callout text</p>\n\nAnother line", false);
|
||||
}
|
||||
|
||||
public function test_page_markdown_export_handles_bookstacks_wysiwyg_codeblock_format()
|
||||
@@ -345,7 +345,7 @@ class ExportTest extends TestCase
|
||||
$page->save();
|
||||
|
||||
$resp = $this->asEditor()->get($page->getUrl('/export/markdown'));
|
||||
$resp->assertSee("# Dogcat\n\n```JavaScript\nvar a = 'cat';\n```\n\nAnother line");
|
||||
$resp->assertSee("# Dogcat\n\n```JavaScript\nvar a = 'cat';\n```\n\nAnother line", false);
|
||||
}
|
||||
|
||||
public function test_chapter_markdown_export()
|
||||
|
||||
@@ -74,7 +74,7 @@ class PageContentTest extends TestCase
|
||||
|
||||
$this->asEditor();
|
||||
$pageResp = $this->get($page->getUrl());
|
||||
$pageResp->assertSee($content);
|
||||
$pageResp->assertSee($content, false);
|
||||
}
|
||||
|
||||
public function test_page_includes_rendered_on_book_export()
|
||||
@@ -106,7 +106,7 @@ class PageContentTest extends TestCase
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertStatus(200);
|
||||
$pageView->assertDontSee($script);
|
||||
$pageView->assertDontSee($script, false);
|
||||
$pageView->assertSee('abc123abc123');
|
||||
}
|
||||
|
||||
@@ -260,8 +260,8 @@ class PageContentTest extends TestCase
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertStatus(200);
|
||||
$pageView->assertDontSee($script);
|
||||
$pageView->assertSee('<p>Hello</p>');
|
||||
$pageView->assertDontSee($script, false);
|
||||
$pageView->assertSee('<p>Hello</p>', false);
|
||||
}
|
||||
|
||||
public function test_more_complex_inline_on_attributes_escaping_scenarios()
|
||||
@@ -301,7 +301,7 @@ class PageContentTest extends TestCase
|
||||
$page->save();
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertSee($script);
|
||||
$pageView->assertSee($script, false);
|
||||
$pageView->assertDontSee('abc123abc123');
|
||||
}
|
||||
|
||||
@@ -338,8 +338,8 @@ class PageContentTest extends TestCase
|
||||
$page->save();
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertSee($script);
|
||||
$pageView->assertDontSee('<p>Hello</p>');
|
||||
$pageView->assertSee($script, false);
|
||||
$pageView->assertDontSee('<p>Hello</p>', false);
|
||||
}
|
||||
|
||||
public function test_duplicate_ids_does_not_break_page_render()
|
||||
@@ -545,7 +545,7 @@ class PageContentTest extends TestCase
|
||||
|
||||
$pageView = $this->get($page->getUrl());
|
||||
$pageView->assertStatus(200);
|
||||
$pageView->assertSee($content);
|
||||
$pageView->assertSee($content, false);
|
||||
}
|
||||
|
||||
public function test_base64_images_get_extracted_from_page_content()
|
||||
|
||||
@@ -173,11 +173,11 @@ class RolesTest extends TestCase
|
||||
public function test_manage_users_permission_shows_link_in_header_if_does_not_have_settings_manage_permision()
|
||||
{
|
||||
$usersLink = 'href="' . url('/settings/users') . '"';
|
||||
$this->actingAs($this->user)->get('/')->assertDontSee($usersLink);
|
||||
$this->actingAs($this->user)->get('/')->assertDontSee($usersLink, false);
|
||||
$this->giveUserPermissions($this->user, ['users-manage']);
|
||||
$this->actingAs($this->user)->get('/')->assertSee($usersLink);
|
||||
$this->actingAs($this->user)->get('/')->assertSee($usersLink, false);
|
||||
$this->giveUserPermissions($this->user, ['settings-manage', 'users-manage']);
|
||||
$this->actingAs($this->user)->get('/')->assertDontSee($usersLink);
|
||||
$this->actingAs($this->user)->get('/')->assertDontSee($usersLink, false);
|
||||
}
|
||||
|
||||
public function test_user_cannot_change_email_unless_they_have_manage_users_permission()
|
||||
|
||||
@@ -76,7 +76,7 @@ class SecurityHeaderTest extends TestCase
|
||||
|
||||
$nonce = app()->make(CspService::class)->getNonce();
|
||||
$this->assertStringContainsString('nonce-' . $nonce, $scriptHeader);
|
||||
$resp->assertSee('<script nonce="' . $nonce . '">console.log("cat");</script>');
|
||||
$resp->assertSee('<script nonce="' . $nonce . '">console.log("cat");</script>', false);
|
||||
}
|
||||
|
||||
public function test_script_csp_nonce_changes_per_request()
|
||||
|
||||
@@ -11,21 +11,21 @@ class CustomHeadContentTest extends TestCase
|
||||
{
|
||||
$this->setSettings(['app-custom-head' => '<script>console.log("cat");</script>']);
|
||||
$resp = $this->get('/login');
|
||||
$resp->assertSee('console.log("cat")');
|
||||
$resp->assertSee('console.log("cat")', false);
|
||||
}
|
||||
|
||||
public function test_configured_content_does_not_show_on_settings_page()
|
||||
{
|
||||
$this->setSettings(['app-custom-head' => '<script>console.log("cat");</script>']);
|
||||
$resp = $this->asAdmin()->get('/settings');
|
||||
$resp->assertDontSee('console.log("cat")');
|
||||
$resp->assertDontSee('console.log("cat")', false);
|
||||
}
|
||||
|
||||
public function test_divs_in_js_preserved_in_configured_content()
|
||||
{
|
||||
$this->setSettings(['app-custom-head' => '<script><div id="hello">cat</div></script>']);
|
||||
$resp = $this->get('/login');
|
||||
$resp->assertSee('<div id="hello">cat</div>');
|
||||
$resp->assertSee('<div id="hello">cat</div>', false);
|
||||
}
|
||||
|
||||
public function test_nonce_application_handles_edge_cases()
|
||||
@@ -61,6 +61,6 @@ const b = `<script`;
|
||||
|
||||
$this->setSettings(['app-custom-head' => $content]);
|
||||
$resp = $this->get('/login');
|
||||
$resp->assertSee($expectedOutput);
|
||||
$resp->assertSee($expectedOutput, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,10 +31,10 @@ class FooterLinksTest extends TestCase
|
||||
]]);
|
||||
|
||||
$resp = $this->asAdmin()->get('/settings');
|
||||
$resp->assertSee('value="My custom link"');
|
||||
$resp->assertSee('value="Another Link"');
|
||||
$resp->assertSee('value="https://example.com/link-a"');
|
||||
$resp->assertSee('value="https://example.com/link-b"');
|
||||
$resp->assertSee('value="My custom link"', false);
|
||||
$resp->assertSee('value="Another Link"', false);
|
||||
$resp->assertSee('value="https://example.com/link-a"', false);
|
||||
$resp->assertSee('value="https://example.com/link-b"', false);
|
||||
}
|
||||
|
||||
public function test_footer_links_show_on_pages()
|
||||
|
||||
@@ -22,10 +22,10 @@ use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Handler\MockHandler;
|
||||
use GuzzleHttp\HandlerStack;
|
||||
use GuzzleHttp\Middleware;
|
||||
use Illuminate\Foundation\Testing\Assert as PHPUnit;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Env;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Testing\Assert as PHPUnit;
|
||||
use Mockery;
|
||||
use Monolog\Handler\TestHandler;
|
||||
use Monolog\Logger;
|
||||
@@ -127,7 +127,7 @@ trait SharedTestHelpers
|
||||
/**
|
||||
* Create and return a new test chapter.
|
||||
*/
|
||||
public function newChapter(array $input = ['name' => 'test chapter', 'description' => 'My new test chapter'], Book $book): Chapter
|
||||
public function newChapter(array $input, Book $book): Chapter
|
||||
{
|
||||
return app(ChapterRepo::class)->create($input, $book);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Foundation\Testing\TestResponse as BaseTestResponse;
|
||||
use Illuminate\Testing\TestResponse as BaseTestResponse;
|
||||
use PHPUnit\Framework\Assert as PHPUnit;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
|
||||
@@ -17,13 +17,13 @@ class AttachmentTest extends TestCase
|
||||
*/
|
||||
protected function getTestFile(string $fileName): UploadedFile
|
||||
{
|
||||
return new UploadedFile(base_path('tests/test-data/test-file.txt'), $fileName, 'text/plain', 55, null, true);
|
||||
return new UploadedFile(base_path('tests/test-data/test-file.txt'), $fileName, 'text/plain', null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads a file with the given name.
|
||||
*/
|
||||
protected function uploadFile(string $name, int $uploadedTo = 0): \Illuminate\Foundation\Testing\TestResponse
|
||||
protected function uploadFile(string $name, int $uploadedTo = 0): \Illuminate\Testing\TestResponse
|
||||
{
|
||||
$file = $this->getTestFile($name);
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ class DrawioTest extends TestCase
|
||||
$editor = $this->getEditor();
|
||||
|
||||
$resp = $this->actingAs($editor)->get($page->getUrl('/edit'));
|
||||
$resp->assertSee('drawio-url="http://cats.com?dog=tree"');
|
||||
$resp->assertSee('drawio-url="http://cats.com?dog=tree"', false);
|
||||
}
|
||||
|
||||
public function test_drawio_url_can_be_disabled()
|
||||
@@ -71,10 +71,10 @@ class DrawioTest extends TestCase
|
||||
$editor = $this->getEditor();
|
||||
|
||||
$resp = $this->actingAs($editor)->get($page->getUrl('/edit'));
|
||||
$resp->assertSee('drawio-url="https://embed.diagrams.net/?embed=1&proto=json&spin=1"');
|
||||
$resp->assertSee('drawio-url="https://embed.diagrams.net/?embed=1&proto=json&spin=1"', false);
|
||||
|
||||
config()->set('services.drawio', false);
|
||||
$resp = $this->actingAs($editor)->get($page->getUrl('/edit'));
|
||||
$resp->assertDontSee('drawio-url');
|
||||
$resp->assertDontSee('drawio-url', false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user