From ce2e4e7333865563c4cc68b3b82263f169ad95c0 Mon Sep 17 00:00:00 2001 From: Andrew Short Date: Thu, 15 Oct 2009 00:02:05 +0000 Subject: [PATCH] MINOR: Added tests for HtmlEditorField's broken link tracking and highlighting. From: Andrew Short git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@88990 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- tests/forms/HtmlEditorFieldTest.php | 38 +++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/forms/HtmlEditorFieldTest.php b/tests/forms/HtmlEditorFieldTest.php index a52bde53d..ed510dbbe 100755 --- a/tests/forms/HtmlEditorFieldTest.php +++ b/tests/forms/HtmlEditorFieldTest.php @@ -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('

Broken Link

'); + $editor->saveInto($sitetree); + + $this->assertTrue($sitetree->HasBrokenLink); + + $editor->setValue(sprintf ( + '

Working Link

', + $this->idFromFixture('SiteTree', 'home') + )); + $editor->saveInto($sitetree); + + $this->assertFalse((bool) $sitetree->HasBrokenLink); + } + + public function testBrokenLinkHighlighting() { + $sitetree = new SiteTree(); + $editor = new HtmlEditorField('Content'); + + $editor->setValue('Broken Link'); + + $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 ( + 'Working Link', + $this->idFromFixture('SiteTree', 'home') + )); + + $element = new SimpleXMLElement(html_entity_decode((string) new SimpleXMLElement($editor->Field()))); + $this->assertNotContains('ss-broken', (string) $element['class']); + } + }