aboutsummaryrefslogtreecommitdiffstats
path: root/tests/text_formatter/s9e
diff options
context:
space:
mode:
Diffstat (limited to 'tests/text_formatter/s9e')
-rw-r--r--tests/text_formatter/s9e/acp_utils_test.php79
-rw-r--r--tests/text_formatter/s9e/factory_test.php4
-rw-r--r--tests/text_formatter/s9e/parser_test.php6
-rw-r--r--tests/text_formatter/s9e/renderer_test.php10
4 files changed, 89 insertions, 10 deletions
diff --git a/tests/text_formatter/s9e/acp_utils_test.php b/tests/text_formatter/s9e/acp_utils_test.php
new file mode 100644
index 0000000000..9d84924042
--- /dev/null
+++ b/tests/text_formatter/s9e/acp_utils_test.php
@@ -0,0 +1,79 @@
+<?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_textformatter_s9e_acp_utils_test extends phpbb_test_case
+{
+ /**
+ * @dataProvider get_analyse_bbcode_tests
+ */
+ public function test_analyse_bbcode($definition, $template, $expected)
+ {
+ $container = $this->get_test_case_helpers()->set_s9e_services();
+ $factory = $container->get('text_formatter.s9e.factory');
+ $acp_utils = new \phpbb\textformatter\s9e\acp_utils($factory);
+ $actual = $acp_utils->analyse_bbcode($definition, $template);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ public function get_analyse_bbcode_tests()
+ {
+ return [
+ [
+ '[x]{TEXT}[/x]',
+ '<b>{TEXT}</b>',
+ [
+ 'status' => 'safe',
+ 'name' => 'X'
+ ]
+ ],
+ [
+ '[hr]',
+ '<hr>',
+ [
+ 'status' => 'safe',
+ 'name' => 'HR'
+ ]
+ ],
+ [
+ '[x]{TEXT}[/x]',
+ '<script>{TEXT}</script>',
+ [
+ 'status' => 'unsafe',
+ 'name' => 'X',
+ 'error_text' => 'Cannot allow unfiltered data in this context',
+ 'error_html' => '&lt;script&gt;
+ <span class="highlight">&lt;xsl:apply-templates/&gt;</span>
+&lt;/script&gt;'
+ ]
+ ],
+ [
+ '???',
+ '<hr>',
+ [
+ 'status' => 'invalid_definition',
+ 'error_text' => 'Cannot interpret the BBCode definition'
+ ]
+ ],
+ [
+ '[x]{TEXT}[/x]',
+ '<xsl:invalid',
+ [
+ 'status' => 'invalid_template',
+ 'name' => 'X',
+ 'error_text' => "Invalid XSL: Couldn't find end of Start Tag invalid line 1\n"
+ ]
+ ],
+ ];
+ }
+}
diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php
index 0d780a19a9..d3be7d2fb4 100644
--- a/tests/text_formatter/s9e/factory_test.php
+++ b/tests/text_formatter/s9e/factory_test.php
@@ -15,7 +15,7 @@ require_once __DIR__ . '/../../test_framework/phpbb_database_test_case.php';
class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
{
- public function setUp()
+ public function setUp(): void
{
$this->cache = new phpbb_mock_cache;
$this->dispatcher = new phpbb_mock_event_dispatcher;
@@ -286,7 +286,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
*/
public function test_configure_events()
{
- $this->dispatcher = $this->getMock('phpbb\\event\\dispatcher_interface');
+ $this->dispatcher = $this->createMock('phpbb\\event\\dispatcher_interface');
$this->dispatcher
->expects($this->at(0))
->method('trigger_event')
diff --git a/tests/text_formatter/s9e/parser_test.php b/tests/text_formatter/s9e/parser_test.php
index 4b9bbf9bb2..e10ebd29ee 100644
--- a/tests/text_formatter/s9e/parser_test.php
+++ b/tests/text_formatter/s9e/parser_test.php
@@ -19,7 +19,7 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case
->disableOriginalConstructor()
->getMock();
- $cache = $this->getMock('phpbb_mock_cache');
+ $cache = $this->createMock('phpbb_mock_cache');
$cache->expects($this->once())
->method('get')
->with('_foo_parser')
@@ -172,7 +172,7 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case
public function test_setup_event()
{
$container = $this->get_test_case_helpers()->set_s9e_services();
- $dispatcher = $this->getMock('phpbb\\event\\dispatcher_interface');
+ $dispatcher = $this->createMock('phpbb\\event\\dispatcher_interface');
$dispatcher
->expects($this->once())
->method('trigger_event')
@@ -202,7 +202,7 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case
public function test_parse_event()
{
$container = $this->get_test_case_helpers()->set_s9e_services();
- $dispatcher = $this->getMock('phpbb\\event\\dispatcher_interface');
+ $dispatcher = $this->createMock('phpbb\\event\\dispatcher_interface');
$dispatcher
->expects($this->any())
->method('trigger_event')
diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php
index 175b90fdc7..672069590a 100644
--- a/tests/text_formatter/s9e/renderer_test.php
+++ b/tests/text_formatter/s9e/renderer_test.php
@@ -26,7 +26,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
'<?php class renderer_foo { public function setParameter() {} }'
);
- $cache = $this->getMock('phpbb_mock_cache');
+ $cache = $this->createMock('phpbb_mock_cache');
$cache->expects($this->once())
->method('get')
->with('_foo_renderer')
@@ -50,7 +50,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
{
$mock = $this->getMockForAbstractClass('s9e\\TextFormatter\\Renderer');
- $cache = $this->getMock('phpbb_mock_cache');
+ $cache = $this->createMock('phpbb_mock_cache');
$cache->expects($this->once())
->method('get')
->with('_foo_renderer')
@@ -197,7 +197,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
$config = new \phpbb\config\config(array('allow_nocensors' => true));
- $auth = $test->getMock('phpbb\\auth\\auth');
+ $auth = $test->createMock('phpbb\\auth\\auth');
$auth->expects($test->any())
->method('acl_get')
->with('u_chgcensors')
@@ -393,7 +393,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
public function test_setup_event()
{
$container = $this->get_test_case_helpers()->set_s9e_services();
- $dispatcher = $this->getMock('phpbb\\event\\dispatcher_interface');
+ $dispatcher = $this->createMock('phpbb\\event\\dispatcher_interface');
$dispatcher
->expects($this->once())
->method('trigger_event')
@@ -424,7 +424,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
public function test_render_event()
{
$container = $this->get_test_case_helpers()->set_s9e_services();
- $dispatcher = $this->getMock('phpbb\\event\\dispatcher_interface');
+ $dispatcher = $this->createMock('phpbb\\event\\dispatcher_interface');
$dispatcher
->expects($this->any())
->method('trigger_event')