3 use BookStack\Entities\Models\Book;
4 use Illuminate\Support\Facades\Log;
6 class ErrorTest extends TestCase
9 public function test_404_page_does_not_show_login()
11 // Due to middleware being handled differently this will not fail
12 // if our custom, middleware-loaded handler fails but this is here
13 // as a reminder and as a general check in the event of other issues.
14 $editor = $this->getEditor();
15 $editor->name = 'tester';
18 $this->actingAs($editor);
19 $notFound = $this->get('/fgfdngldfnotfound');
20 $notFound->assertStatus(404);
21 $notFound->assertDontSeeText('Log in');
22 $notFound->assertSeeText('tester');
25 public function test_item_not_found_does_not_get_logged_to_file()
27 $this->actingAs($this->getViewer());
28 $handler = $this->withTestLogger();
29 $book = Book::query()->first();
31 // Ensure we're seeing errors
33 $this->assertTrue($handler->hasErrorThatContains('cat'));
35 $this->get('/books/arandomnotfouindbook');
36 $this->get($book->getUrl('/chapter/arandomnotfouindchapter'));
37 $this->get($book->getUrl('/chapter/arandomnotfouindpages'));
39 $this->assertCount(1, $handler->getRecords());