mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR: Added tests for HtmlEditorField's broken link tracking and highlighting.
From: Andrew Short <andrewjshort@gmail.com> git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@88990 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
5adfc28a43
commit
ce2e4e7333
@ -132,4 +132,42 @@ class HtmlEditorFieldTest extends FunctionalTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testBrokenLinkTracking() {
|
||||||
|
$sitetree = new SiteTree();
|
||||||
|
$editor = new HtmlEditorField('Content');
|
||||||
|
|
||||||
|
$this->assertFalse((bool) $sitetree->HasBrokenLink);
|
||||||
|
|
||||||
|
$editor->setValue('<p><a href="[sitetree_link id=0]">Broken Link</a></p>');
|
||||||
|
$editor->saveInto($sitetree);
|
||||||
|
|
||||||
|
$this->assertTrue($sitetree->HasBrokenLink);
|
||||||
|
|
||||||
|
$editor->setValue(sprintf (
|
||||||
|
'<p><a href="[sitetree_link id=%d]">Working Link</a></p>',
|
||||||
|
$this->idFromFixture('SiteTree', 'home')
|
||||||
|
));
|
||||||
|
$editor->saveInto($sitetree);
|
||||||
|
|
||||||
|
$this->assertFalse((bool) $sitetree->HasBrokenLink);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testBrokenLinkHighlighting() {
|
||||||
|
$sitetree = new SiteTree();
|
||||||
|
$editor = new HtmlEditorField('Content');
|
||||||
|
|
||||||
|
$editor->setValue('<a href="[sitetree_link id=0]">Broken Link</a>');
|
||||||
|
|
||||||
|
$element = new SimpleXMLElement(html_entity_decode((string) new SimpleXMLElement($editor->Field())));
|
||||||
|
$this->assertContains('ss-broken', (string) $element['class'], 'A broken link class is added to broken links');
|
||||||
|
|
||||||
|
$editor->setValue(sprintf (
|
||||||
|
'<a href="[sitetree_link id=%d]">Working Link</a>',
|
||||||
|
$this->idFromFixture('SiteTree', 'home')
|
||||||
|
));
|
||||||
|
|
||||||
|
$element = new SimpleXMLElement(html_entity_decode((string) new SimpleXMLElement($editor->Field())));
|
||||||
|
$this->assertNotContains('ss-broken', (string) $element['class']);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user