mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-29 20:06:18 +08:00
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:
@ -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());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user