aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/di/ordered_service_collection_test.php51
-rw-r--r--tests/di/service_collection_test.php47
-rw-r--r--tests/text_formatter/s9e/default_formatting_test.php11
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-10989.html2
-rw-r--r--tests/text_reparser/plugins/fixtures/forums.xml22
-rw-r--r--tests/text_reparser/plugins/fixtures/groups.xml8
-rw-r--r--tests/text_reparser/plugins/fixtures/poll_options.xml60
-rw-r--r--tests/text_reparser/plugins/fixtures/polls.xml40
-rw-r--r--tests/text_reparser/plugins/poll_option_test.php17
9 files changed, 247 insertions, 11 deletions
diff --git a/tests/di/ordered_service_collection_test.php b/tests/di/ordered_service_collection_test.php
new file mode 100644
index 0000000000..47e6d23744
--- /dev/null
+++ b/tests/di/ordered_service_collection_test.php
@@ -0,0 +1,51 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+class phpbb_ordered_service_collection_test extends \phpbb_test_case
+{
+ /**
+ * @var \phpbb\di\ordered_service_collection
+ */
+ protected $service_collection;
+
+ public function setUp()
+ {
+ $container = new phpbb_mock_container_builder();
+ $container->set('foo', new StdClass);
+ $container->set('bar', new StdClass);
+ $container->set('foobar', new StdClass);
+ $container->set('barfoo', new StdClass);
+
+ $this->service_collection = new \phpbb\di\ordered_service_collection($container);
+ $this->service_collection->add('foo', 7);
+ $this->service_collection->add('bar', 3);
+ $this->service_collection->add('barfoo', 5);
+ $this->service_collection->add('foobar', 2);
+
+ parent::setUp();
+ }
+
+ public function test_service_collection()
+ {
+ $service_names = array();
+
+ // Test the iterator
+ foreach ($this->service_collection as $name => $service)
+ {
+ $service_names[] = $name;
+ $this->assertInstanceOf('StdClass', $service);
+ }
+
+ $this->assertSame(array('foobar', 'bar', 'barfoo', 'foo'), $service_names);
+ }
+}
diff --git a/tests/di/service_collection_test.php b/tests/di/service_collection_test.php
new file mode 100644
index 0000000000..5b51254a4a
--- /dev/null
+++ b/tests/di/service_collection_test.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+class phpbb_service_collection_test extends \phpbb_test_case
+{
+ /**
+ * @var \phpbb\di\service_collection
+ */
+ protected $service_collection;
+
+ public function setUp()
+ {
+ $container = new phpbb_mock_container_builder();
+ $container->set('foo', new StdClass);
+ $container->set('bar', new StdClass);
+
+ $this->service_collection = new \phpbb\di\service_collection($container);
+ $this->service_collection->add('foo');
+ $this->service_collection->add('bar');
+
+ parent::setUp();
+ }
+
+ public function test_service_collection()
+ {
+ $service_names = array();
+
+ // Test the iterator
+ foreach ($this->service_collection as $name => $service)
+ {
+ $service_names[] = $name;
+ $this->assertInstanceOf('StdClass', $service);
+ }
+
+ $this->assertSame(array('foo', 'bar'), $service_names);
+ }
+}
diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php
index 40bec9ceee..c67976301f 100644
--- a/tests/text_formatter/s9e/default_formatting_test.php
+++ b/tests/text_formatter/s9e/default_formatting_test.php
@@ -15,6 +15,17 @@ require_once __DIR__ . '/../../../phpBB/includes/functions_content.php';
class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case
{
+ public function test_bbcode_code_lang_is_saved()
+ {
+ $container = $this->get_test_case_helpers()->set_s9e_services();
+ $parser = $container->get('text_formatter.parser');
+
+ $original = '[code]...[/code][code=php]...[/code]';
+ $expected = '<r><CODE><s>[code]</s>...<e>[/code]</e></CODE><CODE lang="php"><s>[code=php]</s>...<e>[/code]</e></CODE></r>';
+
+ $this->assertXmlStringEqualsXmlString($expected, $parser->parse($original));
+ }
+
/**
* @dataProvider get_default_formatting_tests
*/
diff --git a/tests/text_processing/tickets_data/PHPBB3-10989.html b/tests/text_processing/tickets_data/PHPBB3-10989.html
index f003ad3dfa..cd24df60e5 100644
--- a/tests/text_processing/tickets_data/PHPBB3-10989.html
+++ b/tests/text_processing/tickets_data/PHPBB3-10989.html
@@ -1,6 +1,6 @@
<blockquote><div><cite>Lorem wrote:</cite>[quote="Lorem"<blockquote class="uncited"><div> Suspendisse iaculis porta tempor. Nulla.</div></blockquote>
Nullam a tortor sit amet.</div></blockquote>
- Proin ac mi eget magna.
+ Proin ac mi eget magna.<br>
<blockquote><div><cite>Lorem wrote:</cite>Quisque fermentum tortor quis odio scelerisque consequat fermentum urna gravida. In semper vehicula condimentum. Donec suscipit ante imperdiet augue rhoncus.</div></blockquote>
diff --git a/tests/text_reparser/plugins/fixtures/forums.xml b/tests/text_reparser/plugins/fixtures/forums.xml
index 39c172c969..c12c8d6d48 100644
--- a/tests/text_reparser/plugins/fixtures/forums.xml
+++ b/tests/text_reparser/plugins/fixtures/forums.xml
@@ -5,87 +5,109 @@
<column>forum_parents</column>
<column>forum_desc</column>
<column>forum_desc_uid</column>
+ <column>forum_desc_options</column>
<column>forum_rules</column>
<column>forum_rules_uid</column>
+ <column>forum_rules_options</column>
<row>
<value>1</value>
<value></value>
<value>This row should be [b]ignored[/b]</value>
<value>abcd1234</value>
+ <value>0</value>
<value>This row should be [b]ignored[/b]</value>
<value>abcd1234</value>
+ <value>0</value>
</row>
<row>
<value>2</value>
<value></value>
<value>[b]Not bold[/b] :) http://example.org</value>
<value>abcd1234</value>
+ <value>0</value>
<value>[b]Not bold[/b] :) http://example.org</value>
<value>abcd1234</value>
+ <value>0</value>
</row>
<row>
<value>3</value>
<value></value>
<value>[b:abcd1234]Bold[/b:abcd1234] :) http://example.org</value>
<value>abcd1234</value>
+ <value>1</value>
<value>[b:abcd1234]Bold[/b:abcd1234] :) http://example.org</value>
<value>abcd1234</value>
+ <value>1</value>
</row>
<row>
<value>4</value>
<value></value>
<value><![CDATA[[b]Not bold[/b] <!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) --> http://example.org]]></value>
<value>abcd1234</value>
+ <value>2</value>
<value><![CDATA[[b]Not bold[/b] <!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) --> http://example.org]]></value>
<value>abcd1234</value>
+ <value>2</value>
</row>
<row>
<value>5</value>
<value></value>
<value><![CDATA[[b]Not bold[/b] :) <!-- m --><a class="postlink" href="http://example.org">http://example.org</a><!-- m -->]]></value>
<value>abcd1234</value>
+ <value>4</value>
<value><![CDATA[[b]Not bold[/b] :) <!-- m --><a class="postlink" href="http://example.org">http://example.org</a><!-- m -->]]></value>
<value>abcd1234</value>
+ <value>4</value>
</row>
<row>
<value>6</value>
<value></value>
<value><![CDATA[[flash=123,345:abcd1234]http&#58;//example&#46;org/flash&#46;swf[/flash:abcd1234]]]></value>
<value>abcd1234</value>
+ <value>1</value>
<value><![CDATA[[flash=123,345:abcd1234]http&#58;//example&#46;org/flash&#46;swf[/flash:abcd1234]]]></value>
<value>abcd1234</value>
+ <value>1</value>
</row>
<row>
<value>7</value>
<value></value>
<value><![CDATA[[flash=123,345]http://example.org/flash.swf[/flash]]]></value>
<value>abcd1234</value>
+ <value>0</value>
<value><![CDATA[[flash=123,345]http://example.org/flash.swf[/flash]]]></value>
<value>abcd1234</value>
+ <value>0</value>
</row>
<row>
<value>8</value>
<value></value>
<value><![CDATA[[img:abcd1234]http&#58;//example&#46;org/img&#46;png[/img:abcd1234]]]></value>
<value>abcd1234</value>
+ <value>1</value>
<value><![CDATA[[img:abcd1234]http&#58;//example&#46;org/img&#46;png[/img:abcd1234]]]></value>
<value>abcd1234</value>
+ <value>1</value>
</row>
<row>
<value>9</value>
<value></value>
<value><![CDATA[[img]http://example.org/img.png[/img]]]></value>
<value>abcd1234</value>
+ <value>0</value>
<value><![CDATA[[img]http://example.org/img.png[/img]]]></value>
<value>abcd1234</value>
+ <value>0</value>
</row>
<row>
<value>1000</value>
<value></value>
<value>This row should be [b]ignored[/b]</value>
<value>abcd1234</value>
+ <value>0</value>
<value>This row should be [b]ignored[/b]</value>
<value>abcd1234</value>
+ <value>0</value>
</row>
</table>
</dataset>
diff --git a/tests/text_reparser/plugins/fixtures/groups.xml b/tests/text_reparser/plugins/fixtures/groups.xml
index d3df0131a3..15151426bc 100644
--- a/tests/text_reparser/plugins/fixtures/groups.xml
+++ b/tests/text_reparser/plugins/fixtures/groups.xml
@@ -38,25 +38,25 @@
<row>
<value>6</value>
<value><![CDATA[[flash=123,345:abcd1234]http&#58;//example&#46;org/flash&#46;swf[/flash:abcd1234]]]></value>
- <value>7</value>
+ <value>1</value>
<value>abcd1234</value>
</row>
<row>
<value>7</value>
<value><![CDATA[[flash=123,345]http://example.org/flash.swf[/flash]]]></value>
- <value>7</value>
+ <value>1</value>
<value>abcd1234</value>
</row>
<row>
<value>8</value>
<value><![CDATA[[img:abcd1234]http&#58;//example&#46;org/img&#46;png[/img:abcd1234]]]></value>
- <value>7</value>
+ <value>1</value>
<value>abcd1234</value>
</row>
<row>
<value>9</value>
<value><![CDATA[[img]http://example.org/img.png[/img]]]></value>
- <value>7</value>
+ <value>1</value>
<value>abcd1234</value>
</row>
<row>
diff --git a/tests/text_reparser/plugins/fixtures/poll_options.xml b/tests/text_reparser/plugins/fixtures/poll_options.xml
index c2fad9f764..48ba024315 100644
--- a/tests/text_reparser/plugins/fixtures/poll_options.xml
+++ b/tests/text_reparser/plugins/fixtures/poll_options.xml
@@ -31,6 +31,21 @@
</row>
<row>
<value>1</value>
+ <value>11</value>
+ <value>[b:abcd1234]Bold[/b:abcd1234] :) http://example.org</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>12</value>
+ <value><![CDATA[[b]Not bold[/b] <!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) --> http://example.org]]></value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>13</value>
+ <value><![CDATA[[b]Not bold[/b] :) <!-- m --><a class="postlink" href="http://example.org">http://example.org</a><!-- m -->]]></value>
+ </row>
+ <row>
+ <value>1</value>
<value>123</value>
<value>This row should be [b]ignored[/b]</value>
</row>
@@ -42,10 +57,40 @@
</table>
<table name="phpbb_posts">
<column>post_id</column>
+ <column>enable_bbcode</column>
+ <column>enable_smilies</column>
+ <column>enable_magic_url</column>
<column>post_text</column>
<column>bbcode_uid</column>
<row>
<value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>11</value>
+ <value>1</value>
+ <value>0</value>
+ <value>0</value>
+ <value></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>12</value>
+ <value>0</value>
+ <value>1</value>
+ <value>0</value>
+ <value></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>13</value>
+ <value>0</value>
+ <value>0</value>
+ <value>1</value>
<value></value>
<value>abcd1234</value>
</row>
@@ -65,6 +110,21 @@
<value>This row should be [b]ignored[/b]</value>
</row>
<row>
+ <value>11</value>
+ <value>11</value>
+ <value>BBCode</value>
+ </row>
+ <row>
+ <value>12</value>
+ <value>12</value>
+ <value>Smilies</value>
+ </row>
+ <row>
+ <value>13</value>
+ <value>13</value>
+ <value>Magic URLs</value>
+ </row>
+ <row>
<value>123</value>
<value>1</value>
<value>This row should be [b]ignored[/b]</value>
diff --git a/tests/text_reparser/plugins/fixtures/polls.xml b/tests/text_reparser/plugins/fixtures/polls.xml
index 9baf813c97..2960d640a9 100644
--- a/tests/text_reparser/plugins/fixtures/polls.xml
+++ b/tests/text_reparser/plugins/fixtures/polls.xml
@@ -2,10 +2,40 @@
<dataset>
<table name="phpbb_posts">
<column>post_id</column>
+ <column>enable_bbcode</column>
+ <column>enable_smilies</column>
+ <column>enable_magic_url</column>
<column>post_text</column>
<column>bbcode_uid</column>
<row>
<value>1</value>
+ <value>0</value>
+ <value>0</value>
+ <value>0</value>
+ <value></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>1</value>
+ <value>0</value>
+ <value>0</value>
+ <value></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>0</value>
+ <value>1</value>
+ <value>0</value>
+ <value></value>
+ <value>abcd1234</value>
+ </row>
+ <row>
+ <value>4</value>
+ <value>0</value>
+ <value>0</value>
+ <value>1</value>
<value></value>
<value>abcd1234</value>
</row>
@@ -26,22 +56,22 @@
</row>
<row>
<value>3</value>
- <value>1</value>
+ <value>2</value>
<value>[b:abcd1234]Bold[/b:abcd1234] :) http://example.org</value>
</row>
<row>
<value>4</value>
- <value>1</value>
+ <value>3</value>
<value><![CDATA[[b]Not bold[/b] <!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) --> http://example.org]]></value>
</row>
<row>
<value>5</value>
- <value>1</value>
+ <value>4</value>
<value><![CDATA[[b]Not bold[/b] :) <!-- m --><a class="postlink" href="http://example.org">http://example.org</a><!-- m -->]]></value>
</row>
<row>
<value>6</value>
- <value>1</value>
+ <value>2</value>
<value><![CDATA[[flash=123,345:abcd1234]http&#58;//example&#46;org/flash&#46;swf[/flash:abcd1234]]]></value>
</row>
<row>
@@ -51,7 +81,7 @@
</row>
<row>
<value>8</value>
- <value>1</value>
+ <value>2</value>
<value><![CDATA[[img:abcd1234]http&#58;//example&#46;org/img&#46;png[/img:abcd1234]]]></value>
</row>
<row>
diff --git a/tests/text_reparser/plugins/poll_option_test.php b/tests/text_reparser/plugins/poll_option_test.php
index e043858597..acabda2146 100644
--- a/tests/text_reparser/plugins/poll_option_test.php
+++ b/tests/text_reparser/plugins/poll_option_test.php
@@ -49,7 +49,7 @@ class phpbb_textreparser_poll_option_test extends phpbb_database_test_case
public function testReparse()
{
$reparser = $this->get_reparser();
- $reparser->reparse_range(2, 3);
+ $reparser->reparse_range(2, 13);
$sql = 'SELECT topic_id, poll_option_id, poll_option_text
FROM ' . POLL_OPTIONS_TABLE . '
@@ -85,6 +85,21 @@ class phpbb_textreparser_poll_option_test extends phpbb_database_test_case
'poll_option_text' => '<r><URL url="http://example.org">http://example.org</URL></r>',
),
array(
+ 'topic_id' => 11,
+ 'poll_option_id' => 1,
+ 'poll_option_text' => '<r><B><s>[b]</s>Bold<e>[/b]</e></B> :) http://example.org</r>',
+ ),
+ array(
+ 'topic_id' => 12,
+ 'poll_option_id' => 1,
+ 'poll_option_text' => '<r>[b]Not bold[/b] <E>:)</E> http://example.org</r>',
+ ),
+ array(
+ 'topic_id' => 13,
+ 'poll_option_id' => 1,
+ 'poll_option_text' => '<r>[b]Not bold[/b] :) <URL url="http://example.org">http://example.org</URL></r>',
+ ),
+ array(
'topic_id' => 123,
'poll_option_id' => 1,
'poll_option_text' => 'This row should be [b]ignored[/b]',