2022-08-17 23:59:23 +08: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-30 00:31:38 +08:00
|
|
|
$page = $this->entities->page();
|
2022-08-17 23:59:23 +08: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-30 00:46:41 +08:00
|
|
|
'from_id' => $page->id,
|
2022-08-17 23:59:23 +08:00
|
|
|
'from_type' => $page->getMorphClass(),
|
2022-08-30 00:46:41 +08:00
|
|
|
'to_id' => $book->id,
|
|
|
|
'to_type' => $book->getMorphClass(),
|
2022-08-17 23:59:23 +08:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|