2014-07-28 02:39:19 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class ExternalLinks extends FunctionalTest {
|
|
|
|
|
|
|
|
protected static $fixture_file = 'ExternalLinksTest.yml';
|
|
|
|
|
2014-07-31 06:49:20 +02:00
|
|
|
public function testLinks() {
|
2014-07-28 02:39:19 +02:00
|
|
|
// uses http://127.0.0.1 to test a working link
|
2014-07-31 06:49:20 +02:00
|
|
|
$working = $this->objFromFixture('SiteTree', 'working');
|
2014-08-04 07:38:28 +02:00
|
|
|
$working->write();
|
2014-07-28 02:39:19 +02:00
|
|
|
$task = new CheckExternalLinks();
|
2014-07-31 06:49:20 +02:00
|
|
|
$task->run(null);
|
2014-08-04 02:30:08 +02:00
|
|
|
$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
|
2014-07-31 06:49:20 +02:00
|
|
|
$broken = $this->objFromFixture('SiteTree', 'broken');
|
2014-08-04 07:38:28 +02:00
|
|
|
$broken->write();
|
2014-07-28 02:39:19 +02:00
|
|
|
$task = new CheckExternalLinks();
|
2014-07-31 06:49:20 +02:00
|
|
|
$task->run(null);
|
|
|
|
$brokenLinks = BrokenExternalLink::get();
|
2014-07-28 02:39:19 +02:00
|
|
|
$this->assertEquals(1, $brokenLinks->count());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testReportExists() {
|
2014-07-31 06:49:20 +02:00
|
|
|
$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');
|
|
|
|
}
|
|
|
|
}
|
2014-07-31 06:49:20 +02:00
|
|
|
|