PHPUnit proof of concept
This commit is contained in:
@ -1,78 +1,73 @@
|
||||
<?php
|
||||
# FIXME: web test
|
||||
class BBCodeTest extends ShimmieWebTestCase {}
|
||||
|
||||
if(!defined(VERSION)) return;
|
||||
|
||||
class BBCodeUnitTest extends UnitTestCase {
|
||||
class BBCodeTest extends ShimmiePHPUnitTestCase {
|
||||
public function testBasics() {
|
||||
$this->assertEqual(
|
||||
$this->assertEquals(
|
||||
$this->filter("[b]bold[/b][i]italic[/i]"),
|
||||
"<b>bold</b><i>italic</i>");
|
||||
}
|
||||
|
||||
public function testStacking() {
|
||||
$this->assertEqual(
|
||||
$this->assertEquals(
|
||||
$this->filter("[b]B[/b][i]I[/i][b]B[/b]"),
|
||||
"<b>B</b><i>I</i><b>B</b>");
|
||||
$this->assertEqual(
|
||||
$this->assertEquals(
|
||||
$this->filter("[b]bold[i]bolditalic[/i]bold[/b]"),
|
||||
"<b>bold<i>bolditalic</i>bold</b>");
|
||||
}
|
||||
|
||||
public function testFailure() {
|
||||
$this->assertEqual(
|
||||
$this->assertEquals(
|
||||
$this->filter("[b]bold[i]italic"),
|
||||
"[b]bold[i]italic");
|
||||
}
|
||||
|
||||
public function testCode() {
|
||||
$this->assertEqual(
|
||||
$this->assertEquals(
|
||||
$this->filter("[code][b]bold[/b][/code]"),
|
||||
"<pre>[b]bold[/b]</pre>");
|
||||
}
|
||||
|
||||
public function testNestedList() {
|
||||
$this->assertEqual(
|
||||
$this->assertEquals(
|
||||
$this->filter("[list][*]a[list][*]a[*]b[/list][*]b[/list]"),
|
||||
"<ul><li>a<ul><li>a<li>b</ul><li>b</ul>");
|
||||
$this->assertEqual(
|
||||
$this->assertEquals(
|
||||
$this->filter("[ul][*]a[ol][*]a[*]b[/ol][*]b[/ul]"),
|
||||
"<ul><li>a<ol><li>a<li>b</ol><li>b</ul>");
|
||||
}
|
||||
|
||||
public function testSpoiler() {
|
||||
$this->assertEqual(
|
||||
$this->assertEquals(
|
||||
$this->filter("[spoiler]ShishNet[/spoiler]"),
|
||||
"<span style=\"background-color:#000; color:#000;\">ShishNet</span>");
|
||||
$this->assertEqual(
|
||||
$this->assertEquals(
|
||||
$this->strip("[spoiler]ShishNet[/spoiler]"),
|
||||
"FuvfuArg");
|
||||
#$this->assertEqual(
|
||||
#$this->assertEquals(
|
||||
# $this->filter("[spoiler]ShishNet"),
|
||||
# "[spoiler]ShishNet");
|
||||
}
|
||||
|
||||
public function testURL() {
|
||||
$this->assertEqual(
|
||||
$this->assertEquals(
|
||||
$this->filter("[url]http://shishnet.org[/url]"),
|
||||
"<a href=\"http://shishnet.org\">http://shishnet.org</a>");
|
||||
$this->assertEqual(
|
||||
$this->assertEquals(
|
||||
$this->filter("[url=http://shishnet.org]ShishNet[/url]"),
|
||||
"<a href=\"http://shishnet.org\">ShishNet</a>");
|
||||
$this->assertEqual(
|
||||
$this->assertEquals(
|
||||
$this->filter("[url=javascript:alert(\"owned\")]click to fail[/url]"),
|
||||
"[url=javascript:alert(\"owned\")]click to fail[/url]");
|
||||
}
|
||||
|
||||
public function testEmailURL() {
|
||||
$this->assertEqual(
|
||||
$this->assertEquals(
|
||||
$this->filter("[email]spam@shishnet.org[/email]"),
|
||||
"<a href=\"mailto:spam@shishnet.org\">spam@shishnet.org</a>");
|
||||
}
|
||||
|
||||
public function testAnchor() {
|
||||
$this->assertEqual(
|
||||
$this->assertEquals(
|
||||
$this->filter("[anchor=rules]Rules[/anchor]"),
|
||||
'<span class="anchor">Rules <a class="alink" href="#bb-rules" name="bb-rules" title="link to this anchor"> ¶ </a></span>');
|
||||
}
|
||||
|
Reference in New Issue
Block a user