aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/extension/modules_test.php4
-rw-r--r--tests/functional/auth_test.php4
-rw-r--r--tests/functional/extension_acp_test.php10
-rw-r--r--tests/functional/notification_test.php2
-rw-r--r--tests/functions_content/get_username_string_test.php126
5 files changed, 137 insertions, 9 deletions
diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php
index c0a136e173..e396b7b73e 100644
--- a/tests/extension/modules_test.php
+++ b/tests/extension/modules_test.php
@@ -209,7 +209,7 @@ class phpbb_extension_modules_test extends phpbb_test_case
*/
public function test_modules_auth($module_auth, $expected)
{
- global $phpbb_extension_manager;
+ global $phpbb_extension_manager, $phpbb_dispatcher;
$phpbb_extension_manager = $this->extension_manager = new phpbb_mock_extension_manager(
dirname(__FILE__) . '/',
@@ -227,6 +227,8 @@ class phpbb_extension_modules_test extends phpbb_test_case
)
);
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
+
$this->assertEquals($expected, p_master::module_auth($module_auth, 0));
}
}
diff --git a/tests/functional/auth_test.php b/tests/functional/auth_test.php
index cfd85571b7..d3fed18094 100644
--- a/tests/functional/auth_test.php
+++ b/tests/functional/auth_test.php
@@ -18,7 +18,7 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case
// check for logout link
$crawler = self::request('GET', 'index.php');
- $this->assertContains($this->lang('LOGOUT_USER', 'admin'), $crawler->filter('.navbar')->text());
+ $this->assertContains($this->lang('LOGOUT', 'admin'), $crawler->filter('.navbar')->text());
}
public function test_login_other()
@@ -26,7 +26,7 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case
$this->create_user('anothertestuser');
$this->login('anothertestuser');
$crawler = self::request('GET', 'index.php');
- $this->assertContains('anothertestuser', $crawler->filter('.icon-logout')->text());
+ $this->assertContains('anothertestuser', $crawler->filter('#username_logged_in')->text());
}
/**
diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php
index 1d79043eae..5f02158e20 100644
--- a/tests/functional/extension_acp_test.php
+++ b/tests/functional/extension_acp_test.php
@@ -85,14 +85,14 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
$this->assertContains('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text());
$this->assertContainsLang('EXTENSION_DISABLE', $crawler->filter('.ext_enabled')->eq(0)->text());
- $this->assertContains('phpBB Moo Extension', $crawler->filter('.ext_disabled')->eq(1)->text());
- $this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(1)->text());
- $this->assertContainsLang('EXTENSION_ENABLE', $crawler->filter('.ext_disabled')->eq(1)->text());
- $this->assertContainsLang('EXTENSION_DELETE_DATA', $crawler->filter('.ext_disabled')->eq(1)->text());
+ $this->assertContains('phpBB Moo Extension', $crawler->filter('.ext_disabled')->eq(2)->text());
+ $this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(2)->text());
+ $this->assertContainsLang('EXTENSION_ENABLE', $crawler->filter('.ext_disabled')->eq(2)->text());
+ $this->assertContainsLang('EXTENSION_DELETE_DATA', $crawler->filter('.ext_disabled')->eq(2)->text());
$this->assertContains('The “vendor/test2” extension is not valid.', $crawler->filter('.ext_disabled')->eq(0)->text());
- $this->assertContains('The “vendor/test3” extension is not valid.', $crawler->filter('.ext_disabled')->eq(2)->text());
+ $this->assertContains('The “vendor/test3” extension is not valid.', $crawler->filter('.ext_disabled')->eq(1)->text());
$this->assertContains('phpBB Bar Extension', $crawler->filter('.ext_disabled')->eq(3)->text());
$this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(3)->text());
diff --git a/tests/functional/notification_test.php b/tests/functional/notification_test.php
index dd1b8ec981..9ae37842fe 100644
--- a/tests/functional/notification_test.php
+++ b/tests/functional/notification_test.php
@@ -60,7 +60,7 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case
$this->add_user_group('NEWLY_REGISTERED', array('notificationtestuser'));
$this->login('notificationtestuser');
$crawler = self::request('GET', 'index.php');
- $this->assertContains('notificationtestuser', $crawler->filter('.icon-logout')->text());
+ $this->assertContains('notificationtestuser', $crawler->filter('#username_logged_in')->text());
// Post a new post that needs approval
$this->create_post(2, 1, 'Re: Welcome to phpBB3', 'This is a test [b]post[/b] posted by notificationtestuser.', array(), 'POST_STORED_MOD');
diff --git a/tests/functions_content/get_username_string_test.php b/tests/functions_content/get_username_string_test.php
new file mode 100644
index 0000000000..1f23f19056
--- /dev/null
+++ b/tests/functions_content/get_username_string_test.php
@@ -0,0 +1,126 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2014 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php';
+
+class phpbb_functions_content_get_username_string_test extends phpbb_test_case
+{
+ public function setUp()
+ {
+ parent::setUp();
+
+ global $auth, $phpbb_dispatcher, $user;
+ $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),
+ )));
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher;
+ $user->data['user_id'] = ANONYMOUS;
+ $user->lang['GUEST'] = 'Guest';
+ }
+
+ public function get_username_string_profile_data()
+ {
+ global $phpbb_root_path, $phpEx;
+
+ return array(
+ array(ANONYMOUS, 'Anonymous', '', false, false, ''),
+ array(2, 'Administrator', 'FF0000', false, false, "{$phpbb_root_path}memberlist.$phpEx?mode=viewprofile&amp;u=2"),
+ array(42, 'User42', '', false, 'http://www.example.org/user.php?mode=show', 'http://www.example.org/user.php?mode=show&amp;u=42'),
+ );
+ }
+
+ /**
+ * @dataProvider get_username_string_profile_data
+ */
+ public function test_get_username_string_profile($user_id, $username, $user_colour, $guest_username, $custom_profile_url, $expected)
+ {
+ $this->assertEquals($expected, get_username_string('profile', $user_id, $username, $user_colour, $guest_username, $custom_profile_url));
+ }
+
+ public function get_username_string_username_data()
+ {
+ return array(
+ array(ANONYMOUS, '', '', false, false, 'Guest'),
+ array(ANONYMOUS, '', '', 'CustomName', false, 'CustomName'),
+ array(2, 'User2', '', false, false, 'User2'),
+ array(5, 'User5', '', 'Anonymous', false, 'User5'),
+ array(128, 'User128', '', false, false, 'User128'),
+ );
+ }
+
+ /**
+ * @dataProvider get_username_string_username_data
+ */
+ public function test_get_username_string_username($user_id, $username, $user_colour, $guest_username, $custom_profile_url, $expected)
+ {
+ $this->assertEquals($expected, get_username_string('username', $user_id, $username, $user_colour, $guest_username, $custom_profile_url));
+ }
+
+ public function get_username_string_colour_data()
+ {
+ return array(
+ array(0, '', '', false, false, ''),
+ array(0, '', 'F0F0F0', false, false, '#F0F0F0'),
+ array(ANONYMOUS, 'Anonymous', '000000', false, false, '#000000'),
+ array(2, 'Administrator', '', false, false, ''),
+ );
+ }
+
+ /**
+ * @dataProvider get_username_string_colour_data
+ */
+ public function test_get_username_string_colour($user_id, $username, $user_colour, $guest_username, $custom_profile_url, $expected)
+ {
+ $this->assertEquals($expected, get_username_string('colour', $user_id, $username, $user_colour, $guest_username, $custom_profile_url));
+ }
+
+ public function get_username_string_full_data()
+ {
+ global $phpbb_root_path, $phpEx;
+
+ return array(
+ array(0, '', '', false, false, 'Guest'),
+ array(ANONYMOUS, 'Anonymous', '', false, false, 'Anonymous'),
+ array(2, 'Administrator', 'FF0000', false, false, '<a href="' . $phpbb_root_path . 'memberlist.' . $phpEx . '?mode=viewprofile&amp;u=2" style="color: #FF0000;" class="username-coloured">Administrator</a>'),
+ array(5, 'User5', '', false, 'http://www.example.org/user.php?mode=show', '<a href="http://www.example.org/user.php?mode=show&amp;u=5">User5</a>'),
+ array(8, 'Eight', '', false, false, '<a href="' . $phpbb_root_path . 'memberlist.php?mode=viewprofile&amp;u=8">Eight</a>'),
+ );
+ }
+
+ /**
+ * @dataProvider get_username_string_full_data
+ */
+ public function test_get_username_string_full($user_id, $username, $user_colour, $guest_username, $custom_profile_url, $expected)
+ {
+ $this->assertEquals($expected, get_username_string('full', $user_id, $username, $user_colour, $guest_username, $custom_profile_url));
+ }
+
+ public function get_username_string_no_profile_data()
+ {
+ return array(
+ array(ANONYMOUS, 'Anonymous', '', false, false, 'Anonymous'),
+ array(ANONYMOUS, 'Anonymous', '', '', false, 'Guest'),
+ array(2, 'Administrator', 'FF0000', false, false, '<span style="color: #FF0000;" class="username-coloured">Administrator</span>'),
+ array(8, 'Eight', '', false, false, 'Eight'),
+ );
+ }
+
+ /**
+ * @dataProvider get_username_string_no_profile_data
+ */
+ public function test_get_username_string_no_profile($user_id, $username, $user_colour, $guest_username, $custom_profile_url, $expected)
+ {
+ $this->assertEquals($expected, get_username_string('no_profile', $user_id, $username, $user_colour, $guest_username, $custom_profile_url));
+ }
+}