public function testSortedQueryThrowsNotFoundException(EntityManager $em)
{
$category = (new Category())->setId(5000);
$article1 = (new Article())->setId(5001)->setTitle('A');
$article2 = (new Article())->setId(5002)->setTitle('B');
$article3 = (new Article())->setId(5003)->setTitle('C');
$category->addArticle($article1);
$category->addArticle($article2);
$category->addArticle($article3);
$em->persist($article1)->persist($article2)->persist($article3)->persist($category)->flush();
// Forcefully break the relationship via the driver manually
$em->getDriver()->delete($em->getKeyScheme()->getEntityKey('article', '5001'));
$em->getDriver()->flush();
$category = $em->retrieve(Category::class, 5000, false);
$results = $em->sortedQuery(new SortedQuery($category, 'articles', 'sort_date'));
// Iterating through these results should trigger an exception
foreach ($results as $result) {
}
}