From b6f6930eb56b9fd64f200a7b0e6d8cd28f0e73f6 Mon Sep 17 00:00:00 2001
From: mrgoldy <gijsmartens1@gmail.com>
Date: Thu, 29 Nov 2018 19:56:24 +0100
Subject: [ticket/15886] Group helper functions

PHPBB3-15886
---
 tests/group/helper_get_name_string_test.php | 114 ++++++++++++++++++++++++++
 tests/group/helper_get_name_test.php        |  31 +++++++
 tests/group/helper_get_rank_test.php        |  43 ++++++++++
 tests/group/helper_test.php                 |  68 ---------------
 tests/group/helper_test_case.php            | 123 ++++++++++++++++++++++++++++
 5 files changed, 311 insertions(+), 68 deletions(-)
 create mode 100644 tests/group/helper_get_name_string_test.php
 create mode 100644 tests/group/helper_get_name_test.php
 create mode 100644 tests/group/helper_get_rank_test.php
 delete mode 100644 tests/group/helper_test.php
 create mode 100644 tests/group/helper_test_case.php

(limited to 'tests')

diff --git a/tests/group/helper_get_name_string_test.php b/tests/group/helper_get_name_string_test.php
new file mode 100644
index 0000000000..7ea0f156e4
--- /dev/null
+++ b/tests/group/helper_get_name_string_test.php
@@ -0,0 +1,114 @@
+<?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.
+ *
+ */
+
+require_once dirname(__FILE__) . '/helper_test_case.php';
+
+class phpbb_group_helper_get_name_string_test extends phpbb_group_helper_test_case
+{
+
+	public function get_name_string_profile_data()
+	{
+		global $phpbb_root_path, $phpEx;
+
+		return array(
+			array(0, 'Non existing group', '', false, ''),
+			array(2, 'Administrators', 'AA0000', false, "{$phpbb_root_path}memberlist.$phpEx?mode=group&amp;g=2"),
+			array(42, 'Example Group', '', 'http://www.example.org/group.php?mode=show', 'http://www.example.org/group.php?mode=show&amp;g=42'),
+		);
+	}
+
+	/**
+	* @dataProvider get_name_string_profile_data
+	*/
+	public function test_get_name_string_profile($group_id, $group_name, $group_colour, $custom_profile_url, $expected)
+	{
+		$this->assertEquals($expected, $this->group_helper->get_name_string('profile', $group_id, $group_name, $group_colour, $custom_profile_url));
+	}
+
+	public function get_name_string_group_name_data()
+	{
+		return array(
+			// Should be fine
+			array(0, 'Bots', 'AA0000', false, 'Bots'),
+			array(1, 'new_group', '', false, 'Some new group'),
+			array(2, 'group_with_ümlauts', '', 'http://www.example.org/group.php?mode=show', 'Should work'),
+
+			// Should fail and thus return the same
+			array(3, 'not_uppercase', 'FFFFFF', false, 'not_uppercase'),
+			array(4, 'Awesome group', '', false, 'Awesome group'),
+		);
+	}
+
+	/**
+	 * @dataProvider get_name_string_group_name_data
+	 */
+	public function test_get_name_string_group_name($group_id, $group_name, $group_colour, $custom_profile_url, $expected)
+	{
+		$this->assertEquals($expected, $this->group_helper->get_name_string('group_name', $group_id, $group_name, $group_colour, $custom_profile_url));
+	}
+
+	public function get_name_string_colour_data()
+	{
+		return array(
+			array(0, '', '', false, ''),
+			array(0, '', 'F0F0F0', false, '#F0F0F0'),
+			array(1, 'Guests', '000000', false, '#000000'),
+			array(2, 'Administrators', '', false, ''),
+		);
+	}
+
+	/**
+	 * @dataProvider get_name_string_colour_data
+	 */
+	public function test_get_name_string_colour($group_id, $group_name, $group_colour, $custom_profile_url, $expected)
+	{
+		$this->assertEquals($expected, $this->group_helper->get_name_string('colour', $group_id, $group_name, $group_colour, $custom_profile_url));
+	}
+
+	public function get_name_string_full_data()
+	{
+		global $phpbb_root_path, $phpEx;
+
+		return array(
+			array(0, 'Bots', '000000', false, '<span class="username-coloured" style="color: #000000;">Bots</span>'),
+			array(7, 'new_group', 'FFA500', false, '<a class="username-coloured" href="' . $phpbb_root_path . 'memberlist.' . $phpEx . '?mode=group&amp;g=7" style="color: #FFA500;">Some new group</a>'),
+			array(14, 'Awesome group', '', 'http://www.example.org/group.php?mode=show', '<a class="username" href="http://www.example.org/group.php?mode=show&amp;g=14">Awesome group</a>'),
+		);
+	}
+
+	/**
+	 * @dataProvider get_name_string_full_data
+	 */
+	public function test_get_name_string_full($group_id, $group_name, $group_colour, $custom_profile_url, $expected)
+	{
+		$this->assertEquals($expected, $this->group_helper->get_name_string('full', $group_id, $group_name, $group_colour, $custom_profile_url));
+	}
+
+	public function get_name_string_no_profile_data()
+	{
+		return array(
+			array(0, 'Bots', '000000', false, '<span class="username-coloured" style="color: #000000;">Bots</span>'),
+			array(1, 'new_group', '', false, '<span class="username">Some new group</span>'),
+			arraY(2, 'not_uppercase', 'FF0000', false, '<span class="username-coloured" style="color: #FF0000;">not_uppercase</span>'),
+			array(5, 'Awesome group', '', 'http://www.example.org/group.php?mode=show', '<span class="username">Awesome group</span>'),
+		);
+	}
+
+	/**
+	 * @dataProvider get_name_string_no_profile_data
+	 */
+	public function test_get_name_string_no_profile($group_id, $group_name, $group_colour, $custom_profile_url, $expected)
+	{
+		$this->assertEquals($expected, $this->group_helper->get_name_string('no_profile', $group_id, $group_name, $group_colour, $custom_profile_url));
+	}
+}
diff --git a/tests/group/helper_get_name_test.php b/tests/group/helper_get_name_test.php
new file mode 100644
index 0000000000..b39b2cbedd
--- /dev/null
+++ b/tests/group/helper_get_name_test.php
@@ -0,0 +1,31 @@
+<?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.
+ *
+ */
+
+require_once dirname(__FILE__) . '/helper_test_case.php';
+
+class phpbb_group_helper_get_name_test extends phpbb_group_helper_test_case
+{
+	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('The 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'));
+	}
+}
diff --git a/tests/group/helper_get_rank_test.php b/tests/group/helper_get_rank_test.php
new file mode 100644
index 0000000000..5efd8ad95e
--- /dev/null
+++ b/tests/group/helper_get_rank_test.php
@@ -0,0 +1,43 @@
+<?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.
+ *
+ */
+
+require_once dirname(__FILE__) . '/helper_test_case.php';
+
+class phpbb_group_helper_get_rank_test extends phpbb_group_helper_test_case
+{
+	public function get_rank_data()
+	{
+		global $phpbb_root_path;
+
+		return array(
+			array(
+				array('group_id' => 0, 'group_rank' => 1),
+				array(
+					'title' => 'Site admin',
+					'img' => '<img src="' . $phpbb_root_path . 'images/ranks/siteadmin.png' . '" alt="Site admin" title="Site admin" />',
+					'img_src' => $phpbb_root_path . 'images/ranks/siteadmin.png',
+				)
+			),
+			array(array('group_id' => 1, 'group_rank' => 0), array('title' => null, 'img' => null, 'img_src' => null)),
+			array(array('group_id' => 2, 'group_rank' => 2), array('title' => 'Test member', 'img' => '', 'img_src' => '')),
+		);
+	}
+
+	/**
+	 * @dataProvider get_rank_data
+	 */
+	public function test_get_rank($group_data, $expected)
+	{
+		$this->assertEquals($expected, $this->group_helper->get_rank($group_data));
+	}
+}
diff --git a/tests/group/helper_test.php b/tests/group/helper_test.php
deleted file mode 100644
index 2377a6f47c..0000000000
--- a/tests/group/helper_test.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?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/group/helper_test_case.php b/tests/group/helper_test_case.php
new file mode 100644
index 0000000000..1318cf9040
--- /dev/null
+++ b/tests/group/helper_test_case.php
@@ -0,0 +1,123 @@
+<?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_case extends phpbb_test_case
+{
+	/** @var  \phpbb\group\helper */
+	protected $group_helper;
+
+	protected function config_defaults()
+	{
+		$defaults = array(
+			'ranks_path' => 'images/ranks'
+		);
+		return $defaults;
+	}
+
+	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',
+		);
+	}
+
+	protected function get_test_rank_data_set()
+	{
+		return array(
+			'special' => array(
+				1 => array(
+					'rank_id'		=> 1,
+					'rank_title'	=> 'Site admin',
+					'rank_special'	=> 1,
+					'rank_image'	=> 'siteadmin.png',
+				),
+				2 => array(
+					'rank_id'		=> 2,
+					'rank_title'	=> 'Test member',
+					'rank_special'	=> 1,
+					'rank_image'	=> '',
+				)
+			)
+		);
+	}
+
+	protected function setup_engine(array $new_config = array())
+	{
+		global $cache, $phpbb_dispatcher, $phpbb_root_path, $phpEx;
+
+		// Set up authentication data for testing
+		$auth = $this->getMock('\phpbb\auth\auth');
+		$auth->expects($this->any())
+			->method('acl_get')
+			->with($this->stringContains('_'), $this->anything())
+			->will($this->returnValueMap(array(
+				array('u_viewprofile', true),
+			)));
+
+		// Set up cache service
+		$cache_service = $this->getMockBuilder('\phpbb\cache\service')->disableOriginalConstructor()->getMock();
+		$cache_service->expects($this->any())
+			->method('obtain_ranks')
+			->will($this->returnValue($this->get_test_rank_data_set()));
+
+		// Set up configuration
+		$defaults = $this->config_defaults();
+		$config = new \phpbb\config\config(array_merge($defaults, $new_config));
+
+		// 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 event dispatcher
+		$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
+
+		// Set up path helper
+		$filesystem = new \phpbb\filesystem\filesystem();
+		$path_helper = new \phpbb\path_helper(
+			new \phpbb\symfony_request(
+				new phpbb_mock_request()
+			),
+			$filesystem,
+			$this->getMock('\phpbb\request\request'),
+			$phpbb_root_path,
+			$phpEx
+		);
+
+		$user = new \phpbb\user($lang, '\phpbb\datetime');
+		$user->data['user_id'] = ANONYMOUS;
+
+		$this->group_helper = new \phpbb\group\helper($auth, $cache_service, $config, $lang, $phpbb_dispatcher, $path_helper, $user, $phpbb_root_path, $phpEx);
+	}
+
+	public function setUp()
+	{
+		$this->setup_engine();
+	}
+}
-- 
cgit v1.2.1


From a1baf106d68259daa0c6b1cd1bec8e870aef94f6 Mon Sep 17 00:00:00 2001
From: mrgoldy <gijsmartens1@gmail.com>
Date: Thu, 29 Nov 2018 20:27:04 +0100
Subject: [ticket/15886] Fix notification_group_request_test

PHPBB3-15886
---
 tests/notification/group_request_test.php | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

(limited to 'tests')

diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php
index 92e758a336..36017945ec 100644
--- a/tests/notification/group_request_test.php
+++ b/tests/notification/group_request_test.php
@@ -49,9 +49,17 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas
 			$this->cache->get_driver()
 		));
 		$this->container->set('group_helper', new \phpbb\group\helper(
+			$this->getMock('\phpbb\auth\auth'),
+			$this->cache,
+			$this->config,
 			new \phpbb\language\language(
 				new phpbb\language\language_file_loader($phpbb_root_path, $phpEx)
-			)
+			),
+			new phpbb_mock_event_dispatcher(),
+			$this->getMock('\phpbb\path_helper'),
+			$this->user,
+			$phpbb_root_path,
+			$phpEx
 		));
 		$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
 		$phpbb_log = new \phpbb\log\dummy();
-- 
cgit v1.2.1


From d356fa9f97986d7d31aa77d44c08ae07fbbe1579 Mon Sep 17 00:00:00 2001
From: mrgoldy <gijsmartens1@gmail.com>
Date: Thu, 29 Nov 2018 20:46:52 +0100
Subject: [ticket/15886] Arguments for path_helper

PHPBB3-15886
---
 tests/notification/group_request_test.php | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

(limited to 'tests')

diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php
index 36017945ec..f53fe32f2a 100644
--- a/tests/notification/group_request_test.php
+++ b/tests/notification/group_request_test.php
@@ -56,7 +56,15 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas
 				new phpbb\language\language_file_loader($phpbb_root_path, $phpEx)
 			),
 			new phpbb_mock_event_dispatcher(),
-			$this->getMock('\phpbb\path_helper'),
+			new \phpbb\path_helper(
+				new \phpbb\symfony_request(
+					new phpbb_mock_request()
+				),
+				new \phpbb\filesystem\filesystem(),
+				$this->getMock('\phpbb\request\request'),
+				$phpbb_root_path,
+				$phpEx
+			),
 			$this->user,
 			$phpbb_root_path,
 			$phpEx
-- 
cgit v1.2.1


From e2e3d402a25b6203f2c29296eddf2dae002053da Mon Sep 17 00:00:00 2001
From: mrgoldy <gijsmartens1@gmail.com>
Date: Sat, 29 Dec 2018 13:28:00 +0100
Subject: [ticket/15886] Clean up services

PHPBB3-15886
---
 tests/group/helper_test_case.php          | 246 +++++++++++++++---------------
 tests/notification/group_request_test.php |   4 +-
 2 files changed, 124 insertions(+), 126 deletions(-)

(limited to 'tests')

diff --git a/tests/group/helper_test_case.php b/tests/group/helper_test_case.php
index 1318cf9040..cfbcd5890c 100644
--- a/tests/group/helper_test_case.php
+++ b/tests/group/helper_test_case.php
@@ -1,123 +1,123 @@
-<?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_case extends phpbb_test_case
-{
-	/** @var  \phpbb\group\helper */
-	protected $group_helper;
-
-	protected function config_defaults()
-	{
-		$defaults = array(
-			'ranks_path' => 'images/ranks'
-		);
-		return $defaults;
-	}
-
-	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',
-		);
-	}
-
-	protected function get_test_rank_data_set()
-	{
-		return array(
-			'special' => array(
-				1 => array(
-					'rank_id'		=> 1,
-					'rank_title'	=> 'Site admin',
-					'rank_special'	=> 1,
-					'rank_image'	=> 'siteadmin.png',
-				),
-				2 => array(
-					'rank_id'		=> 2,
-					'rank_title'	=> 'Test member',
-					'rank_special'	=> 1,
-					'rank_image'	=> '',
-				)
-			)
-		);
-	}
-
-	protected function setup_engine(array $new_config = array())
-	{
-		global $cache, $phpbb_dispatcher, $phpbb_root_path, $phpEx;
-
-		// Set up authentication data for testing
-		$auth = $this->getMock('\phpbb\auth\auth');
-		$auth->expects($this->any())
-			->method('acl_get')
-			->with($this->stringContains('_'), $this->anything())
-			->will($this->returnValueMap(array(
-				array('u_viewprofile', true),
-			)));
-
-		// Set up cache service
-		$cache_service = $this->getMockBuilder('\phpbb\cache\service')->disableOriginalConstructor()->getMock();
-		$cache_service->expects($this->any())
-			->method('obtain_ranks')
-			->will($this->returnValue($this->get_test_rank_data_set()));
-
-		// Set up configuration
-		$defaults = $this->config_defaults();
-		$config = new \phpbb\config\config(array_merge($defaults, $new_config));
-
-		// 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 event dispatcher
-		$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
-
-		// Set up path helper
-		$filesystem = new \phpbb\filesystem\filesystem();
-		$path_helper = new \phpbb\path_helper(
-			new \phpbb\symfony_request(
-				new phpbb_mock_request()
-			),
-			$filesystem,
-			$this->getMock('\phpbb\request\request'),
-			$phpbb_root_path,
-			$phpEx
-		);
-
-		$user = new \phpbb\user($lang, '\phpbb\datetime');
-		$user->data['user_id'] = ANONYMOUS;
-
-		$this->group_helper = new \phpbb\group\helper($auth, $cache_service, $config, $lang, $phpbb_dispatcher, $path_helper, $user, $phpbb_root_path, $phpEx);
-	}
-
-	public function setUp()
-	{
-		$this->setup_engine();
-	}
-}
+<?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_case extends phpbb_test_case
+{
+	/** @var  \phpbb\group\helper */
+	protected $group_helper;
+
+	protected function config_defaults()
+	{
+		$defaults = array(
+			'ranks_path' => 'images/ranks'
+		);
+		return $defaults;
+	}
+
+	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',
+		);
+	}
+
+	protected function get_test_rank_data_set()
+	{
+		return array(
+			'special' => array(
+				1 => array(
+					'rank_id'		=> 1,
+					'rank_title'	=> 'Site admin',
+					'rank_special'	=> 1,
+					'rank_image'	=> 'siteadmin.png',
+				),
+				2 => array(
+					'rank_id'		=> 2,
+					'rank_title'	=> 'Test member',
+					'rank_special'	=> 1,
+					'rank_image'	=> '',
+				)
+			)
+		);
+	}
+
+	protected function setup_engine(array $new_config = array())
+	{
+		global $phpbb_dispatcher, $phpbb_root_path, $phpEx;
+
+		// Set up authentication data for testing
+		$auth = $this->getMock('\phpbb\auth\auth');
+		$auth->expects($this->any())
+			->method('acl_get')
+			->with($this->stringContains('_'), $this->anything())
+			->will($this->returnValueMap(array(
+				array('u_viewprofile', true),
+			)));
+
+		// Set up cache service
+		$cache_service = $this->getMockBuilder('\phpbb\cache\service')->disableOriginalConstructor()->getMock();
+		$cache_service->expects($this->any())
+			->method('obtain_ranks')
+			->will($this->returnValue($this->get_test_rank_data_set()));
+
+		// Set up configuration
+		$defaults = $this->config_defaults();
+		$config = new \phpbb\config\config(array_merge($defaults, $new_config));
+
+		// 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 event dispatcher
+		$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
+
+		// Set up path helper
+		$filesystem = new \phpbb\filesystem\filesystem();
+		$path_helper = new \phpbb\path_helper(
+			new \phpbb\symfony_request(
+				new phpbb_mock_request()
+			),
+			$filesystem,
+			$this->getMock('\phpbb\request\request'),
+			$phpbb_root_path,
+			$phpEx
+		);
+
+		$user = new \phpbb\user($lang, '\phpbb\datetime');
+		$user->data['user_id'] = ANONYMOUS;
+
+		$this->group_helper = new \phpbb\group\helper($auth, $cache_service, $config, $lang, $phpbb_dispatcher, $path_helper, $user);
+	}
+
+	public function setUp()
+	{
+		$this->setup_engine();
+	}
+}
diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php
index f53fe32f2a..e849c66fa5 100644
--- a/tests/notification/group_request_test.php
+++ b/tests/notification/group_request_test.php
@@ -65,9 +65,7 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas
 				$phpbb_root_path,
 				$phpEx
 			),
-			$this->user,
-			$phpbb_root_path,
-			$phpEx
+			$this->user
 		));
 		$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
 		$phpbb_log = new \phpbb\log\dummy();
-- 
cgit v1.2.1


From f023dd590f28b2721773f8429a2d1fbf995f544f Mon Sep 17 00:00:00 2001
From: mrgoldy <gijsmartens1@gmail.com>
Date: Wed, 2 Jan 2019 12:33:25 +0100
Subject: [ticket/15886] Mock path helper in group helper tests

PHPBB3-15886
---
 tests/group/helper_test_case.php | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

(limited to 'tests')

diff --git a/tests/group/helper_test_case.php b/tests/group/helper_test_case.php
index cfbcd5890c..e298770331 100644
--- a/tests/group/helper_test_case.php
+++ b/tests/group/helper_test_case.php
@@ -99,16 +99,16 @@ class phpbb_group_helper_test_case extends phpbb_test_case
 		$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
 
 		// Set up path helper
-		$filesystem = new \phpbb\filesystem\filesystem();
-		$path_helper = new \phpbb\path_helper(
-			new \phpbb\symfony_request(
-				new phpbb_mock_request()
-			),
-			$filesystem,
-			$this->getMock('\phpbb\request\request'),
-			$phpbb_root_path,
-			$phpEx
-		);
+		$path_helper = $this->getMockBuilder('\phpbb\path_helper')
+			->disableOriginalConstructor()
+			->setMethods(array())
+			->getMock();
+		$path_helper->method('get_phpbb_root_path')
+			->willReturn($phpbb_root_path);
+		$path_helper->method('get_php_ext')
+			->willReturn($phpEx);
+		$path_helper->method('update_web_root_path')
+			->will($this->returnArgument(0));
 
 		$user = new \phpbb\user($lang, '\phpbb\datetime');
 		$user->data['user_id'] = ANONYMOUS;
-- 
cgit v1.2.1


From f6c93a81d302be22d754fb65e50d60699ea7b5c0 Mon Sep 17 00:00:00 2001
From: mrgoldy <gijsmartens1@gmail.com>
Date: Wed, 2 Jan 2019 13:21:44 +0100
Subject: [ticket/15886] No profile url for BOTS group

PHPBB3-15886
---
 tests/group/helper_get_name_string_test.php | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

(limited to 'tests')

diff --git a/tests/group/helper_get_name_string_test.php b/tests/group/helper_get_name_string_test.php
index 7ea0f156e4..565602a346 100644
--- a/tests/group/helper_get_name_string_test.php
+++ b/tests/group/helper_get_name_string_test.php
@@ -39,7 +39,7 @@ class phpbb_group_helper_get_name_string_test extends phpbb_group_helper_test_ca
 	{
 		return array(
 			// Should be fine
-			array(0, 'Bots', 'AA0000', false, 'Bots'),
+			array(0, 'BOTS', 'AA0000', false, 'Bots'),
 			array(1, 'new_group', '', false, 'Some new group'),
 			array(2, 'group_with_ümlauts', '', 'http://www.example.org/group.php?mode=show', 'Should work'),
 
@@ -80,7 +80,8 @@ class phpbb_group_helper_get_name_string_test extends phpbb_group_helper_test_ca
 		global $phpbb_root_path, $phpEx;
 
 		return array(
-			array(0, 'Bots', '000000', false, '<span class="username-coloured" style="color: #000000;">Bots</span>'),
+			array(0, 'BOTS', '000000', false, '<span class="username-coloured" style="color: #000000;">Bots</span>'),
+			array(1, 'BOTS', '111111', false, '<span class="username-coloured" style="color: #111111;">Bots</span>'),
 			array(7, 'new_group', 'FFA500', false, '<a class="username-coloured" href="' . $phpbb_root_path . 'memberlist.' . $phpEx . '?mode=group&amp;g=7" style="color: #FFA500;">Some new group</a>'),
 			array(14, 'Awesome group', '', 'http://www.example.org/group.php?mode=show', '<a class="username" href="http://www.example.org/group.php?mode=show&amp;g=14">Awesome group</a>'),
 		);
@@ -97,7 +98,7 @@ class phpbb_group_helper_get_name_string_test extends phpbb_group_helper_test_ca
 	public function get_name_string_no_profile_data()
 	{
 		return array(
-			array(0, 'Bots', '000000', false, '<span class="username-coloured" style="color: #000000;">Bots</span>'),
+			array(0, 'BOTS', '000000', false, '<span class="username-coloured" style="color: #000000;">Bots</span>'),
 			array(1, 'new_group', '', false, '<span class="username">Some new group</span>'),
 			arraY(2, 'not_uppercase', 'FF0000', false, '<span class="username-coloured" style="color: #FF0000;">not_uppercase</span>'),
 			array(5, 'Awesome group', '', 'http://www.example.org/group.php?mode=show', '<span class="username">Awesome group</span>'),
-- 
cgit v1.2.1


From 813789c644dfd34ec9f63e16ad9f6b8a2aa97163 Mon Sep 17 00:00:00 2001
From: mrgoldy <gijsmartens1@gmail.com>
Date: Wed, 2 Jan 2019 13:30:58 +0100
Subject: [ticket/15886] Capital Y in arraY

PHPBB3-15886
---
 tests/group/helper_get_name_string_test.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'tests')

diff --git a/tests/group/helper_get_name_string_test.php b/tests/group/helper_get_name_string_test.php
index 565602a346..c626328dcc 100644
--- a/tests/group/helper_get_name_string_test.php
+++ b/tests/group/helper_get_name_string_test.php
@@ -100,7 +100,7 @@ class phpbb_group_helper_get_name_string_test extends phpbb_group_helper_test_ca
 		return array(
 			array(0, 'BOTS', '000000', false, '<span class="username-coloured" style="color: #000000;">Bots</span>'),
 			array(1, 'new_group', '', false, '<span class="username">Some new group</span>'),
-			arraY(2, 'not_uppercase', 'FF0000', false, '<span class="username-coloured" style="color: #FF0000;">not_uppercase</span>'),
+			array(2, 'not_uppercase', 'FF0000', false, '<span class="username-coloured" style="color: #FF0000;">not_uppercase</span>'),
 			array(5, 'Awesome group', '', 'http://www.example.org/group.php?mode=show', '<span class="username">Awesome group</span>'),
 		);
 	}
-- 
cgit v1.2.1