mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-31 15:24:31 +03:00
Added regenerate-references command test
Also updated model resolvers to only fetch model ID, to prevent bringing back way more data from database than desired.
This commit is contained in:
32
tests/Commands/RegenerateReferencesCommandTest.php
Normal file
32
tests/Commands/RegenerateReferencesCommandTest.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Commands;
|
||||
|
||||
use BookStack\Entities\Models\Page;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\TestCase;
|
||||
|
||||
class RegenerateReferencesCommandTest extends TestCase
|
||||
{
|
||||
public function test_regenerate_references_command()
|
||||
{
|
||||
/** @var Page $page */
|
||||
$page = Page::query()->first();
|
||||
$book = $page->book;
|
||||
|
||||
$page->html = '<a href="' . $book->getUrl() . '">Book Link</a>';
|
||||
$page->save();
|
||||
|
||||
DB::table('references')->delete();
|
||||
|
||||
$this->artisan('bookstack:regenerate-references')
|
||||
->assertExitCode(0);
|
||||
|
||||
$this->assertDatabaseHas('references', [
|
||||
'from_id' => $page->id,
|
||||
'from_type' => $page->getMorphClass(),
|
||||
'to_id' => $book->id,
|
||||
'to_type' => $book->getMorphClass(),
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user