diff --git a/tests/CompatibilityTest.php b/tests/CompatibilityTest.php new file mode 100644 index 0000000..4f58b78 --- /dev/null +++ b/tests/CompatibilityTest.php @@ -0,0 +1,53 @@ + + * @copyright 2009-2016 Vanilla Forums Inc. + * @license Proprietary + */ + +namespace Nbbc\Tests; + +use Nbbc\BBCode; + +/** + * Backwards compatibility testing for when new functionality is introduced. + */ +class CompatibilityTest extends \PHPUnit_Framework_TestCase { + /** + * Test that new templates work like old templates. + * + * @param string $source The BBCode to parse. + * @param string $expected The expected output. + * @dataProvider provideTemplateTests + */ + public function testTemplates($source, $expected) { + $bbcode = new BBCode(); + $bbcode->setDetectURLs(true); + $html = $bbcode->parse($source); + $this->assertSame($expected, $html); + } + + /** + * Provide tests for {@link testTemplates()}. + * + * @return array Returns a data provider. + */ + public function provideTemplateTests() { + $r = [ + 'url' => ['[url=foo.com]go[/url]', 'go'], + 'quote' => ['[quote=todd]This is you!!![/quote]', << +
todd wrote:
+
This is you!!!
+ + +EOT +], + 'wiki' => ['What [[the]] heck?', 'What the heck?'], + 'email' => ['Email todd@noreply.com', 'Email todd@noreply.com'], + ]; + + return $r; + } +}