Skip to content

Commit

Permalink
fix: test fix PurifiableBehavior/HtmlNotLimitedTest
Browse files Browse the repository at this point in the history
  • Loading branch information
akagane99 committed Nov 15, 2018
1 parent d15dd50 commit d7fd947
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions Test/Case/Model/Behavior/PurifiableBehavior/HtmlNotLimitedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ public function testSaveFrameTargets() {

// ezyang/htmlpurifier 4.9.2 からrel属性が追加されるようになったので、期待値を修正
// @see https://github.com/ezyang/htmlpurifier/commit/8e4cacf0a76458d6203f53113c47b49c6edc2dc5#diff-43adc2ea2ce8b37d29a16504aa8414b3
$expected = '<a href="#" target="_blank" rel="noopener">anchor</a>';
//$expected = '<a href="#" target="_blank" rel="noopener">anchor</a>';
// HtmlNotLimitedであれば、htmlpurifierのチェックは通さない
$expected = $content;

$this->assertEquals($expected, $result[$this->__modelName]['content']);
}
Expand All @@ -72,7 +74,11 @@ public function testSaveFrameTargetsRemove() {
$content = '<a href="#" target="_hoge">anchor</a>';
$data[$this->__modelName]['content'] = $content;
$result = $FakeModel->save($data);
$this->assertEquals('<a href="#">anchor</a>', $result[$this->__modelName]['content']);
// HtmlNotLimitedであれば、htmlpurifierのチェックは通さない
$expected = $content;

//$this->assertEquals('<a href="#">anchor</a>', $result[$this->__modelName]['content']);
$this->assertEquals($expected, $result[$this->__modelName]['content']);
}

/**
Expand All @@ -96,7 +102,11 @@ public function testSaveAllowedRelRemove() {
$content = '<a href="#" rel="hoge">anchor</a>';
$data[$this->__modelName]['content'] = $content;
$result = $FakeModel->save($data);
$this->assertEquals('<a href="#">anchor</a>', $result[$this->__modelName]['content']);
// HtmlNotLimitedであれば、htmlpurifierのチェックは通さない
$expected = $content;

//$this->assertEquals('<a href="#">anchor</a>', $result[$this->__modelName]['content']);
$this->assertEquals($expected, $result[$this->__modelName]['content']);
}

/**
Expand Down Expand Up @@ -139,9 +149,13 @@ public function testSaveHtmlNotLimitedScriptTag() {
$content = '<script type="text/javascript">alert("alert");</script>';
$data[$this->__modelName]['content'] = $content;
$result = $FakeModel->save($data);
$this->assertEquals('<script type="text/javascript"><!--//--><![CDATA[//><!--
alert("alert");
//--><!]]></script>', $result[$this->__modelName]['content']);
// HtmlNotLimitedであれば、htmlpurifierのチェックは通さない
$expected = $content;

// $this->assertEquals('<script type="text/javascript"><!--//--><![CDATA[//><!--
//alert("alert");
////--><!]]></script>', $result[$this->__modelName]['content']);
$this->assertEquals($expected, $result[$this->__modelName]['content']);
}

/**
Expand Down

0 comments on commit d7fd947

Please sign in to comment.