getEachEntityType();
$otherPage = Page::query()->where('id', '!=', $entities['page']->id)->first();
$html = '
Page Permalink
Page Link
Chapter Link
Book Link
Shelf Link
Settings Link
';
$parser = CrossLinkParser::createWithEntityResolvers();
$results = $parser->extractLinkedModels($html);
$this->assertCount(5, $results);
$this->assertEquals(get_class($otherPage), get_class($results[0]));
$this->assertEquals($otherPage->id, $results[0]->id);
$this->assertEquals(get_class($entities['page']), get_class($results[1]));
$this->assertEquals($entities['page']->id, $results[1]->id);
$this->assertEquals(get_class($entities['chapter']), get_class($results[2]));
$this->assertEquals($entities['chapter']->id, $results[2]->id);
$this->assertEquals(get_class($entities['book']), get_class($results[3]));
$this->assertEquals($entities['book']->id, $results[3]->id);
$this->assertEquals(get_class($entities['bookshelf']), get_class($results[4]));
$this->assertEquals($entities['bookshelf']->id, $results[4]->id);
}
public function test_similar_page_and_book_reference_links_dont_conflict()
{
$page = Page::query()->first();
$book = $page->book;
$html = '
Page Link
Book Link
';
$parser = CrossLinkParser::createWithEntityResolvers();
$results = $parser->extractLinkedModels($html);
$this->assertCount(2, $results);
$this->assertEquals(get_class($page), get_class($results[0]));
$this->assertEquals($page->id, $results[0]->id);
$this->assertEquals(get_class($book), get_class($results[1]));
$this->assertEquals($book->id, $results[1]->id);
}
}