Merge branch '2.1' into 2

This commit is contained in:
Steve Boyd 2021-02-04 09:47:18 +13:00
commit 40c96ce23f
2 changed files with 20 additions and 1 deletions

View File

@ -71,7 +71,8 @@ class BrokenExternalLinksReport extends Report
{
$track = BrokenExternalPageTrackStatus::get_latest();
if ($track) {
return $track->BrokenLinks();
// Filter items that are attached to archived Pages
return $track->BrokenLinks()->exclude('Track.Page.ID', null);
}
return ArrayList::create();
}

View File

@ -107,4 +107,22 @@ class ExternalLinksTest extends SapphireTest
'BrokenExternalLinksReport is in reports list'
);
}
public function testArchivedPagesAreHiddenFromReport()
{
// Run link checker
$task = CheckExternalLinksTask::create();
$task->setSilent(true); // Be quiet during the test!
$task->runLinksCheck();
// Ensure report lists all broken links
$this->assertEquals(4, BrokenExternalLinksReport::create()->sourceRecords()->count());
// Archive a page
$page = $this->objFromFixture(ExternalLinksTestPage::class, 'page1');
$page->doArchive();
// Ensure report does not list the link associated with an archived page
$this->assertEquals(3, BrokenExternalLinksReport::create()->sourceRecords()->count());
}
}