From 84174183aec60467e092cafefeeff3facae77c23 Mon Sep 17 00:00:00 2001
From: Christoph Burschka <christoph@burschka.de>
Date: Sun, 13 Dec 2015 20:04:23 +0100
Subject: [PATCH] Issue #2630676: Test basic filter operation.

Create a properly nested tag inside another tag,
check that the filter correctly parses and renders both.
---
 src/Tests/XBBCodeFilterTest.php | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/src/Tests/XBBCodeFilterTest.php b/src/Tests/XBBCodeFilterTest.php
index 72b4cb5..a11b6cd 100644
--- a/src/Tests/XBBCodeFilterTest.php
+++ b/src/Tests/XBBCodeFilterTest.php
@@ -99,4 +99,36 @@ class XBBCodeFilterTest extends KernelTestBase {
     $this->assertEqual($expected_markup, $markup);
   }
 
+  /**
+   * Test a few basic aspects of the filter.
+   */
+  public function testFilter() {
+    $string = [
+      $this->randomString(),
+      $this->randomString(),
+      $this->randomString(),
+      $this->randomString(),
+      $this->randomString(),
+    ];
+
+    $escaped = array_map(function($x) {
+      return SafeMarkup::checkPlain($x);
+    }, $string);
+
+    $key = [
+      $this->randomMachineName(),
+      $this->randomMachineName(),
+    ];
+
+    $text = "{$string[0]}[test_plugin {$key[0]}={$key[1]}]{$string[1]}"
+          . "[test_plugin {$key[1]}={$key[0]}]{$string[2]}[/test_plugin]"
+          . "{$string[3]}[/test_plugin]{$string[4]}";
+    $markup = check_markup($text, 'xbbcode_test');
+    $expected = "{$escaped[0]}<span data-{$key[0]}=\"{$key[1]}\">{$escaped[1]}"
+              . "<span data-{$key[1]}=\"{$key[0]}\">{$escaped[2]}</span>"
+              . "{$escaped[3]}</span>{$escaped[4]}";
+    $this->assertEqual($text, $text);
+    $this->assertEqual($expected, $markup);
+  }
+
 }
-- 
1.9.1

