mirror of
https://github.com/silverstripe/silverstripe-externallinks.git
synced 2024-10-22 17:05:44 +02:00
Merge pull request #23 from robbieaverill/pulls/translatable-conflict-in-test
FIX Ensure that translatable cannot break tests. Separate page stub class. Remove injector nesting.
This commit is contained in:
commit
ded3b7cd82
@ -5,9 +5,13 @@ class ExternalLinksTest extends SapphireTest {
|
||||
protected static $fixture_file = 'ExternalLinksTest.yml';
|
||||
|
||||
protected $extraDataObjects = array(
|
||||
'ExternalLinksTest_Page'
|
||||
'ExternalLinksTestPage'
|
||||
);
|
||||
|
||||
protected $illegalExtensions = array(
|
||||
'SiteTree' => array('Translatable')
|
||||
);
|
||||
|
||||
public function setUpOnce() {
|
||||
if (class_exists('Phockito')) {
|
||||
Phockito::include_hamcrest(false);
|
||||
@ -19,8 +23,6 @@ class ExternalLinksTest extends SapphireTest {
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
Injector::nest();
|
||||
|
||||
// Check dependencies
|
||||
if (!class_exists('Phockito')) {
|
||||
$this->skipTest = true;
|
||||
@ -72,11 +74,6 @@ class ExternalLinksTest extends SapphireTest {
|
||||
Injector::inst()->registerService($checker, 'LinkChecker');
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
Injector::unnest();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testLinks() {
|
||||
// Run link checker
|
||||
$task = CheckExternalLinksTask::create();
|
||||
@ -91,7 +88,7 @@ class ExternalLinksTest extends SapphireTest {
|
||||
|
||||
// Check all pages have had the correct HTML adjusted
|
||||
for($i = 1; $i <= 5; $i++) {
|
||||
$page = $this->objFromFixture('ExternalLinksTest_Page', 'page'.$i);
|
||||
$page = $this->objFromFixture('ExternalLinksTestPage', 'page'.$i);
|
||||
$this->assertNotEmpty($page->Content);
|
||||
$this->assertEquals(
|
||||
$page->ExpectedContent,
|
||||
@ -149,9 +146,3 @@ class ExternalLinksTest extends SapphireTest {
|
||||
'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
|
||||
page1:
|
||||
Title: 'Page 1'
|
||||
@ -18,7 +18,7 @@ ExternalLinksTest_Page:
|
||||
Content: >
|
||||
<p><a href="http://www.broken.com/url/thing" class="ss-broken">Still Broken</a></p>
|
||||
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
|
||||
page3:
|
||||
Title: 'Page 3'
|
||||
|
8
tests/ExternalLinksTestPage.php
Normal file
8
tests/ExternalLinksTestPage.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
class ExternalLinksTestPage extends Page implements TestOnly
|
||||
{
|
||||
private static $db = array(
|
||||
'ExpectedContent' => 'HTMLText'
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue
Block a user