Permalink
Browse files

MINOR Fixed SiteTreeTest->testCompareVersions() to work regardless of…

… used HTMLCleaner implementation (was failing if lib_tidy wasn't available)
  • Loading branch information...
1 parent 842c38f commit 446b8bae6378ecddb5f01fff53a20ae60a64abf6 @chillu chillu committed Apr 6, 2011
Showing with 16 additions and 4 deletions.
  1. +16 −4 tests/model/SiteTreeTest.php
@@ -509,11 +509,18 @@ function testEditPermissionsOnDraftVsLive() {
}
function testCompareVersions() {
+ // Necessary to avoid
+ $oldCleanerClass = Diff::$html_cleaner_class;
+ Diff::$html_cleaner_class = 'SiteTreeTest_NullHtmlCleaner';
+
$page = new Page();
$page->write();
$this->assertEquals(1, $page->Version);
-
- $page->Content = "<p>This is a test</p>";
+
+ // Use inline element to avoid double wrapping applied to
+ // blocklevel elements depending on HTMLCleaner implementation:
+ // <ins><p> gets converted to <ins><p><inst>
+ $page->Content = "<span>This is a test</span>";
$page->write();
$this->assertEquals(2, $page->Version);
@@ -522,8 +529,9 @@ function testCompareVersions() {
$processedContent = trim($diff->Content);
$processedContent = preg_replace('/\s*</','<',$processedContent);
$processedContent = preg_replace('/>\s*/','>',$processedContent);
- $this->assertEquals("<ins><p><ins>This is a test</ins></p></ins>", $processedContent);
+ $this->assertEquals("<ins><span>This is a test</span></ins>", $processedContent);
+ Diff::$html_cleaner_class = $oldCleanerClass;
}
function testAuthorIDAndPublisherIDFilledOutOnPublish() {
@@ -759,4 +767,8 @@ public function hasActionTemplate($template) {
}
-/**#@-*/
+class SiteTreeTest_NullHtmlCleaner extends HTMLCleaner {
+ function cleanHTML($html) {
+ return $html;
+ }
+}

0 comments on commit 446b8ba

Please sign in to comment.