diff options
Diffstat (limited to 'tests/functional')
22 files changed, 601 insertions, 54 deletions
diff --git a/tests/functional/acp_attachments_test.php b/tests/functional/acp_attachments_test.php new file mode 100644 index 0000000000..8e810a508a --- /dev/null +++ b/tests/functional/acp_attachments_test.php @@ -0,0 +1,78 @@ +<?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. + * + */ + +/** + * @group functional + */ +class phpbb_functional_acp_attachments_test extends phpbb_functional_test_case +{ + public function data_imagick_path_linux() + { + return array( + array('/usr/bin', 'Configuration updated successfully'), + array('/usr/foobar', 'The entered path “/usr/foobar” does not exist.'), + array('/usr/bin/which', 'The entered path “/usr/bin/which” is not a directory.'), + ); + } + + /** + * @dataProvider data_imagick_path_linux + */ + public function test_imagick_path_linux($imagick_path, $expected) + { + if (strtolower(substr(PHP_OS, 0, 5)) !== 'linux') + { + $this->markTestSkipped('Unable to test linux specific paths on other OS.'); + } + + $this->login(); + $this->admin_login(); + + $crawler = self::request('GET', 'adm/index.php?i=attachments&mode=attach&sid=' . $this->sid); + + $form = $crawler->selectButton('Submit')->form(array('config[img_imagick]' => $imagick_path)); + + $crawler = self::submit($form); + $this->assertContains($expected, $crawler->filter('#main')->text()); + } + + public function data_imagick_path_windows() + { + return array( + array('C:\Windows', 'Configuration updated successfully'), + array('C:\Windows\foobar1', 'The entered path “C:\Windows\foobar1” does not exist.'), + array('C:\Windows\explorer.exe', 'The entered path “C:\Windows\explorer.exe” is not a directory.'), + ); + } + + /** + * @dataProvider data_imagick_path_windows + */ + public function test_imagick_path_windows($imagick_path, $expected) + { + if (strtolower(substr(PHP_OS, 0, 3)) !== 'win') + { + $this->markTestSkipped('Unable to test windows specific paths on other OS.'); + } + + $this->login(); + $this->admin_login(); + + $crawler = self::request('GET', 'adm/index.php?i=attachments&mode=attach&sid=' . $this->sid); + + $form = $crawler->selectButton('Submit')->form(array('config[img_imagick]' => $imagick_path)); + + $crawler = self::submit($form); + $this->assertContains($expected, $crawler->filter('#main')->text()); + } +} diff --git a/tests/functional/acp_groups_test.php b/tests/functional/acp_groups_test.php index 4eb4747572..9dfdc93474 100644 --- a/tests/functional/acp_groups_test.php +++ b/tests/functional/acp_groups_test.php @@ -11,12 +11,12 @@ * */ -require_once dirname(__FILE__) . '/common_groups_test.php'; +require_once dirname(__FILE__) . '/common_groups_test_case.php'; /** * @group functional */ -class phpbb_functional_acp_groups_test extends phpbb_functional_common_groups_test +class phpbb_functional_acp_groups_test extends phpbb_functional_common_groups_test_case { protected $form_data; diff --git a/tests/functional/acp_profile_field_test.php b/tests/functional/acp_profile_field_test.php new file mode 100644 index 0000000000..88df782faa --- /dev/null +++ b/tests/functional/acp_profile_field_test.php @@ -0,0 +1,71 @@ +<?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. +* +*/ + +/** +* @group functional +*/ +class phpbb_functional_acp_profile_field_test extends phpbb_functional_test_case +{ + public function setUp() + { + parent::setUp(); + + $this->login(); + $this->admin_login(); + $this->add_lang('acp/profile'); + } + + public function data_add_profile_field() + { + return array( + array('bool', 'profilefields.type.bool', + array( + 'lang_options[0]' => 'foo', + 'lang_options[1]' => 'bar', + ), + array(), + ), + array('dropdown', 'profilefields.type.dropdown', + array( + 'lang_options' => "foo\nbar\nbar\nfoo", + ), + array(), + ), + ); + } + + /** + * @dataProvider data_add_profile_field + */ + public function test_add_profile_field($name, $type, $page1_settings, $page2_settings) + { + // Custom profile fields page + $crawler = self::request('GET', 'adm/index.php?i=acp_profile&mode=profile&sid=' . $this->sid); + // these language strings are html + $form = $crawler->selectButton('Create new field')->form(array( + 'field_ident' => $name, + 'field_type' => $type, + )); + $crawler = self::submit($form); + + // Fill form for profile field options + $form = $crawler->selectButton('Profile type specific options')->form($page1_settings); + $crawler = self::submit($form); + + // Fill form for profile field specific options + $form = $crawler->selectButton('Save')->form($page2_settings); + $crawler= self::submit($form); + + $this->assertContainsLang('ADDED_PROFILE_FIELD', $crawler->text()); + } +} diff --git a/tests/functional/acp_registration_test.php b/tests/functional/acp_registration_test.php new file mode 100644 index 0000000000..ef9843679e --- /dev/null +++ b/tests/functional/acp_registration_test.php @@ -0,0 +1,55 @@ +<?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. +* +*/ + +/** +* @group functional +*/ +class phpbb_functional_acp_registration_test extends phpbb_functional_test_case +{ + protected function set_email_enable($db, $status) + { + $sql = "UPDATE phpbb_config + SET config_value = '" . (($status) ? '1' : '0') . "' + WHERE config_name = 'email_enable'"; + $db->sql_query($sql); + + $this->purge_cache(); + } + + public function test_submitting_activation_method() + { + $db = $this->get_db(); + + $this->set_email_enable($db, false); + + $this->add_lang('acp/board'); + $this->login(); + $this->admin_login(); + + $crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=registration&sid=' . $this->sid); + $this->assertContainsLang('ACP_REGISTER_SETTINGS_EXPLAIN', $this->get_content()); + + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['config[require_activation]']->select(USER_ACTIVATION_ADMIN); + $crawler = self::submit($form); + $this->assertContainsLang('ACC_ACTIVATION_WARNING', $crawler->filter('div.main')->text()); + + $crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=registration&sid=' . $this->sid); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['config[require_activation]']->select(USER_ACTIVATION_NONE); + $crawler = self::submit($form); + $this->assertNotContainsLang('ACC_ACTIVATION_WARNING', $crawler->filter('div.main')->text()); + + $this->set_email_enable($db, true); + } +} diff --git a/tests/functional/auth_test.php b/tests/functional/auth_test.php index b4b4279bf1..76e1709afb 100644 --- a/tests/functional/auth_test.php +++ b/tests/functional/auth_test.php @@ -34,6 +34,25 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case } /** + * @dependsOn test_login_other + */ + public function test_login_ucp_other_auth_provider() + { + global $cache, $config; + $cache = new phpbb_mock_null_cache; + $db = $this->get_db(); + $sql = 'UPDATE ' . CONFIG_TABLE . " SET config_value = 'foobar' WHERE config_name = 'auth_method'"; + $db->sql_query($sql); + $config['auth_method'] = 'foobar'; + $this->login('anothertestuser'); + $crawler = self::request('GET', 'index.php'); + $this->assertContains('anothertestuser', $crawler->filter('#username_logged_in')->text()); + $sql = 'UPDATE ' . CONFIG_TABLE . " SET config_value = 'db' WHERE config_name = 'auth_method'"; + $db->sql_query($sql); + $config['auth_method'] = 'db'; + } + + /** * @depends test_login */ public function test_logout() diff --git a/tests/functional/avatar_acp_groups_test.php b/tests/functional/avatar_acp_groups_test.php index 925335a2f7..ca8c84ab2e 100644 --- a/tests/functional/avatar_acp_groups_test.php +++ b/tests/functional/avatar_acp_groups_test.php @@ -11,12 +11,12 @@ * */ -require_once dirname(__FILE__) . '/common_avatar_test.php'; +require_once dirname(__FILE__) . '/common_avatar_test_case.php'; /** * @group functional */ -class phpbb_functional_avatar_acp_groups_test extends phpbb_functional_common_avatar_test +class phpbb_functional_avatar_acp_groups_test extends phpbb_functional_common_avatar_test_case { public function get_url() { diff --git a/tests/functional/avatar_acp_users_test.php b/tests/functional/avatar_acp_users_test.php index 5eca473157..8b05a28658 100644 --- a/tests/functional/avatar_acp_users_test.php +++ b/tests/functional/avatar_acp_users_test.php @@ -11,12 +11,12 @@ * */ -require_once dirname(__FILE__) . '/common_avatar_test.php'; +require_once dirname(__FILE__) . '/common_avatar_test_case.php'; /** * @group functional */ -class phpbb_functional_avatar_acp_users_test extends phpbb_functional_common_avatar_test +class phpbb_functional_avatar_acp_users_test extends phpbb_functional_common_avatar_test_case { public function get_url() { diff --git a/tests/functional/avatar_ucp_groups_test.php b/tests/functional/avatar_ucp_groups_test.php index 1e8ca911c6..52ef67543e 100644 --- a/tests/functional/avatar_ucp_groups_test.php +++ b/tests/functional/avatar_ucp_groups_test.php @@ -10,12 +10,12 @@ * the docs/CREDITS.txt file. * */ -require_once dirname(__FILE__) . '/common_avatar_test.php'; +require_once dirname(__FILE__) . '/common_avatar_test_case.php'; /** * @group functional */ -class phpbb_functional_avatar_ucp_groups_test extends phpbb_functional_common_avatar_test +class phpbb_functional_avatar_ucp_groups_test extends phpbb_functional_common_avatar_test_case { public function get_url() { diff --git a/tests/functional/avatar_ucp_users_test.php b/tests/functional/avatar_ucp_users_test.php index 972bfa0fb2..2f0832e092 100644 --- a/tests/functional/avatar_ucp_users_test.php +++ b/tests/functional/avatar_ucp_users_test.php @@ -11,12 +11,12 @@ * */ -require_once dirname(__FILE__) . '/common_avatar_test.php'; +require_once dirname(__FILE__) . '/common_avatar_test_case.php'; /** * @group functional */ -class phpbb_functional_avatar_ucp_users_test extends phpbb_functional_common_avatar_test +class phpbb_functional_avatar_ucp_users_test extends phpbb_functional_common_avatar_test_case { public function get_url() { diff --git a/tests/functional/common_avatar_test.php b/tests/functional/common_avatar_test_case.php index 82d7136c98..924eb1273c 100644 --- a/tests/functional/common_avatar_test.php +++ b/tests/functional/common_avatar_test_case.php @@ -14,7 +14,7 @@ /** * @group functional */ -abstract class phpbb_functional_common_avatar_test extends phpbb_functional_test_case +abstract class phpbb_functional_common_avatar_test_case extends phpbb_functional_test_case { private $path; private $form_content; @@ -62,7 +62,7 @@ abstract class phpbb_functional_common_avatar_test extends phpbb_functional_test { if (is_array($value)) { - $form[$key]->$value[0]($value[1]); + $form[$key]->{$value[0]}($value[1]); } else { diff --git a/tests/functional/common_groups_test.php b/tests/functional/common_groups_test_case.php index 748d4d5e0a..521b7c84d2 100644 --- a/tests/functional/common_groups_test.php +++ b/tests/functional/common_groups_test_case.php @@ -14,7 +14,7 @@ /** * @group functional */ -abstract class phpbb_functional_common_groups_test extends phpbb_functional_test_case +abstract class phpbb_functional_common_groups_test_case extends phpbb_functional_test_case { abstract protected function get_url(); diff --git a/tests/functional/download_test.php b/tests/functional/download_test.php index 4e4995c21e..1e863210e6 100644 --- a/tests/functional/download_test.php +++ b/tests/functional/download_test.php @@ -66,6 +66,11 @@ class phpbb_functional_download_test extends phpbb_functional_test_case public function test_download_accessible() { + if (!class_exists('finfo')) + { + $this->markTestSkipped('Unable to run test with fileinfo disabled'); + } + $this->load_ids(array( 'forums' => array( 'Download #1', @@ -118,6 +123,11 @@ class phpbb_functional_download_test extends phpbb_functional_test_case public function test_download_softdeleted_post() { + if (!class_exists('finfo')) + { + $this->markTestSkipped('Unable to run test with fileinfo disabled'); + } + $this->load_ids(array( 'forums' => array( 'Download #1', @@ -180,6 +190,11 @@ class phpbb_functional_download_test extends phpbb_functional_test_case public function test_download_softdeleted_topic() { + if (!class_exists('finfo')) + { + $this->markTestSkipped('Unable to run test with fileinfo disabled'); + } + $this->load_ids(array( 'forums' => array( 'Download #1', diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index 7aa2d0da7d..9041c8dc69 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -322,15 +322,9 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $post = $this->create_topic($this->data['forums']['Feeds #news'], 'Feeds #news - Topic #1', 'This is a test topic posted by the testing framework.'); $this->data['topics']['Feeds #news - Topic #1'] = (int) $post['topic_id']; - // Travis is too fast, so we have to wait - sleep(1); - $post = $this->create_topic($this->data['forums']['Feeds #news'], 'Feeds #news - Topic #2', 'This is a test topic posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); - // Travis is too fast, so we have to wait - sleep(1); - $this->assertContains('Feeds #news - Topic #2', $crawler->filter('html')->text()); $this->data['topics']['Feeds #news - Topic #2'] = (int) $post['topic_id']; $this->data['posts']['Feeds #news - Topic #2'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p'); @@ -456,9 +450,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $post = $this->create_topic($this->data['forums']['Feeds #1'], 'Feeds #1 - Topic #1', 'This is a test topic posted by the testing framework.'); $this->data['topics']['Feeds #1 - Topic #1'] = (int) $post['topic_id']; - // Travis is too fast, so we have to wait - sleep(1); - $post = $this->create_topic($this->data['forums']['Feeds #1.1'], 'Feeds #1.1 - Topic #1', 'This is a test topic posted by the testing framework.'); $this->data['topics']['Feeds #1.1 - Topic #1'] = (int) $post['topic_id']; } @@ -494,9 +485,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $post = $this->create_topic($this->data['forums']['Feeds #1'], 'Feeds #1 - Topic #2', 'This is a test topic posted by the testing framework.'); $this->data['topics']['Feeds #1 - Topic #2'] = (int) $post['topic_id']; - // Travis is too fast, so we have to wait - sleep(1); - // Test creating a reply $post2 = $this->create_post($this->data['forums']['Feeds #1'], $post['topic_id'], 'Re: Feeds #1 - Topic #2', 'This is a test post posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}"); @@ -852,9 +840,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case 'Feeds #1.1', ), )); - - // We have to wait because of the flood interval. - sleep(15); + $this->set_flood_interval(0); $this->login('disapprove_user'); $post = $this->create_topic($this->data['forums']['Feeds #1.1'], 'Feeds #1.1 - Topic #3', 'This is a test topic posted by the testing framework.', array(), 'POST_STORED_MOD'); @@ -862,6 +848,27 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Feeds #1.1']}&sid={$this->sid}"); $this->assertNotContains('Feeds #1.1 - Topic #3', $crawler->filter('html')->text()); + + $this->logout(); + $this->set_flood_interval(15); + } + + protected function set_flood_interval($flood_interval) + { + $this->login(); + $this->admin_login(); + + $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post'); + + $form = $crawler->selectButton('Submit')->form(); + $values = $form->getValues(); + + $values["config[flood_interval]"] = $flood_interval; + $form->setValues($values); + $crawler = self::submit($form); + $this->assertGreaterThan(0, $crawler->filter('.successbox')->count()); + + $this->logout(); } public function test_feeds_unapproved_topic_admin() diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php index b8c48389e0..d381fa1ae2 100644 --- a/tests/functional/fileupload_form_test.php +++ b/tests/functional/fileupload_form_test.php @@ -93,23 +93,32 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case $this->login(); $this->admin_login(); $this->add_lang('ucp'); - $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_attachments&mode=attach'); - $form = $crawler->selectButton('Submit')->form(); - $values = $form->getValues(); + // Make sure check_attachment_content is set to false + $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_attachments&mode=attach'); - $values["config[check_attachment_content]"] = 0; - $form->setValues($values); - $crawler = self::submit($form); + $form = $crawler->selectButton('Submit')->form(array( + 'config[check_attachment_content]' => 0, + 'config[img_imagick]' => '', + )); + self::submit($form); // Request index for correct URL - $crawler = self::request('GET', 'index.php?sid=' . $this->sid); + self::request('GET', 'index.php?sid=' . $this->sid); $crawler = $this->upload_file('disallowed.jpg', 'image/jpeg'); // Hitting the UNABLE_GET_IMAGE_SIZE error means we passed the // DISALLOWED_CONTENT check $this->assertContainsLang('UNABLE_GET_IMAGE_SIZE', $crawler->text()); + + // Reset check_attachment_content to default (enabled) + $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_attachments&mode=attach'); + + $form = $crawler->selectButton('Submit')->form(array( + 'config[check_attachment_content]' => 1, + )); + self::submit($form); } public function test_too_large() diff --git a/tests/functional/fixtures/ext/foo/bar/config/routing.yml b/tests/functional/fixtures/ext/foo/bar/config/routing.yml index 08bc73038f..374a58046d 100644 --- a/tests/functional/fixtures/ext/foo/bar/config/routing.yml +++ b/tests/functional/fixtures/ext/foo/bar/config/routing.yml @@ -1,35 +1,35 @@ foo_bar_controller: - pattern: /foo/bar + path: /foo/bar defaults: { _controller: foo_bar.controller:handle } foo_baz_controller: - pattern: /foo/baz + path: /foo/baz defaults: { _controller: foo_bar.controller:baz } foo_template_controller: - pattern: /foo/template + path: /foo/template defaults: { _controller: foo_bar.controller:template } foo_exception_controller: - pattern: /foo/exception + path: /foo/exception defaults: { _controller: foo_bar.controller:exception } foo_login_redirect_controller: - pattern: /foo/login_redirect + path: /foo/login_redirect defaults: { _controller: foo_bar.controller:login_redirect } foo_redirect_controller: - pattern: /foo/redirect + path: /foo/redirect defaults: { _controller: foo_bar.controller:redirect } foo_index_controller: - pattern: /index + path: /index defaults: { _controller: foo_bar.controller:redirect } foo_tests_index_controller: - pattern: /tests/index + path: /tests/index defaults: { _controller: foo_bar.controller:redirect } foo_tests_dotdot_index_controller: - pattern: /tests/../index + path: /tests/../index defaults: { _controller: foo_bar.controller:redirect } diff --git a/tests/functional/fixtures/ext/foo/foo/config/resource.yml b/tests/functional/fixtures/ext/foo/foo/config/resource.yml index ed1d018016..4f2b9cce70 100644 --- a/tests/functional/fixtures/ext/foo/foo/config/resource.yml +++ b/tests/functional/fixtures/ext/foo/foo/config/resource.yml @@ -1,3 +1,3 @@ foo_foo_controller: - pattern: /foo + path: /foo defaults: { _controller: foo_foo.controller:handle } diff --git a/tests/functional/memberlist_test.php b/tests/functional/memberlist_test.php index c76ba6e37d..1da5c39401 100644 --- a/tests/functional/memberlist_test.php +++ b/tests/functional/memberlist_test.php @@ -106,4 +106,32 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case $this->assertContains('admin', $crawler->eq(0)->text()); $this->assertNotContains('admin', $crawler->eq(1)->text()); } + + public function test_group_rank() + { + copy(__DIR__ . '/fixtures/files/valid.jpg', __DIR__ . '/../../phpBB/images/ranks/valid.jpg'); + + $this->login(); + $this->admin_login(); + $this->add_lang(array('acp/groups', 'acp/posting')); + + // Set a group rank to the registered users + $crawler = self::request('GET', "adm/index.php?sid={$this->sid}&i=acp_groups&mode=manage&action=edit&g=2"); + $form = $crawler->selectButton('Submit')->form(); + $form['group_rank']->select('1'); + $crawler = self::submit($form); + $this->assertContainsLang('GROUP_UPDATED', $crawler->filter('.successbox')->text()); + + // Set a rank image for site_admin + $crawler = self::request('GET', "adm/index.php?sid={$this->sid}&i=acp_ranks&mode=ranks&action=edit&id=1"); + $form = $crawler->selectButton('Submit')->form(); + $form['rank_image']->select('valid.jpg'); + $crawler = self::submit($form); + $this->assertContainsLang('RANK_UPDATED', $crawler->filter('.successbox')->text()); + + $crawler = self::request('GET', 'memberlist.php?mode=group&g=2'); + $this->assertContains('memberlist-test-user', $crawler->text()); + + unlink(__DIR__ . '/../../phpBB/images/ranks/valid.jpg'); + } } diff --git a/tests/functional/notification_test.php b/tests/functional/notification_test.php index 667d268b1e..ec03f7a6a4 100644 --- a/tests/functional/notification_test.php +++ b/tests/functional/notification_test.php @@ -82,8 +82,6 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case // 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()); } } diff --git a/tests/functional/prune_shadow_topic_test.php b/tests/functional/prune_shadow_topic_test.php index 84f07e9802..c014119b98 100644 --- a/tests/functional/prune_shadow_topic_test.php +++ b/tests/functional/prune_shadow_topic_test.php @@ -62,7 +62,7 @@ class phpbb_functional_prune_shadow_topic_test extends phpbb_functional_test_cas $crawler = self::request('GET', "viewtopic.php?t={$this->post['topic_id']}&sid={$this->sid}"); $this->assertContains('Prune Shadow #1', $crawler->filter('html')->text()); - $this->data['topics']['Prune Shadow #1'] = (int) $post['topic_id']; + $this->data['topics']['Prune Shadow #1'] = (int) $this->post['topic_id']; $this->data['posts']['Prune Shadow #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p'); $this->assert_forum_details($this->data['forums']['Prune Shadow'], array( @@ -129,8 +129,8 @@ class phpbb_functional_prune_shadow_topic_test extends phpbb_functional_test_cas $result = $this->db->sql_query($sql); $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Prune Shadow']}&sid={$this->sid}"); - $cron_link = $crawler->filter('img')->last()->attr('src'); - $crawler = self::request('GET', $cron_link . "&sid={$this->sid}", array(), false); + $this->assertNotEmpty($crawler->filter('img')->last()->attr('src')); + self::request('GET', "cron.php?cron_type=cron.task.core.prune_shadow_topics&f={$this->data['forums']['Prune Shadow']}&sid={$this->sid}", array(), false); $this->assert_forum_details($this->data['forums']['Prune Shadow'], array( 'forum_posts_approved' => 0, diff --git a/tests/functional/registration_test.php b/tests/functional/registration_test.php index 45a684db19..690f4ae9f2 100644 --- a/tests/functional/registration_test.php +++ b/tests/functional/registration_test.php @@ -45,12 +45,23 @@ class phpbb_functional_registration_test extends phpbb_functional_test_case $form = $crawler->selectButton('Submit')->form(array( 'username' => 'user-reg-test', 'email' => 'user-reg-test@phpbb.com', - 'new_password' => 'testtest', - 'password_confirm' => 'testtest', + 'new_password' => 'user-reg-testuser-reg-test', + 'password_confirm' => 'user-reg-testuser-reg-test', )); $form['tz']->select('Europe/Berlin'); $crawler = self::submit($form); $this->assertContainsLang('ACCOUNT_ADDED', $crawler->filter('#message')->text()); } + + /** + * @depends test_register_new_account + */ + public function test_default_subscription_options() + { + $this->login('user-reg-test'); + $crawler = self::request('GET', 'ucp.php?i=ucp_notifications&mode=notification_options&sid=' . $this->sid); + $this->assert_checkbox_is_checked($crawler, 'notification.type.post_notification.method.email'); + $this->assert_checkbox_is_checked($crawler, 'notification.type.topic_notification.method.email'); + } } diff --git a/tests/functional/ucp_groups_test.php b/tests/functional/ucp_groups_test.php index 2b075b37a5..cd18a0fcae 100644 --- a/tests/functional/ucp_groups_test.php +++ b/tests/functional/ucp_groups_test.php @@ -11,12 +11,12 @@ * */ -require_once dirname(__FILE__) . '/common_groups_test.php'; +require_once dirname(__FILE__) . '/common_groups_test_case.php'; /** * @group functional */ -class phpbb_functional_ucp_groups_test extends phpbb_functional_common_groups_test +class phpbb_functional_ucp_groups_test extends phpbb_functional_common_groups_test_case { protected $db; diff --git a/tests/functional/viewforum_paging_test.php b/tests/functional/viewforum_paging_test.php new file mode 100644 index 0000000000..4a574bebbb --- /dev/null +++ b/tests/functional/viewforum_paging_test.php @@ -0,0 +1,256 @@ +<?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. +* +*/ + +/** +* @group functional +*/ +class viewforum_paging_test extends phpbb_functional_test_case +{ + protected $data = array(); + + public function test_setup_forums() + { + $this->login(); + $this->admin_login(); + + $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}"); + $form = $crawler->selectButton('addforum')->form(array( + 'forum_name' => 'Viewforum Pagination Test #1', + )); + $crawler = self::submit($form); + $form = $crawler->selectButton('update')->form(array( + 'forum_perm_from' => 2, + )); + self::submit($form); + + $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}"); + $form = $crawler->selectButton('addforum')->form(array( + 'forum_name' => 'Viewforum Pagination Test #2', + )); + $crawler = self::submit($form); + $form = $crawler->selectButton('update')->form(array( + 'forum_perm_from' => 2, + )); + self::submit($form); + + $this->set_post_settings(array( + 'flood_interval' => 0, + 'topics_per_page' => 3, + )); + } + + public function test_create_posts() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Viewforum Pagination Test #1', + 'Viewforum Pagination Test #2', + ), + )); + + $this->assert_forum_details($this->data['forums']['Viewforum Pagination Test #1'], array( + 'forum_posts_approved' => 0, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 0, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + 'forum_last_post_id' => 0, + ), 'initial comparison'); + + for ($topic_id = 1; $topic_id <= 6; $topic_id++) + { + $this->create_topic($this->data['forums']['Viewforum Pagination Test #1'], 'Viewforum Pagination TestTopic #' . $topic_id, 'This is a test topic posted by the testing framework.'); + } + + $this->create_topic($this->data['forums']['Viewforum Pagination Test #2'], 'Viewforum Pagination TestTopic #GA1', 'This is a test topic posted by the testing framework.', array( + 'topic_type' => POST_GLOBAL, + )); + + $this->assert_forum_details($this->data['forums']['Viewforum Pagination Test #1'], array( + 'forum_posts_approved' => 6, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 6, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + ), 'after creating topics'); + + $this->assert_forum_details($this->data['forums']['Viewforum Pagination Test #2'], array( + 'forum_posts_approved' => 1, + 'forum_posts_unapproved' => 0, + 'forum_posts_softdeleted' => 0, + 'forum_topics_approved' => 1, + 'forum_topics_unapproved' => 0, + 'forum_topics_softdeleted' => 0, + ), 'after creating GA'); + + // Set flood interval back to 15 + $this->admin_login(); + $this->set_post_settings(array( + 'flood_interval' => 15, + )); + } + + public function test_viewforum_first_page() + { + $this->load_ids(array( + 'forums' => array( + 'Viewforum Pagination Test #1', + 'Viewforum Pagination Test #2', + ), + )); + $crawler = self::request('GET', 'viewforum.php?f=' . $this->data['forums']['Viewforum Pagination Test #1']); + + // Test the topics that are displayed + $topiclists = $crawler->filter('.forumbg .topics'); + $this->assertEquals(2, $topiclists->count()); + $topiclist = $topiclists->eq(0)->filter('li'); + $this->assertStringEndsWith('TestTopic #GA1', $topiclist->eq(0)->filter('.topictitle')->text()); + $topiclist = $topiclists->eq(1)->filter('li'); + $this->assertStringEndsWith('TestTopic #6', $topiclist->eq(0)->filter('.topictitle')->text()); + $this->assertStringEndsWith('TestTopic #5', $topiclist->eq(1)->filter('.topictitle')->text()); + $this->assertStringEndsWith('TestTopic #4', $topiclist->eq(2)->filter('.topictitle')->text()); + + // Test the pagination, should only have: 1 - 2 - Next + $this->assertEquals(2, $crawler->filter('div.pagination')->count()); + $top_pagination = $crawler->filter('div.pagination')->eq(0); + $this->assertEquals(3, $top_pagination->filter('li')->count(), 'Number of pagination items on page 1 does not match'); + $this->assertContains('1', $top_pagination->filter('li')->eq(0)->text()); + $this->assertContains('2', $top_pagination->filter('li')->eq(1)->text()); + $this->assertContainsLang('NEXT', $top_pagination->filter('li')->eq(2)->text()); + } + + public function test_viewforum_second_page() + { + $this->load_ids(array( + 'forums' => array( + 'Viewforum Pagination Test #1', + 'Viewforum Pagination Test #2', + ), + )); + $crawler = self::request('GET', 'viewforum.php?f=' . $this->data['forums']['Viewforum Pagination Test #1'] . '&start=3'); + + // Test the topics that are displayed + $topiclists = $crawler->filter('.forumbg .topics'); + $this->assertEquals(2, $topiclists->count()); + $topiclist = $topiclists->eq(0)->filter('li'); + $this->assertStringEndsWith('TestTopic #GA1', $topiclist->eq(0)->filter('.topictitle')->text()); + $topiclist = $topiclists->eq(1)->filter('li'); + $this->assertStringEndsWith('TestTopic #3', $topiclist->eq(0)->filter('.topictitle')->text()); + $this->assertStringEndsWith('TestTopic #2', $topiclist->eq(1)->filter('.topictitle')->text()); + $this->assertStringEndsWith('TestTopic #1', $topiclist->eq(2)->filter('.topictitle')->text()); + + // Test the pagination, should only have: Previous - 1 - 2 + $this->assertEquals(2, $crawler->filter('div.pagination')->count()); + $top_pagination = $crawler->filter('div.pagination')->eq(0); + $this->assertEquals(3, $top_pagination->filter('li')->count(), 'Number of pagination items on page 2 does not match'); + $this->assertContainsLang('PREVIOUS', $top_pagination->filter('li')->eq(0)->text()); + $this->assertContains('1', $top_pagination->filter('li')->eq(1)->text()); + $this->assertContains('2', $top_pagination->filter('li')->eq(2)->text()); + } + + protected function assert_forum_details($forum_id, $details, $additional_error_message = '') + { + $this->db = $this->get_db(); + + $sql = 'SELECT ' . implode(', ', array_keys($details)) . ' + FROM phpbb_forums + WHERE forum_id = ' . (int) $forum_id; + $result = $this->db->sql_query($sql); + $data = $this->db->sql_fetchrow($result); + $this->db->sql_freeresult($result); + + $this->assertEquals($details, $data, "Forum {$forum_id} does not match expected {$additional_error_message}"); + } + + /** + * Sets the post setting via the ACP page + * + * @param array $settings + */ + protected function set_post_settings($settings) + { + $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post'); + + $form = $crawler->selectButton('Submit')->form(); + $values = $form->getValues(); + + foreach ($settings as $setting => $value) + { + $values["config[{$setting}]"] = $value; + } + $form->setValues($values); + $crawler = self::submit($form); + $this->assertGreaterThan(0, $crawler->filter('.successbox')->count()); + } + + /** + * Loads forum, topic and post IDs + * + * @param array $data + */ + protected function load_ids($data) + { + $this->db = $this->get_db(); + + if (!empty($data['forums'])) + { + $sql = 'SELECT * + FROM phpbb_forums + WHERE ' . $this->db->sql_in_set('forum_name', $data['forums']); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + if (in_array($row['forum_name'], $data['forums'])) + { + $this->data['forums'][$row['forum_name']] = (int) $row['forum_id']; + } + } + $this->db->sql_freeresult($result); + } + + if (!empty($data['topics'])) + { + $sql = 'SELECT * + FROM phpbb_topics + WHERE ' . $this->db->sql_in_set('topic_title', $data['topics']); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + if (in_array($row['topic_title'], $data['topics'])) + { + $this->data['topics'][$row['topic_title']] = (int) $row['topic_id']; + } + } + $this->db->sql_freeresult($result); + } + + if (!empty($data['posts'])) + { + $sql = 'SELECT * + FROM phpbb_posts + WHERE ' . $this->db->sql_in_set('post_subject', $data['posts']); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + if (in_array($row['post_subject'], $data['posts'])) + { + $this->data['posts'][$row['post_subject']] = (int) $row['post_id']; + } + } + $this->db->sql_freeresult($result); + } + } +} |