FIX Ensure that translatable cannot break tests. Separate page stub class. Remove injector nesting.
This commit is contained in:
parent
738ca1733e
commit
99d4a6ee1a
|
@ -5,9 +5,13 @@ class ExternalLinksTest extends SapphireTest {
|
||||||
protected static $fixture_file = 'ExternalLinksTest.yml';
|
protected static $fixture_file = 'ExternalLinksTest.yml';
|
||||||
|
|
||||||
protected $extraDataObjects = array(
|
protected $extraDataObjects = array(
|
||||||
'ExternalLinksTest_Page'
|
'ExternalLinksTestPage'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
protected $illegalExtensions = array(
|
||||||
|
'SiteTree' => array('Translatable')
|
||||||
|
);
|
||||||
|
|
||||||
public function setUpOnce() {
|
public function setUpOnce() {
|
||||||
if (class_exists('Phockito')) {
|
if (class_exists('Phockito')) {
|
||||||
Phockito::include_hamcrest(false);
|
Phockito::include_hamcrest(false);
|
||||||
|
@ -19,8 +23,6 @@ class ExternalLinksTest extends SapphireTest {
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
Injector::nest();
|
|
||||||
|
|
||||||
// Check dependencies
|
// Check dependencies
|
||||||
if (!class_exists('Phockito')) {
|
if (!class_exists('Phockito')) {
|
||||||
$this->skipTest = true;
|
$this->skipTest = true;
|
||||||
|
@ -72,11 +74,6 @@ class ExternalLinksTest extends SapphireTest {
|
||||||
Injector::inst()->registerService($checker, 'LinkChecker');
|
Injector::inst()->registerService($checker, 'LinkChecker');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown() {
|
|
||||||
Injector::unnest();
|
|
||||||
parent::tearDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testLinks() {
|
public function testLinks() {
|
||||||
// Run link checker
|
// Run link checker
|
||||||
$task = CheckExternalLinksTask::create();
|
$task = CheckExternalLinksTask::create();
|
||||||
|
@ -91,7 +88,7 @@ class ExternalLinksTest extends SapphireTest {
|
||||||
|
|
||||||
// Check all pages have had the correct HTML adjusted
|
// Check all pages have had the correct HTML adjusted
|
||||||
for($i = 1; $i <= 5; $i++) {
|
for($i = 1; $i <= 5; $i++) {
|
||||||
$page = $this->objFromFixture('ExternalLinksTest_Page', 'page'.$i);
|
$page = $this->objFromFixture('ExternalLinksTestPage', 'page'.$i);
|
||||||
$this->assertNotEmpty($page->Content);
|
$this->assertNotEmpty($page->Content);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$page->ExpectedContent,
|
$page->ExpectedContent,
|
||||||
|
@ -149,9 +146,3 @@ class ExternalLinksTest extends SapphireTest {
|
||||||
'BrokenExternalLinksReport is in reports list');
|
'BrokenExternalLinksReport is in reports list');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ExternalLinksTest_Page extends Page implements TestOnly {
|
|
||||||
private static $db = array(
|
|
||||||
'ExpectedContent' => 'HTMLText'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
ExternalLinksTest_Page:
|
ExternalLinksTestPage:
|
||||||
# Tests mix of broken and working external links
|
# Tests mix of broken and working external links
|
||||||
page1:
|
page1:
|
||||||
Title: 'Page 1'
|
Title: 'Page 1'
|
||||||
|
@ -18,7 +18,7 @@ ExternalLinksTest_Page:
|
||||||
Content: >
|
Content: >
|
||||||
<p><a href="http://www.broken.com/url/thing" class="ss-broken">Still Broken</a></p>
|
<p><a href="http://www.broken.com/url/thing" class="ss-broken">Still Broken</a></p>
|
||||||
ExpectedContent: >
|
ExpectedContent: >
|
||||||
<p><a href="http://www.broken.com/url/thing" class="ss-broken">Still Broken</a></p>
|
<p><a href="http://www.broken.com/url/thing" class="ss-broken">Still Broken</a></p>
|
||||||
# Tests internal broken links not marking a page as broken
|
# Tests internal broken links not marking a page as broken
|
||||||
page3:
|
page3:
|
||||||
Title: 'Page 3'
|
Title: 'Page 3'
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class ExternalLinksTestPage extends Page implements TestOnly
|
||||||
|
{
|
||||||
|
private static $db = array(
|
||||||
|
'ExpectedContent' => 'HTMLText'
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in New Issue