aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/group/helper_test.php68
-rw-r--r--tests/language/language_test.php14
-rw-r--r--tests/notification/fixtures/services_notification.yml3
-rw-r--r--tests/notification/group_request_test.php5
-rw-r--r--tests/text_formatter/s9e/default_formatting_test.php2
-rw-r--r--tests/text_formatter/s9e/fixtures/styles/bar/template/bbcode.html2
-rw-r--r--tests/text_formatter/s9e/fixtures/styles/barplus/template/bbcode.html2
-rw-r--r--tests/text_formatter/s9e/fixtures/styles/foo/template/bbcode.html2
-rw-r--r--tests/text_formatter/s9e/renderer_test.php4
-rw-r--r--tests/text_processing/generate_text_for_display_test.php2
-rw-r--r--tests/text_processing/tickets_data/PHPBB3-12195.html2
11 files changed, 98 insertions, 8 deletions
diff --git a/tests/group/helper_test.php b/tests/group/helper_test.php
new file mode 100644
index 0000000000..2377a6f47c
--- /dev/null
+++ b/tests/group/helper_test.php
@@ -0,0 +1,68 @@
+<?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_group_helper_test extends phpbb_test_case
+{
+ /** @var \phpbb\group\helper */
+ protected $group_helper;
+
+ public function setUp()
+ {
+ global $phpbb_root_path, $phpEx;
+
+ // Set up language service
+ $lang = new \phpbb\language\language(
+ new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)
+ );
+
+ // Set up language data for testing
+ $reflection_class = new ReflectionClass('\phpbb\language\language');
+
+ // Set default language files loaded flag to true
+ $loaded_flag = $reflection_class->getProperty('common_language_files_loaded');
+ $loaded_flag->setAccessible(true);
+ $loaded_flag->setValue($lang, true);
+
+ // Set up test language data
+ $lang_array = $reflection_class->getProperty('lang');
+ $lang_array->setAccessible(true);
+ $lang_array->setValue($lang, $this->get_test_language_data_set());
+
+ // Set up group helper
+ $this->group_helper = new \phpbb\group\helper($lang);
+ }
+
+ public function test_get_name()
+ {
+ // They should be totally fine
+ $this->assertEquals('Bots', $this->group_helper->get_name('Bots'));
+ $this->assertEquals('Some new group', $this->group_helper->get_name('new_group'));
+ $this->assertEquals('Should work', $this->group_helper->get_name('group_with_ümlauts'));
+
+ // This should fail (obviously)
+ $this->assertNotEquals('They key does not contain uppercase letters', $this->group_helper->get_name('not_uppercase'));
+
+ // The key doesn't exist so just return group name...
+ $this->assertEquals('Awesome group', $this->group_helper->get_name('Awesome group'));
+ }
+
+ protected function get_test_language_data_set()
+ {
+ return array(
+ 'G_BOTS' => 'Bots',
+ 'G_NEW_GROUP' => 'Some new group',
+ 'G_not_uppercase' => 'The key does not contain uppercase letters',
+ 'G_GROUP_WITH_ÜMLAUTS' => 'Should work',
+ );
+ }
+}
diff --git a/tests/language/language_test.php b/tests/language/language_test.php
index 95de403bd4..6a814e39dc 100644
--- a/tests/language/language_test.php
+++ b/tests/language/language_test.php
@@ -39,6 +39,20 @@ class phpbb_language_test extends phpbb_test_case
$lang_array->setValue($this->lang, $this->get_test_data_set());
}
+ public function test_is_set()
+ {
+ // Check for non-existing key
+ $this->assertFalse($this->lang->is_set('VALUE'));
+ $this->assertFalse($this->lang->is_set(array('dateformat', 'MAYBE')));
+
+ // Check for existing key
+ $this->assertTrue($this->lang->is_set('FOO'));
+ $this->assertTrue($this->lang->is_set(array('dateformat', 'AGO')));
+
+ // Array doesn't exist at all...
+ $this->assertFalse($this->lang->is_set(array('PHPBB', 'PHP')));
+ }
+
public function test_lang()
{
// No param
diff --git a/tests/notification/fixtures/services_notification.yml b/tests/notification/fixtures/services_notification.yml
index 7eaa7e81ec..e0a404b12b 100644
--- a/tests/notification/fixtures/services_notification.yml
+++ b/tests/notification/fixtures/services_notification.yml
@@ -23,6 +23,9 @@ services:
cache.driver:
synthetic: true
+ group_helper:
+ synthetic: true
+
path_helper:
synthetic: true
diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php
index a24808fbbd..d16e198861 100644
--- a/tests/notification/group_request_test.php
+++ b/tests/notification/group_request_test.php
@@ -49,6 +49,11 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas
$this->user,
$this->cache->get_driver()
));
+ $this->container->set('group_helper', new \phpbb\group\helper(
+ new \phpbb\language\language(
+ new phpbb\language\language_file_loader($phpbb_root_path, $phpEx)
+ )
+ ));
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
$phpbb_log = new \phpbb\log\dummy();
$this->get_test_case_helpers()->set_s9e_services();
diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php
index 390bc65264..3047653d51 100644
--- a/tests/text_formatter/s9e/default_formatting_test.php
+++ b/tests/text_formatter/s9e/default_formatting_test.php
@@ -132,7 +132,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case
),
array(
'[img]https://area51.phpbb.com/images/area51.png[/img]',
- '<img src="https://area51.phpbb.com/images/area51.png" alt="Image">'
+ '<img src="https://area51.phpbb.com/images/area51.png" class="postimage" alt="Image">'
),
array(
'[url]https://area51.phpbb.com/[/url]',
diff --git a/tests/text_formatter/s9e/fixtures/styles/bar/template/bbcode.html b/tests/text_formatter/s9e/fixtures/styles/bar/template/bbcode.html
index a17446581a..76a35542be 100644
--- a/tests/text_formatter/s9e/fixtures/styles/bar/template/bbcode.html
+++ b/tests/text_formatter/s9e/fixtures/styles/bar/template/bbcode.html
@@ -31,7 +31,7 @@
<!-- BEGIN size --><span style="font-size: {SIZE}%; line-height: 116%;">{TEXT}</span><!-- END size -->
-<!-- BEGIN img --><img src="{URL}" alt="{L_IMAGE}" /><!-- END img -->
+<!-- BEGIN img --><img src="{URL}" class="postimage" alt="{L_IMAGE}" /><!-- END img -->
<!-- BEGIN url --><a href="{URL}" class="postlink">{DESCRIPTION}</a><!-- END url -->
diff --git a/tests/text_formatter/s9e/fixtures/styles/barplus/template/bbcode.html b/tests/text_formatter/s9e/fixtures/styles/barplus/template/bbcode.html
index cd2f0acae3..fad8d828fd 100644
--- a/tests/text_formatter/s9e/fixtures/styles/barplus/template/bbcode.html
+++ b/tests/text_formatter/s9e/fixtures/styles/barplus/template/bbcode.html
@@ -31,7 +31,7 @@
<!-- BEGIN size --><span style="font-size: {SIZE}%; line-height: 116%;">{TEXT}</span><!-- END size -->
-<!-- BEGIN img --><img src="{URL}" alt="{L_IMAGE}" /><!-- END img -->
+<!-- BEGIN img --><img src="{URL}" class="postimage" alt="{L_IMAGE}" /><!-- END img -->
<!-- BEGIN url --><a href="{URL}" class="postlink">{DESCRIPTION}</a><!-- END url -->
diff --git a/tests/text_formatter/s9e/fixtures/styles/foo/template/bbcode.html b/tests/text_formatter/s9e/fixtures/styles/foo/template/bbcode.html
index 909c09df5a..3e38d13a32 100644
--- a/tests/text_formatter/s9e/fixtures/styles/foo/template/bbcode.html
+++ b/tests/text_formatter/s9e/fixtures/styles/foo/template/bbcode.html
@@ -31,7 +31,7 @@
<!-- BEGIN size --><span style="font-size: {SIZE}%; line-height: 116%;">{TEXT}</span><!-- END size -->
-<!-- BEGIN img --><img src="{URL}" alt="{L_IMAGE}" /><!-- END img -->
+<!-- BEGIN img --><img src="{URL}" class="postimage" alt="{L_IMAGE}" /><!-- END img -->
<!-- BEGIN url --><a href="{URL}" class="postlink">{DESCRIPTION}</a><!-- END url -->
diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php
index 3c0bbb96c7..ad5bfa78fc 100644
--- a/tests/text_formatter/s9e/renderer_test.php
+++ b/tests/text_formatter/s9e/renderer_test.php
@@ -112,7 +112,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
),
array(
'<r><IMG src="http://example.org/foo.png"><s>[img]</s>http://example.org/foo.png<e>[/img]</e></IMG></r>',
- '<img src="http://example.org/foo.png" alt="Image">',
+ '<img src="http://example.org/foo.png" class="postimage" alt="Image">',
array('set_viewimg' => true)
),
array(
@@ -231,7 +231,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
),
array(
'<r><IMG src="http://localhost/mrgreen.gif"><s>[img]</s><URL url="http://localhost/mrgreen.gif">http://localhost/mrgreen.gif</URL><e>[/img]</e></IMG></r>',
- '<img src="http://localhost/mrgreen.gif" alt="Image">'
+ '<img src="http://localhost/mrgreen.gif" class="postimage" alt="Image">'
),
array(
'<r><IMG src="http://localhost/mrgreen.gif"><s>[img]</s><URL url="http://localhost/mrgreen.gif">http://localhost/mrgreen.gif</URL><e>[/img]</e></IMG></r>',
diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php
index f2b0d6c78b..dba3713447 100644
--- a/tests/text_processing/generate_text_for_display_test.php
+++ b/tests/text_processing/generate_text_for_display_test.php
@@ -173,7 +173,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
),
array(
'<r><IMG src="http://localhost/mrgreen.gif"><s>[img]</s><URL url="http://localhost/mrgreen.gif">http://localhost/mrgreen.gif</URL><e>[/img]</e></IMG></r>',
- '<img src="http://localhost/mrgreen.gif" alt="Image">'
+ '<img src="http://localhost/mrgreen.gif" class="postimage" alt="Image">'
),
array(
'<r><IMG src="http://localhost/mrgreen.gif"><s>[img]</s><URL url="http://localhost/mrgreen.gif">http://localhost/mrgreen.gif</URL><e>[/img]</e></IMG></r>',
diff --git a/tests/text_processing/tickets_data/PHPBB3-12195.html b/tests/text_processing/tickets_data/PHPBB3-12195.html
index d8e0f8d523..c286c0fee9 100644
--- a/tests/text_processing/tickets_data/PHPBB3-12195.html
+++ b/tests/text_processing/tickets_data/PHPBB3-12195.html
@@ -1 +1 @@
-<a href="//example.org/" class="postlink"><img src="//example.org/img.png" alt="Image"></a> \ No newline at end of file
+<a href="//example.org/" class="postlink"><img src="//example.org/img.png" class="postimage" alt="Image"></a> \ No newline at end of file