assertEquals(
$this->filter("[b]bold[/b][i]italic[/i]"),
"bolditalic");
}
public function testStacking() {
$this->assertEquals(
$this->filter("[b]B[/b][i]I[/i][b]B[/b]"),
"BIB");
$this->assertEquals(
$this->filter("[b]bold[i]bolditalic[/i]bold[/b]"),
"boldbolditalicbold");
}
public function testFailure() {
$this->assertEquals(
$this->filter("[b]bold[i]italic"),
"[b]bold[i]italic");
}
public function testCode() {
$this->assertEquals(
$this->filter("[code][b]bold[/b][/code]"),
"
[b]bold[/b]
");
}
public function testNestedList() {
$this->assertEquals(
$this->filter("[list][*]a[list][*]a[*]b[/list][*]b[/list]"),
"");
$this->assertEquals(
$this->filter("[ul][*]a[ol][*]a[*]b[/ol][*]b[/ul]"),
"");
}
public function testSpoiler() {
$this->assertEquals(
$this->filter("[spoiler]ShishNet[/spoiler]"),
"ShishNet");
$this->assertEquals(
$this->strip("[spoiler]ShishNet[/spoiler]"),
"FuvfuArg");
#$this->assertEquals(
# $this->filter("[spoiler]ShishNet"),
# "[spoiler]ShishNet");
}
public function testURL() {
$this->assertEquals(
$this->filter("[url]http://shishnet.org[/url]"),
"http://shishnet.org");
$this->assertEquals(
$this->filter("[url=http://shishnet.org]ShishNet[/url]"),
"ShishNet");
$this->assertEquals(
$this->filter("[url=javascript:alert(\"owned\")]click to fail[/url]"),
"[url=javascript:alert(\"owned\")]click to fail[/url]");
}
public function testEmailURL() {
$this->assertEquals(
$this->filter("[email]spam@shishnet.org[/email]"),
"spam@shishnet.org");
}
public function testAnchor() {
$this->assertEquals(
$this->filter("[anchor=rules]Rules[/anchor]"),
'Rules ΒΆ ');
}
private function filter($in) {
$bb = new BBCode();
return $bb->format($in);
}
private function strip($in) {
$bb = new BBCode();
return $bb->strip($in);
}
}