FIX Exclude links attached to archived Pages from report (#72)

This commit is contained in:
Garion Herman 2021-02-04 09:45:39 +13:00 committed by GitHub
parent 7b68fe0eaa
commit cb7a1acb47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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());
}
}