2022-08-17 11:59:23 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Commands;
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class RegenerateReferencesCommandTest extends TestCase
|
|
|
|
{
|
|
|
|
public function test_regenerate_references_command()
|
|
|
|
{
|
2022-09-29 12:31:38 -04:00
|
|
|
$page = $this->entities->page();
|
2022-08-17 11:59:23 -04:00
|
|
|
$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', [
|
2022-08-29 12:46:41 -04:00
|
|
|
'from_id' => $page->id,
|
2022-08-17 11:59:23 -04:00
|
|
|
'from_type' => $page->getMorphClass(),
|
2022-08-29 12:46:41 -04:00
|
|
|
'to_id' => $book->id,
|
|
|
|
'to_type' => $book->getMorphClass(),
|
2022-08-17 11:59:23 -04:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|