mirror of
https://github.com/silverstripe/silverstripe-externallinks.git
synced 2024-10-22 17:05:44 +02:00
FIX Exclude links attached to archived Pages from report (#72)
This commit is contained in:
parent
7b68fe0eaa
commit
cb7a1acb47
@ -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();
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user