setValue('Un-enclosed Content'); $editor->saveInto($sitetree); $this->assertEquals('
Un-enclosed Content
', $sitetree->Content, 'Un-enclosed content is put in p tags.'); $editor->setValue('Simple Content
'); $editor->saveInto($sitetree); $this->assertEquals('Simple Content
', $sitetree->Content, 'Attributes are preserved.'); $editor->setValue('Unclosed Tag'); $editor->saveInto($sitetree); $this->assertEquals('
Unclosed Tag
', $sitetree->Content, 'Unclosed tags are closed.'); } public function testNullSaving() { $sitetree = new SiteTree(); $editor = new HtmlEditorField('Content'); $editor->setValue(null); $editor->saveInto($sitetree); $this->assertEquals('', $sitetree->Content, 'Doesn\'t choke on null values.'); } public function testLinkTracking() { $sitetree = $this->objFromFixture('SiteTree', 'home'); $editor = new HtmlEditorField('Content'); $aboutID = $this->idFromFixture('SiteTree', 'about'); $contactID = $this->idFromFixture('SiteTree', 'contact'); $editor->setValue("Example Link"); $editor->saveInto($sitetree); $this->assertEquals(array($aboutID => $aboutID), $sitetree->LinkTracking()->getIdList(), 'Basic link tracking works.'); $editor->setValue ( "" ); $editor->saveInto($sitetree); $this->assertEquals ( array($aboutID => $aboutID, $contactID => $contactID), $sitetree->LinkTracking()->getIdList(), 'Tracking works on multiple links' ); $editor->setValue(null); $editor->saveInto($sitetree); $this->assertEquals(array(), $sitetree->LinkTracking()->getIdList(), 'Link tracking is removed when links are.'); } public function testFileLinkTracking() { $sitetree = $this->objFromFixture('SiteTree', 'home'); $editor = new HtmlEditorField('Content'); $fileID = $this->idFromFixture('File', 'example_file'); $editor->setValue('Example File'); $editor->saveInto($sitetree); $this->assertEquals ( array($fileID => $fileID), $sitetree->ImageTracking()->getIDList(), 'Links to assets are tracked.' ); $editor->setValue(null); $editor->saveInto($sitetree); $this->assertEquals(array(), $sitetree->ImageTracking()->getIdList(), 'Asset tracking is removed with links.'); } public function testImageInsertion() { $sitetree = new SiteTree(); $editor = new HtmlEditorField('Content'); $editor->setValue('First Paragraph
\n\nSecond Paragraph
"); $editor->saveInto($sitetree); $this->assertEquals("First Paragraph
\n\nSecond Paragraph
", $sitetree->Content); } }