assertEqual( $this->filter("[b]bold[/b][i]italic[/i]"), "bolditalic"); } public function testStacking() { $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->assertEqual( $this->filter("[b]bold[i]italic"), "[b]bold[i]italic"); } public function testCode() { $this->assertEqual( $this->filter("[code][b]bold[/b][/code]"), "
[b]bold[/b]
"); } public function testNestedList() { $this->assertEqual( $this->filter("[list][*]a[list][*]a[*]b[/list][*]b[/list]"), ""); $this->assertEqual( $this->filter("[ul][*]a[ol][*]a[*]b[/ol][*]b[/ul]"), ""); } public function testSpoiler() { $this->assertEqual( $this->filter("[spoiler]ShishNet[/spoiler]"), "ShishNet"); $this->assertEqual( $this->strip("[spoiler]ShishNet[/spoiler]"), "FuvfuArg"); #$this->assertEqual( # $this->filter("[spoiler]ShishNet"), # "[spoiler]ShishNet"); } public function testURL() { $this->assertEqual( $this->filter("[url]http://shishnet.org[/url]"), "http://shishnet.org"); $this->assertEqual( $this->filter("[url=http://shishnet.org]ShishNet[/url]"), "ShishNet"); $this->assertEqual( $this->filter("[url=javascript:alert(\"owned\")]click to fail[/url]"), "[url=javascript:alert(\"owned\")]click to fail[/url]"); } public function testEmailURL() { $this->assertEqual( $this->filter("[email]spam@shishnet.org[/email]"), "spam@shishnet.org"); } private function filter($in) { $bb = new BBCode(); return $bb->format($in); } private function strip($in) { $bb = new BBCode(); return $bb->strip($in); } }