From a9ca976afd1297d212a117395425e0ce059ab2bc Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 25 Jan 2009 12:42:21 +0000 Subject: [PATCH] call assert() from the right place --- ext/bbcode/test.php | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/ext/bbcode/test.php b/ext/bbcode/test.php index 76c809c7..016a428d 100644 --- a/ext/bbcode/test.php +++ b/ext/bbcode/test.php @@ -1,45 +1,55 @@ template("[b]bold[/b][i]italic[/i]", "bolditalic"); + $this->assertEqual( + $this->filter("[b]bold[/b][i]italic[/i]"), + "bolditalic"); } public function testStacking() { - $this->template("[b]B[/b][i]I[/i][b]B[/b]", "BIB"); - $this->template("[b]bold[i]bolditalic[/i]bold[/b]", "boldbolditalicbold"); + $this->assertEqual( + $this->filter("[b]B[/b][i]I[/i][b]B[/b]"), + "BIB"); + $this->assertEqual( + $this->filter("[b]bold[i]bolditalic[/i]bold[/b]"), + "boldbolditalicbold"); } public function testFailure() { - $this->template("[b]bold[i]italic", "[b]bold[i]italic"); + $this->assertEqual( + $this->filter("[b]bold[i]italic"), + "[b]bold[i]italic"); } public function testCode() { - $this->template("[code][b]bold[/b][/code]", "
[b]bold[/b]
"); + $this->assertEqual( + $this->filter("[code][b]bold[/b][/code]"), + "
[b]bold[/b]
"); } public function testNestedList() { - $this->template( - "[list][*]a[list][*]a[*]b[/list][*]b[/list]", + $this->assertEqual( + $this->filter("[list][*]a[list][*]a[*]b[/list][*]b[/list]"), ""); } public function testURL() { - $this->template( - "[url]http://shishnet.org[/url]", + $this->assertEqual( + $this->filter("[url]http://shishnet.org[/url]"), "http://shishnet.org"); - $this->template( - "[url=http://shishnet.org]ShishNet[/url]", + $this->assertEqual( + $this->filter("[url=http://shishnet.org]ShishNet[/url]"), "ShishNet"); - $this->template( - "[url=javascript:alert(\"owned\")]click to fail[/url]", + $this->assertEqual( + $this->filter("[url=javascript:alert(\"owned\")]click to fail[/url]"), "[url=javascript:alert("owned")]click to fail[/url]"); } - private function template($in, $out) { - $bb = new BBCode(); + private function filter($in) { + $bb = new WordFilter(); $tfe = new TextFormattingEvent($in); $bb->receive_event($tfe); - $this->assertEqual($tfe->formatted, $out); + return $tfe->formatted; } } ?>