/** * Utility method for all tests to use. * * @return \ArrayList * @todo pre-fill the report with fixture-defined users */ public function setUp() { parent::setUp(); $reports = SS_Report::get_reports(); $report = $reports['UserSecurityReport']; $this->report = $report; $this->records = $report->sourceRecords()->toArray(); }
public function testAbstractClassesAreExcluded() { $reports = SS_Report::get_reports(); $reportNames = array(); foreach ($reports as $report) { $reportNames[] = $report->class; } $this->assertNotContains('ReportTest_FakeTest_Abstract', $reportNames, 'ReportTest_FakeTest_Abstract is NOT in reports list as it is abstract'); }
/** * Test that broken links appears in the reports list */ public function testReportExists() { $reports = SS_Report::get_reports(); $reportNames = array(); foreach ($reports as $report) { $reportNames[] = $report->class; } $this->assertContains('BrokenExternalLinksReport', $reportNames, 'BrokenExternalLinksReport is in reports list'); }
public function setUp() { parent::setUp(); if (!class_exists('Subsite')) { $this->skipTest = true; return $this->markTestSkipped("Please install Subsites to run this test"); } $reports = SS_Report::get_reports(); $report = $reports['UserSecurityReport']; $this->records = $report->sourceRecords()->toArray(); }
/** * @return ArrayList */ public function UpdatedReportList() { $output = new ArrayList(); foreach (SS_Report::get_reports() as $report) { if (!in_array(get_class($report), array('SideReport_BrokenFiles'))) { if ($report->canView()) { $output->push($report); } } } return $output; }
/** * Determine if we have reports and need * to display the "Reports" main menu item * in the CMS. * * The test for an existance of a report * is done by checking for a subclass of * "SS_Report" that exists. * * @return boolean */ public static function has_reports() { return sizeof(SS_Report::get_reports()) > 0; }
function SideReports() { return SS_Report::get_reports('SideReport'); }
/** * Test the broken links report. */ public function testBrokenLinksReport() { // --- // BROKEN LINKS // --- // Create a "draft" page with a broken link. $page = Page::create(); $page->Content = "<a href='[sitetree_link,id=987654321]'>This</a> is a broken link."; $page->writeToStage('Stage'); // Retrieve the broken links report. $reports = SS_Report::get_reports(); $brokenLinksReport = null; foreach ($reports as $report) { if ($report instanceof BrokenLinksReport) { $brokenLinksReport = $report; break; } } // Determine that the report exists, otherwise it has been excluded. if ($brokenLinksReport) { // ASSERT that the "draft" report has detected the page having a broken link. // ASSERT that the "published" report has NOT detected the page having a broken link, as the page has not been "published" yet. $this->isReportBroken($brokenLinksReport, true, false, 'BROKENLINK'); // Make sure the page is now "published". $page->writeToStage('Live'); // ASSERT that the "draft" report has detected the page having a broken link. // ASSERT that the "published" report has detected the page having a broken link. $this->isReportBroken($brokenLinksReport, true, true, 'BROKENLINK'); // Correct the "draft" broken link. $page->Content = str_replace('987654321', $page->ID, $page->Content); $page->writeToStage('Stage'); // ASSERT that the "draft" report has NOT detected the page having a broken link. // ASSERT that the "published" report has detected the page having a broken link, as the previous content remains "published". $this->isReportBroken($brokenLinksReport, false, true, 'BROKENLINK'); // Make sure the change has now been "published". $page->writeToStage('Live'); // ASSERT that the "draft" report has NOT detected the page having a broken link. // ASSERT that the "published" report has NOT detected the page having a broken link. $this->isReportBroken($brokenLinksReport, false, false, 'BROKENLINK'); $page->delete(); // --- // BROKEN FILES // --- // Create a "draft" page with a broken file. $page = Page::create(); $page->Content = "<a href='[file_link,id=987654321]'>This</a> is a broken file."; $page->writeToStage('Stage'); // ASSERT that the "draft" report has detected the page having a broken file. // ASSERT that the "published" report has NOT detected the page having a broken file, as the page has not been "published" yet. $this->isReportBroken($brokenLinksReport, true, false, 'BROKENFILE'); // Make sure the page is now "published". $page->writeToStage('Live'); // ASSERT that the "draft" report has detected the page having a broken file. // ASSERT that the "published" report has detected the page having a broken file. $this->isReportBroken($brokenLinksReport, true, true, 'BROKENFILE'); // Correct the "draft" broken file. $file = File::create(); $file->Filename = 'name.pdf'; $file->write(); $page->Content = str_replace('987654321', $file->ID, $page->Content); $page->writeToStage('Stage'); // ASSERT that the "draft" report has NOT detected the page having a broken file. // ASSERT that the "published" report has detected the page having a broken file, as the previous content remains "published". $this->isReportBroken($brokenLinksReport, false, true, 'BROKENFILE'); // Make sure the change has now been "published". $page->writeToStage('Live'); // ASSERT that the "draft" report has NOT detected the page having a broken file. // ASSERT that the "published" report has NOT detected the page having a broken file. $this->isReportBroken($brokenLinksReport, false, false, 'BROKENFILE'); $page->delete(); // --- // BROKEN VIRTUAL PAGES // --- // Create a "draft" virtual page with a broken link. $page = VirtualPage::create(); $page->CopyContentFromID = 987654321; $page->writeToStage('Stage'); // ASSERT that the "draft" report has detected the page having a broken link. // ASSERT that the "published" report has NOT detected the page having a broken link, as the page has not been "published" yet. $this->isReportBroken($brokenLinksReport, true, false, 'VPBROKENLINK'); // Make sure the page is now "published". $page->writeToStage('Live'); // ASSERT that the "draft" report has detected the page having a broken link. // ASSERT that the "published" report has detected the page having a broken link. $this->isReportBroken($brokenLinksReport, true, true, 'VPBROKENLINK'); // Correct the "draft" broken link. $contentPage = Page::create(); $contentPage->Content = 'This is some content.'; $contentPage->writeToStage('Stage'); $contentPage->writeToStage('Live'); $page->CopyContentFromID = $contentPage->ID; $page->writeToStage('Stage'); // ASSERT that the "draft" report has NOT detected the page having a broken link. // ASSERT that the "published" report has detected the page having a broken link, as the previous content remains "published". $this->isReportBroken($brokenLinksReport, false, true, 'VPBROKENLINK'); // Make sure the change has now been "published". $page->writeToStage('Live'); // ASSERT that the "draft" report has NOT detected the page having a broken link. // ASSERT that the "published" report has NOT detected the page having a broken link. $this->isReportBroken($brokenLinksReport, false, false, 'VPBROKENLINK'); $contentPage->delete(); $page->delete(); // --- // BROKEN REDIRECTOR PAGES // --- // Create a "draft" redirector page with a broken link. $page = RedirectorPage::create(); $page->RedirectionType = 'Internal'; $page->LinkToID = 987654321; $page->writeToStage('Stage'); // ASSERT that the "draft" report has detected the page having a broken link. // ASSERT that the "published" report has NOT detected the page having a broken link, as the page has not been "published" yet. $this->isReportBroken($brokenLinksReport, true, false, 'RPBROKENLINK'); // Make sure the page is now "published". $page->writeToStage('Live'); // ASSERT that the "draft" report has detected the page having a broken link. // ASSERT that the "published" report has detected the page having a broken link. $this->isReportBroken($brokenLinksReport, true, true, 'RPBROKENLINK'); // Correct the "draft" broken link. $contentPage = Page::create(); $contentPage->Content = 'This is some content.'; $contentPage->writeToStage('Stage'); $contentPage->writeToStage('Live'); $page->LinkToID = $contentPage->ID; $page->writeToStage('Stage'); // ASSERT that the "draft" report has NOT detected the page having a broken link. // ASSERT that the "published" report has detected the page having a broken link, as the previous content remains "published". $this->isReportBroken($brokenLinksReport, false, true, 'RPBROKENLINK'); // Make sure the change has now been "published". $page->writeToStage('Live'); // ASSERT that the "draft" report has NOT detected the page having a broken link. // ASSERT that the "published" report has NOT detected the page having a broken link. $this->isReportBroken($brokenLinksReport, false, false, 'RPBROKENLINK'); } }
/** * Test the broken redirector pages side report. */ public function testBrokenRedirectorPages() { // Create a "draft" redirector page with a broken link. $page = RedirectorPage::create(); $page->RedirectionType = 'Internal'; $page->LinkToID = 987654321; $page->writeToStage('Stage'); // Retrieve the broken redirector pages side report. $reports = SS_Report::get_reports(); $brokenRedirectorPagesReport = null; foreach ($reports as $report) { if ($report instanceof SideReport_BrokenRedirectorPages) { $brokenRedirectorPagesReport = $report; break; } } // Determine that the report exists, otherwise it has been excluded. if ($brokenRedirectorPagesReport) { // ASSERT that the "draft" report has detected the page having a broken link. // ASSERT that the "published" report has NOT detected the page having a broken link, as the page has not been "published" yet. $this->isReportBroken($brokenRedirectorPagesReport, true, false); // Make sure the page is now "published". $page->writeToStage('Live'); // ASSERT that the "draft" report has detected the page having a broken link. // ASSERT that the "published" report has detected the page having a broken link. $this->isReportBroken($brokenRedirectorPagesReport, true, true); // Correct the "draft" broken link. $contentPage = Page::create(); $contentPage->Content = 'This is some content.'; $contentPage->writeToStage('Stage'); $contentPage->writeToStage('Live'); $page->LinkToID = $contentPage->ID; $page->writeToStage('Stage'); // ASSERT that the "draft" report has NOT detected the page having a broken link. // ASSERT that the "published" report has detected the page having a broken link, as the previous content remains "published". $this->isReportBroken($brokenRedirectorPagesReport, false, true); // Make sure the change has now been "published". $page->writeToStage('Live'); // ASSERT that the "draft" report has NOT detected the page having a broken link. // ASSERT that the "published" report has NOT detected the page having a broken link. $this->isReportBroken($brokenRedirectorPagesReport, false, false); } }