Prevented entity "Not Found" events from being logged

- Added testing to cover, which was more hassle than thought
  since Laravel did not have built in log test helpers, so:
- Added Log testing helper.

Related to #2110
This commit is contained in:
Dan Brown
2020-05-23 11:26:48 +01:00
parent bf4a3b73f8
commit 19bfc8ad37
5 changed files with 55 additions and 6 deletions

View File

@ -1,5 +1,8 @@
<?php namespace Tests;
use BookStack\Entities\Book;
use Illuminate\Support\Facades\Log;
class ErrorTest extends TestCase
{
@ -18,4 +21,21 @@ class ErrorTest extends TestCase
$notFound->assertDontSeeText('Log in');
$notFound->assertSeeText('tester');
}
public function test_item_not_found_does_not_get_logged_to_file()
{
$this->actingAs($this->getViewer());
$handler = $this->withTestLogger();
$book = Book::query()->first();
// Ensure we're seeing errors
Log::error('cat');
$this->assertTrue($handler->hasErrorThatContains('cat'));
$this->get('/books/arandomnotfouindbook');
$this->get($book->getUrl('/chapter/arandomnotfouindchapter'));
$this->get($book->getUrl('/chapter/arandomnotfouindpages'));
$this->assertCount(1, $handler->getRecords());
}
}