From 7a8a4408952659d59a3c92108eae6ef0f10a5bb3 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 8 Nov 2013 14:08:55 +0100 Subject: [ticket/12002] Change functional test to use link hash PHPBB3-12002 --- tests/functional/extension_acp_test.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests/functional') diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index 44bb895f67..5d391e42f7 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -182,13 +182,34 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case public function test_actions() { + // Access enable page without hash $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $this->assertContainsLang('FORM_INVALID', $crawler->filter('.errorbox')->text()); + + // Correctly submit the enable form + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $form = $crawler->selectButton('enable')->form(); + $crawler = self::submit($form); $this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', $crawler->filter('.successbox')->text()); + // Access disable page without hash $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $this->assertContainsLang('FORM_INVALID', $crawler->filter('.errorbox')->text()); + + // Correctly submit the disable form + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $form = $crawler->selectButton('disable')->form(); + $crawler = self::submit($form); $this->assertContainsLang('EXTENSION_DISABLE_SUCCESS', $crawler->filter('.successbox')->text()); + // Access delete_data page without hash $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $this->assertContainsLang('FORM_INVALID', $crawler->filter('.errorbox')->text()); + + // Correctly submit the delete data form + $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); + $form = $crawler->selectButton('delete_data')->form(); + $crawler = self::submit($form); $this->assertContainsLang('EXTENSION_DELETE_DATA_SUCCESS', $crawler->filter('.successbox')->text()); } } -- cgit v1.2.1 From 95c2b12bf7be4e6ad1070d7dd11a9afd7fc1efa8 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 9 Nov 2013 20:35:37 +0100 Subject: [ticket/11896] Add functional tests for marking all notifications read PHPBB3-11896 --- tests/functional/notification_test.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tests/functional') diff --git a/tests/functional/notification_test.php b/tests/functional/notification_test.php index 7f33ad1859..dd1b8ec981 100644 --- a/tests/functional/notification_test.php +++ b/tests/functional/notification_test.php @@ -52,4 +52,37 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case $this->assert_checkbox_is_unchecked($cplist, $checkbox_name); } } + + public function test_mark_notifications_read() + { + // Create a new standard user + $this->create_user('notificationtestuser'); + $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()); + + // 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'); + $crawler = self::request('GET', "viewtopic.php?t=1&sid={$this->sid}"); + $this->assertNotContains('This is a test post posted by notificationtestuser.', $crawler->filter('html')->text()); + + // logout + $crawler = self::request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout'); + + // admin login + $this->login(); + $this->add_lang('ucp'); + $crawler = self::request('GET', 'ucp.php?i=ucp_notifications'); + + // At least one notification should exist + $this->assertGreaterThan(0, $crawler->filter('#notification_list_button strong')->text()); + + // Get form token + $link = $crawler->selectLink($this->lang('NOTIFICATIONS_MARK_ALL_READ'))->link()->getUri(); + $crawler = self::request('GET', substr($link, strpos($link, 'ucp.'))); + $form = $crawler->selectButton($this->lang('YES'))->form(); + $crawler = self::submit($form); + $this->assertEquals(0, $crawler->filter('#notification_list_button strong')->text()); + } } -- cgit v1.2.1 From fbf5911ac54c83d439121e90032afca0ec2a7fc4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 13 Nov 2013 17:38:58 +0100 Subject: [ticket/12016] Update functional tests to use service for event listeners PHPBB3-12016 --- tests/functional/fixtures/ext/foo/bar/config/services.yml | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/functional') diff --git a/tests/functional/fixtures/ext/foo/bar/config/services.yml b/tests/functional/fixtures/ext/foo/bar/config/services.yml index 3bca4c6567..64e1163408 100644 --- a/tests/functional/fixtures/ext/foo/bar/config/services.yml +++ b/tests/functional/fixtures/ext/foo/bar/config/services.yml @@ -4,3 +4,12 @@ services: arguments: - @controller.helper - @template + foo_bar.listener.permission: + class: foo\bar\event\permission + tags: + - { name: event.listener } + foo_bar.listener.user_setup: + class: foo\bar\event\user_setup + tags: + - { name: event.listener } + -- cgit v1.2.1 From 009a1303f59628417573b47b162690b057594953 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 14 Nov 2013 00:14:04 +0100 Subject: [ticket/12017] Remove IN_PHPBB defined check PHPBB3-12017 --- tests/functional/fixtures/ext/foo/bar/event/permission.php | 9 --------- tests/functional/fixtures/ext/foo/bar/event/user_setup.php | 9 --------- 2 files changed, 18 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/fixtures/ext/foo/bar/event/permission.php b/tests/functional/fixtures/ext/foo/bar/event/permission.php index 92e24074ad..9b319dd35f 100644 --- a/tests/functional/fixtures/ext/foo/bar/event/permission.php +++ b/tests/functional/fixtures/ext/foo/bar/event/permission.php @@ -10,15 +10,6 @@ namespace foo\bar\event; -/** -* @ignore -*/ - -if (!defined('IN_PHPBB')) -{ - exit; -} - /** * Event listener */ diff --git a/tests/functional/fixtures/ext/foo/bar/event/user_setup.php b/tests/functional/fixtures/ext/foo/bar/event/user_setup.php index 1409f97470..8fa7ac97da 100644 --- a/tests/functional/fixtures/ext/foo/bar/event/user_setup.php +++ b/tests/functional/fixtures/ext/foo/bar/event/user_setup.php @@ -10,15 +10,6 @@ namespace foo\bar\event; -/** -* @ignore -*/ - -if (!defined('IN_PHPBB')) -{ - exit; -} - /** * Event listener */ -- cgit v1.2.1 From 4e2bb6ef535a5188aeda6d04286b6b9bb8825c72 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 14 Nov 2013 00:14:53 +0100 Subject: [ticket/12017] Copy config/ dir so events work PHPBB3-12017 --- tests/functional/extension_controller_test.php | 2 ++ tests/functional/extension_global_lang_test.php | 3 ++- tests/functional/extension_permission_lang_test.php | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) (limited to 'tests/functional') diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 41bd48c204..37752b8fbb 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -19,6 +19,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c static protected $fixtures = array( 'foo/bar/config/', 'foo/bar/controller/', + 'foo/bar/event/', + 'foo/bar/language/en/', 'foo/bar/styles/prosilver/template/', ); diff --git a/tests/functional/extension_global_lang_test.php b/tests/functional/extension_global_lang_test.php index fb8f87e6de..094eda8257 100644 --- a/tests/functional/extension_global_lang_test.php +++ b/tests/functional/extension_global_lang_test.php @@ -17,8 +17,9 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_ static private $helper; static protected $fixtures = array( - 'foo/bar/language/en/', + 'foo/bar/config/', 'foo/bar/event/', + 'foo/bar/language/en/', ); static public function setUpBeforeClass() diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index 19adb89819..e922abdaf1 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -17,8 +17,9 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t static private $helper; static protected $fixtures = array( - 'foo/bar/language/en/', + 'foo/bar/config/', 'foo/bar/event/', + 'foo/bar/language/en/', ); static public function setUpBeforeClass() -- cgit v1.2.1 From 1e73e0c9544d2601127b7179fdbd0724370e8b04 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 14 Nov 2013 00:15:23 +0100 Subject: [ticket/12017] Fix phpbb requirement in composer.json PHPBB3-12017 --- tests/functional/fixtures/ext/foo/bar/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/functional') diff --git a/tests/functional/fixtures/ext/foo/bar/composer.json b/tests/functional/fixtures/ext/foo/bar/composer.json index cb9dbc9514..e3e5fc21cd 100644 --- a/tests/functional/fixtures/ext/foo/bar/composer.json +++ b/tests/functional/fixtures/ext/foo/bar/composer.json @@ -14,7 +14,7 @@ }], "require": { "php": ">=5.3", - "phpbb": "3.1.*@dev" + "phpbb/phpbb": "3.1.*@dev" }, "extra": { "display-name": "phpBB 3.1 Extension Testing" -- cgit v1.2.1 From 9fbeae3e0ca373f98a6102266f2bb75653e5211a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 3 Dec 2013 17:57:34 +0100 Subject: [ticket/12026] Add functional test for ucp extension module PHPBB3-12026 --- tests/functional/extension_module_test.php | 45 +++++++++++++++++++--- .../foo/bar/styles/prosilver/template/foobar.html | 3 ++ .../fixtures/ext/foo/bar/ucp/main_info.php | 26 +++++++++++++ .../fixtures/ext/foo/bar/ucp/main_module.php | 22 +++++++++++ 4 files changed, 91 insertions(+), 5 deletions(-) create mode 100644 tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar.html create mode 100644 tests/functional/fixtures/ext/foo/bar/ucp/main_info.php create mode 100644 tests/functional/fixtures/ext/foo/bar/ucp/main_module.php (limited to 'tests/functional') diff --git a/tests/functional/extension_module_test.php b/tests/functional/extension_module_test.php index 090cd38daf..ba025d582e 100644 --- a/tests/functional/extension_module_test.php +++ b/tests/functional/extension_module_test.php @@ -80,18 +80,53 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case ); $modules->update_module_data($module_data, true); + $parent_data = array( + 'module_basename' => '', + 'module_enabled' => 1, + 'module_display' => 1, + 'parent_id' => 0, + 'module_class' => 'ucp', + 'module_langname' => 'UCP_FOOBAR_TITLE', + 'module_mode' => '', + 'module_auth' => '', + ); + $modules->update_module_data($parent_data, true); + + $module_data = array( + 'module_basename' => 'foo\\bar\\ucp\\main_module', + 'module_enabled' => 1, + 'module_display' => 1, + 'parent_id' => $parent_data['module_id'], + 'module_class' => 'ucp', + 'module_langname' => 'UCP_FOOBAR_TITLE', + 'module_mode' => 'mode', + 'module_auth' => '', + ); + $modules->update_module_data($module_data, true); + $this->purge_cache(); } - /** - * Check a controller for extension foo/bar. - */ - public function test_foo_bar() + public function test_acp() { $this->login(); $this->admin_login(); + $crawler = self::request('GET', 'adm/index.php?i=foo%5cbar%5cacp%5cmain_module&mode=mode&sid=' . $this->sid); - $this->assertContains("Bertie rulez!", $crawler->filter('#main')->text()); + $this->assertContains('Bertie rulez!', $crawler->filter('#main')->text()); + } + + public function test_ucp() + { + $this->login(); + + $crawler = self::request('GET', 'ucp.php?sid=' . $this->sid); + $this->assertContains('UCP_FOOBAR_TITLE', $crawler->filter('#tabs')->text()); + + $link = $crawler->selectLink('UCP_FOOBAR_TITLE')->link()->getUri(); + $crawler = self::request('GET', substr($link, strpos($link, 'ucp.'))); + $this->assertContains('UCP Extension Template Test Passed!', $crawler->filter('#content')->text()); + $this->phpbb_extension_manager->purge('foo/bar'); } } diff --git a/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar.html b/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar.html new file mode 100644 index 0000000000..cbded623f4 --- /dev/null +++ b/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar.html @@ -0,0 +1,3 @@ + +
UCP Extension Template Test Passed!
+ diff --git a/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php b/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php new file mode 100644 index 0000000000..2ba37f3050 --- /dev/null +++ b/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php @@ -0,0 +1,26 @@ + '\foo\bar\ucp\main_module', + 'title' => 'ACP_FOOBAR_TITLE', + 'version' => '1.0.0', + 'modes' => array( + 'mode' => array('title' => 'ACP_FOOBAR_MODE', 'auth' => '', 'cat' => array('ACP_FOOBAR_TITLE')), + ), + ); + } +} diff --git a/tests/functional/fixtures/ext/foo/bar/ucp/main_module.php b/tests/functional/fixtures/ext/foo/bar/ucp/main_module.php new file mode 100644 index 0000000000..cd3dacc9db --- /dev/null +++ b/tests/functional/fixtures/ext/foo/bar/ucp/main_module.php @@ -0,0 +1,22 @@ +tpl_name = 'foobar'; + $this->page_title = 'Bertie'; + } +} -- cgit v1.2.1 From abb2def48d7a946fd4d0a67f88682c9fa2556223 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 4 Dec 2013 15:42:17 +0100 Subject: [ticket/11842] Use avatar_data for obtaining driver that should be deleted PHPBB3-11842 --- tests/functional/avatar_acp_groups_test.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/functional') diff --git a/tests/functional/avatar_acp_groups_test.php b/tests/functional/avatar_acp_groups_test.php index 5e908bc6da..5f767b44f2 100644 --- a/tests/functional/avatar_acp_groups_test.php +++ b/tests/functional/avatar_acp_groups_test.php @@ -69,4 +69,13 @@ class phpbb_functional_avatar_acp_groups_test extends phpbb_functional_common_av { $this->assert_avatar_submit($expected, $avatar_type, $data); } + + // Test if avatar was really deleted + public function test_no_avatar_acp_groups() + { + $crawler = self::request('GET', $this->get_url() . '&sid=' . $this->sid); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form_data = $form->getValues(); + $this->assertEmpty($form_data['avatar_type']); + } } -- cgit v1.2.1 From 80fa658e8fc94972349b5f0d01f93afba7744e0e Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 4 Dec 2013 15:58:07 +0100 Subject: [ticket/11842] Add functional test for creating group PHPBB3-11842 --- tests/functional/group_create_test.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/functional/group_create_test.php (limited to 'tests/functional') diff --git a/tests/functional/group_create_test.php b/tests/functional/group_create_test.php new file mode 100644 index 0000000000..96780069f7 --- /dev/null +++ b/tests/functional/group_create_test.php @@ -0,0 +1,31 @@ +login(); + $this->admin_login(); + $this->add_lang('acp/groups'); + + $crawler = self::request('GET', 'adm/index.php?i=acp_groups&mode=manage&sid=' . $this->sid); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $crawler = self::submit($form, array('group_name' => 'testtest')); + + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $crawler = self::submit($form, array('group_name' => 'testtest')); + + $this->assertContainsLang('GROUP_CREATED', $crawler->filter('#main')->text()); + } +} -- cgit v1.2.1