silverstripe-externallinks/tests/ExternalLinksTest.php

40 lines
1.2 KiB
PHP
Raw Normal View History

2014-07-28 02:39:19 +02:00
<?php
class ExternalLinks extends FunctionalTest {
protected static $fixture_file = 'ExternalLinksTest.yml';
public function testLinks() {
2014-07-28 02:39:19 +02:00
// uses http://127.0.0.1 to test a working link
$working = $this->objFromFixture('SiteTree', 'working');
$working->write();
2014-07-28 02:39:19 +02:00
$task = new CheckExternalLinks();
$task->run(null);
$brokenLinks = BrokenExternalLink::get()->column('Link');;
// confirm the working link has not been added as a broken link
$this->assertNotEquals($working->Link, $brokenLinks[0]);
2014-07-28 02:39:19 +02:00
}
public function testBrokenLink() {
// uses http://192.0.2.1 for a broken link
$broken = $this->objFromFixture('SiteTree', 'broken');
$broken->write();
2014-07-28 02:39:19 +02:00
$task = new CheckExternalLinks();
$task->run(null);
$brokenLinks = BrokenExternalLink::get();
2014-07-28 02:39:19 +02:00
$this->assertEquals(1, $brokenLinks->count());
}
public function testReportExists() {
$mock = $this->objFromFixture('SiteTree', 'broken');
2014-07-28 02:39:19 +02:00
$reports = SS_Report::get_reports();
$reportNames = array();
foreach($reports as $report) {
$reportNames[] = $report->class;
}
$this->assertContains('BrokenExternalLinksReport',$reportNames,
'BrokenExternalLinksReport is in reports list');
}
}