aboutsummaryrefslogtreecommitdiffstats
path: root/tests/group
diff options
context:
space:
mode:
authorOliver Schramm <oliver.schramm97@gmail.com>2015-05-29 11:31:47 +0200
committerOliver Schramm <oliver.schramm97@gmail.com>2015-08-05 17:50:25 +0200
commitca17bc7187c8836be7650209886b1024d01b268c (patch)
tree4692a310f5a9a3f02ca924203f8377b6cef9290c /tests/group
parentd4095bb11d3181f9d1fbd9fd3600142ef57d6200 (diff)
downloadforums-ca17bc7187c8836be7650209886b1024d01b268c.tar
forums-ca17bc7187c8836be7650209886b1024d01b268c.tar.gz
forums-ca17bc7187c8836be7650209886b1024d01b268c.tar.bz2
forums-ca17bc7187c8836be7650209886b1024d01b268c.tar.xz
forums-ca17bc7187c8836be7650209886b1024d01b268c.zip
[ticket/12143] Add some tests
PHPBB3-12143
Diffstat (limited to 'tests/group')
-rw-r--r--tests/group/helper_test.php68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/group/helper_test.php b/tests/group/helper_test.php
new file mode 100644
index 0000000000..a325ac7ac9
--- /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', 'Bots');
+ $this->assertEquals('Some new group', 'new_group');
+ $this->assertEquals('Should work', 'group_with_ümlauts');
+
+ // This should fail (obviously)
+ $this->assertNotEquals('They key does not contain uppercase letters', 'not_uppercase');
+
+ // The key doesn't exist so just return group name...
+ $this->assertEquals('Awesome group', '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',
+ );
+ }
+}