diff options
author | David King <imkingdavid@gmail.com> | 2013-08-31 13:37:11 -0700 |
---|---|---|
committer | David King <imkingdavid@gmail.com> | 2013-08-31 13:37:11 -0700 |
commit | af1eb7466f11cdb0f851acfcacd957267e20e3ce (patch) | |
tree | 1c72f7436ffcaa0d355ee11a0375323dcf5731f6 /tests/functional | |
parent | 9485eea0987478da25327a06a4fd36943ca1c01c (diff) | |
parent | 9d6370751f1b998e3da448e16c1446b33ddd17d0 (diff) | |
download | forums-af1eb7466f11cdb0f851acfcacd957267e20e3ce.tar forums-af1eb7466f11cdb0f851acfcacd957267e20e3ce.tar.gz forums-af1eb7466f11cdb0f851acfcacd957267e20e3ce.tar.bz2 forums-af1eb7466f11cdb0f851acfcacd957267e20e3ce.tar.xz forums-af1eb7466f11cdb0f851acfcacd957267e20e3ce.zip |
Merge branch 'develop' into ticket/11215
Diffstat (limited to 'tests/functional')
18 files changed, 596 insertions, 18 deletions
diff --git a/tests/functional/avatar_acp_groups_test.php b/tests/functional/avatar_acp_groups_test.php new file mode 100644 index 0000000000..9fdc29cc76 --- /dev/null +++ b/tests/functional/avatar_acp_groups_test.php @@ -0,0 +1,63 @@ +<?php +/** + * + * @package testing + * @copyright (c) 2013 phpBB Group + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 + * + */ + +require_once dirname(__FILE__) . '/common_avatar_test.php'; + +/** + * @group functional + */ +class phpbb_functional_avatar_acp_groups_test extends phpbb_functional_common_avatar_test +{ + public function get_url() + { + return 'adm/index.php?i=acp_groups&mode=manage&action=edit&g=5'; + } + + public function avatar_acp_groups_data() + { + return array( + // Correct Gravatar + array( + 'GROUP_UPDATED', + 'avatar_driver_gravatar', + array( + 'avatar_gravatar_email' => 'test@example.com', + 'avatar_gravatar_width' => 80, + 'avatar_gravatar_height' => 80, + ), + ), + // Gravatar with incorrect size + array( + 'The submitted avatar is 120 wide and 120 high. Avatars must be at least 20 wide and 20 high, but no larger than 90 wide and 90 high.', + 'avatar_driver_gravatar', + array( + 'avatar_gravatar_email' => 'test@example.com', + 'avatar_gravatar_width' => 120, + 'avatar_gravatar_height' => 120, + ), + ), + // Delete avatar image to reset group settings + array( + 'GROUP_UPDATED', + 'avatar_driver_gravatar', + array( + 'avatar_delete' => array('tick', ''), + ), + ), + ); + } + + /** + * @dataProvider avatar_acp_groups_data + */ + public function test_avatar_acp_groups($expected, $avatar_type, $data) + { + $this->assert_avatar_submit($expected, $avatar_type, $data); + } +} diff --git a/tests/functional/avatar_acp_users_test.php b/tests/functional/avatar_acp_users_test.php new file mode 100644 index 0000000000..0afd05e530 --- /dev/null +++ b/tests/functional/avatar_acp_users_test.php @@ -0,0 +1,61 @@ +<?php +/** + * + * @package testing + * @copyright (c) 2013 phpBB Group + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 + * + */ + +require_once dirname(__FILE__) . '/common_avatar_test.php'; + +/** + * @group functional + */ +class phpbb_functional_avatar_acp_users_test extends phpbb_functional_common_avatar_test +{ + public function get_url() + { + return 'adm/index.php?i=acp_users&u=2&mode=avatar'; + } + + public function avatar_acp_users_data() + { + return array( + // Gravatar with incorrect email + array( + 'EMAIL_INVALID_EMAIL', + 'avatar_driver_gravatar', + array( + 'avatar_gravatar_email' => 'test.example.com', + 'avatar_gravatar_width' => 80, + 'avatar_gravatar_height' => 80, + ), + ), + // Remote avatar with correct link + array( + 'USER_AVATAR_UPDATED', + 'avatar_driver_upload', + array( + 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + ), + ), + // Reset avatar settings + array( + 'USER_AVATAR_UPDATED', + 'avatar_driver_gravatar', + array( + 'avatar_delete' => array('tick', ''), + ), + ), + ); + } + + /** + * @dataProvider avatar_acp_users_data + */ + public function test_avatar_acp_users($expected, $avatar_type, $data) + { + $this->assert_avatar_submit($expected, $avatar_type, $data); + } +} diff --git a/tests/functional/avatar_ucp_groups_test.php b/tests/functional/avatar_ucp_groups_test.php new file mode 100644 index 0000000000..233b7d36e1 --- /dev/null +++ b/tests/functional/avatar_ucp_groups_test.php @@ -0,0 +1,71 @@ +<?php +/** + * + * @package testing + * @copyright (c) 2013 phpBB Group + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 + * + */ + +require_once dirname(__FILE__) . '/common_avatar_test.php'; + +/** + * @group functional + */ +class phpbb_functional_avatar_ucp_groups_test extends phpbb_functional_common_avatar_test +{ + public function get_url() + { + return 'ucp.php?i=ucp_groups&mode=manage&action=edit&g=5'; + } + + public function avatar_ucp_groups_data() + { + return array( + // Incorrect URL + array( + 'AVATAR_URL_INVALID', + 'avatar_driver_upload', + array( + 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=80', + ), + ), + /* + // Does not work due to DomCrawler issue + // Valid file upload + array( + 'GROUP_UPDATED', + 'avatar_driver_upload', + array( + 'avatar_upload_file' => array('upload', $this->path . 'valid.jpg'), + ), + ), + */ + // Correct remote avatar + array( + 'GROUP_UPDATED', + 'avatar_driver_remote', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + array( + 'GROUP_UPDATED', + 'avatar_driver_gravatar', + array( + 'avatar_delete' => array('tick', ''), + ), + ), + ); + } + + /** + * @dataProvider avatar_ucp_groups_data + */ + public function test_avatar_ucp_groups($expected, $avatar_type, $data) + { + $this->assert_avatar_submit($expected, $avatar_type, $data); + } +} diff --git a/tests/functional/avatar_ucp_users_test.php b/tests/functional/avatar_ucp_users_test.php new file mode 100644 index 0000000000..f828559e0d --- /dev/null +++ b/tests/functional/avatar_ucp_users_test.php @@ -0,0 +1,78 @@ +<?php +/** + * + * @package testing + * @copyright (c) 2013 phpBB Group + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 + * + */ + +require_once dirname(__FILE__) . '/common_avatar_test.php'; + +/** + * @group functional + */ +class phpbb_functional_avatar_ucp_users_test extends phpbb_functional_common_avatar_test +{ + public function get_url() + { + return 'ucp.php?i=ucp_profile&mode=avatar'; + } + + public function avatar_ucp_groups_data() + { + return array( + // Gravatar with correct settings + array( + 'PROFILE_UPDATED', + 'avatar_driver_gravatar', + array( + 'avatar_gravatar_email' => 'test@example.com', + 'avatar_gravatar_width' => 80, + 'avatar_gravatar_height' => 80, + ), + ), + // Wrong driver selected + array( + 'NO_AVATAR_SELECTED', + 'avatar_driver_upload', + array( + 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + 'avatar_remote_width' => 80, + 'avatar_remote_height' => 80, + ), + ), + array( + 'PROFILE_UPDATED', + 'avatar_driver_gravatar', + array( + 'avatar_delete' => array('tick', ''), + ), + ), + ); + } + + /** + * @dataProvider avatar_ucp_groups_data + */ + public function test_avatar_ucp_groups($expected, $avatar_type, $data) + { + $this->assert_avatar_submit($expected, $avatar_type, $data); + } + + public function test_display_upload_avatar() + { + $this->assert_avatar_submit('PROFILE_UPDATED', + 'avatar_driver_upload', + array( + 'avatar_upload_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg', + ) + ); + + $crawler = self::request('GET', $this->get_url() . '&sid=' . $this->sid); + $avatar_link = $crawler->filter('img')->attr('src'); + $crawler = self::request('GET', $avatar_link . '&sid=' . $this->sid, array(), false); + $content = self::$client->getResponse()->getContent(); + self::assertEquals(false, stripos(trim($content), 'debug'), 'Output contains debug message'); + } +} diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php index 18a2ad9464..c3be301762 100644 --- a/tests/functional/browse_test.php +++ b/tests/functional/browse_test.php @@ -29,4 +29,11 @@ class phpbb_functional_browse_test extends phpbb_functional_test_case $crawler = self::request('GET', 'viewtopic.php?t=1'); $this->assertGreaterThan(0, $crawler->filter('.postbody')->count()); } + + public function test_feed() + { + $crawler = self::request('GET', 'feed.php', array(), false); + self::assert_response_xml(); + $this->assertGreaterThan(0, $crawler->filter('entry')->count()); + } } diff --git a/tests/functional/common_avatar_test.php b/tests/functional/common_avatar_test.php new file mode 100644 index 0000000000..c0f21d07c2 --- /dev/null +++ b/tests/functional/common_avatar_test.php @@ -0,0 +1,80 @@ +<?php +/** + * + * @package testing + * @copyright (c) 2013 phpBB Group + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 + * + */ + +/** + * @group functional + */ +abstract class phpbb_functional_common_avatar_test extends phpbb_functional_test_case +{ + private $path; + private $form_content; + + abstract function get_url(); + + public function setUp() + { + parent::setUp(); + $this->path = __DIR__ . '/fixtures/files/'; + $this->login(); + $this->admin_login(); + $this->add_lang(array('acp/board', 'ucp', 'acp/users', 'acp/groups')); + $this->set_acp_settings(); + } + + private function set_acp_settings() + { + $crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); + // Check the default entries we should have + $this->assertContainsLang('ALLOW_GRAVATAR', $crawler->text()); + $this->assertContainsLang('ALLOW_REMOTE', $crawler->text()); + $this->assertContainsLang('ALLOW_AVATARS', $crawler->text()); + $this->assertContainsLang('ALLOW_LOCAL', $crawler->text()); + + // Now start setting the needed settings + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $form['config[allow_avatar_local]']->select(1); + $form['config[allow_avatar_gravatar]']->select(1); + $form['config[allow_avatar_remote]']->select(1); + $form['config[allow_avatar_remote_upload]']->select(1); + $crawler = self::submit($form); + $this->assertContainsLang('CONFIG_UPDATED', $crawler->text()); + } + + public function assert_avatar_submit($expected, $type, $data, $button_text = 'SUBMIT') + { + $crawler = self::request('GET', $this->get_url() . '&sid=' . $this->sid); + + // Test if setting a gravatar avatar properly works + $form = $crawler->selectButton($this->lang($button_text))->form(); + $form['avatar_driver']->select($type); + + foreach ($data as $key => $value) + { + if (is_array($value)) + { + $form[$key]->$value[0]($value[1]); + } + else + { + $form[$key]->setValue($value); + } + } + + $crawler = self::submit($form); + + try + { + $this->assertContainsLang($expected, $crawler->text()); + } + catch (Exception $e) + { + $this->assertContains($expected, $crawler->text()); + } + } +} diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 9ddf1e3e5c..7d29f0000c 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -6,7 +6,6 @@ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php'; /** * @group functional diff --git a/tests/functional/extension_global_lang_test.php b/tests/functional/extension_global_lang_test.php new file mode 100644 index 0000000000..fb8f87e6de --- /dev/null +++ b/tests/functional/extension_global_lang_test.php @@ -0,0 +1,63 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @group functional +*/ +class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_case +{ + protected $phpbb_extension_manager; + + static private $helper; + + static protected $fixtures = array( + 'foo/bar/language/en/', + 'foo/bar/event/', + ); + + static public function setUpBeforeClass() + { + parent::setUpBeforeClass(); + + self::$helper = new phpbb_test_case_helpers(self); + self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures); + } + + static public function tearDownAfterClass() + { + parent::tearDownAfterClass(); + + self::$helper->restore_original_ext_dir(); + } + + public function setUp() + { + parent::setUp(); + + $this->get_db(); + + $this->phpbb_extension_manager = $this->get_extension_manager(); + + $this->purge_cache(); + } + + public function test_load_extension_lang_globally() + { + $this->phpbb_extension_manager->enable('foo/bar'); + + // The board index, which should contain an overwritten translation + $crawler = self::request('GET', 'index.php'); + + // language from language/en/common.php + $this->assertNotContains('Skip to content', $crawler->filter('.skiplink')->text()); + + // language from ext/foo/bar/language/en/foo_global.php + $this->assertContains('Overwritten by foo', $crawler->filter('.skiplink')->text()); + } +} diff --git a/tests/functional/extension_module_test.php b/tests/functional/extension_module_test.php index c573ea5410..c31a892ce9 100644 --- a/tests/functional/extension_module_test.php +++ b/tests/functional/extension_module_test.php @@ -6,8 +6,6 @@ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ - -require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/acp/acp_modules.php'; /** diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index 6c1720735c..19adb89819 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -18,6 +18,7 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t static protected $fixtures = array( 'foo/bar/language/en/', + 'foo/bar/event/', ); static public function setUpBeforeClass() @@ -75,6 +76,6 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t $this->assertContains('Can attach files', $crawler->filter('body')->text()); // language from ext/foo/bar/language/en/permissions_foo.php - $this->assertContains('Can view foo', $crawler->filter('body')->text()); + $this->assertContains('Can view foobar', $crawler->filter('body')->text()); } } diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 8e361ab77b..65c4b6b7c4 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -44,14 +44,14 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case public function test_invalid_extension() { $upload = new fileupload('', array('jpg'), 100); - $file = $upload->remote_upload('http://example.com/image.gif'); + $file = $upload->remote_upload(self::$root_url . 'develop/blank.gif'); $this->assertEquals('URL_INVALID', $file->error[0]); } - public function test_non_existant() + public function test_empty_file() { $upload = new fileupload('', array('jpg'), 100); - $file = $upload->remote_upload('http://example.com/image.jpg'); + $file = $upload->remote_upload(self::$root_url . 'develop/blank.jpg'); $this->assertEquals('EMPTY_REMOTE_DATA', $file->error[0]); } diff --git a/tests/functional/fixtures/ext/foo/bar/event/permission.php b/tests/functional/fixtures/ext/foo/bar/event/permission.php new file mode 100644 index 0000000000..48688a586a --- /dev/null +++ b/tests/functional/fixtures/ext/foo/bar/event/permission.php @@ -0,0 +1,40 @@ +<?php + +/** +* +* @package testing +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @ignore +*/ + +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* Event listener +*/ +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +class phpbb_ext_foo_bar_event_permission implements EventSubscriberInterface +{ + static public function getSubscribedEvents() + { + return array( + 'core.permissions' => 'add_permissions', + ); + } + + public function add_permissions($event) + { + $permissions = $event['permissions']; + $permissions['u_foo'] = array('lang' => 'ACL_U_FOOBAR', 'cat' => 'post'); + $event['permissions'] = $permissions; + } +} diff --git a/tests/functional/fixtures/ext/foo/bar/event/user_setup.php b/tests/functional/fixtures/ext/foo/bar/event/user_setup.php new file mode 100644 index 0000000000..3d2d0c5325 --- /dev/null +++ b/tests/functional/fixtures/ext/foo/bar/event/user_setup.php @@ -0,0 +1,43 @@ +<?php + +/** +* +* @package testing +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @ignore +*/ + +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* Event listener +*/ +use Symfony\Component\EventDispatcher\EventSubscriberInterface; + +class phpbb_ext_foo_bar_event_user_setup implements EventSubscriberInterface +{ + static public function getSubscribedEvents() + { + return array( + 'core.user_setup' => 'add_global_translations', + ); + } + + public function add_global_translations($event) + { + $lang_set_ext = $event['lang_set_ext']; + $lang_set_ext[] = array( + 'ext_name' => 'foo/bar', + 'lang_set' => 'foo_global', + ); + $event['lang_set_ext'] = $lang_set_ext; + } +} diff --git a/tests/functional/fixtures/ext/foo/bar/language/en/foo_global.php b/tests/functional/fixtures/ext/foo/bar/language/en/foo_global.php new file mode 100644 index 0000000000..a6af8680d3 --- /dev/null +++ b/tests/functional/fixtures/ext/foo/bar/language/en/foo_global.php @@ -0,0 +1,5 @@ +<?php + +$lang = array_merge($lang, array( + 'SKIP' => 'Overwritten by foo', +)); diff --git a/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php b/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php index cd4b9a32d1..64b497c394 100644 --- a/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php +++ b/tests/functional/fixtures/ext/foo/bar/language/en/permissions_foo.php @@ -1,6 +1,5 @@ <?php -// Admin Permissions $lang = array_merge($lang, array( - 'acl_u_foo' => array('lang' => 'Can view foo', 'cat' => 'misc'), + 'ACL_U_FOOBAR' => 'Can view foobar with permission foo', )); diff --git a/tests/functional/mcp_test.php b/tests/functional/mcp_test.php new file mode 100644 index 0000000000..f65a7d0784 --- /dev/null +++ b/tests/functional/mcp_test.php @@ -0,0 +1,67 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @group functional +*/ +class phpbb_functional_mcp_test extends phpbb_functional_test_case +{ + public function test_post_new_topic() + { + $this->login(); + + // Test creating topic + $post = $this->create_topic(2, 'Test Topic 2', 'Testing move post with "Move posts" option from Quick-Moderator Tools.'); + + $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); + $this->assertContains('Testing move post with "Move posts" option from Quick-Moderator Tools.', $crawler->filter('html')->text()); + + return $crawler; + } + + /** + * @depends test_post_new_topic + */ + public function test_handle_quickmod($crawler) + { + // Test moving a post + $form = $crawler->selectButton('Go')->eq(1)->form(); + $form['action']->select('merge'); + $crawler = self::submit($form); + + return $crawler; + } + + /** + * @depends test_handle_quickmod + */ + public function test_move_post_to_topic($crawler) + { + // Select the post in MCP + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(array( + 'to_topic_id' => 1, + )); + $form['post_id_list'][0]->tick(); + $crawler = self::submit($form); + $this->assertContains($this->lang('MERGE_POSTS'), $crawler->filter('html')->text()); + + return $crawler; + } + + /** + * @depends test_move_post_to_topic + */ + public function test_confirm_result($crawler) + { + $this->add_lang('mcp'); + $form = $crawler->selectButton('Yes')->form(); + $crawler = self::submit($form); + $this->assertContains($this->lang('POSTS_MERGED_SUCCESS'), $crawler->text()); + } +} diff --git a/tests/functional/metadata_manager_test.php b/tests/functional/metadata_manager_test.php index c55e7373ea..651c99a99d 100644 --- a/tests/functional/metadata_manager_test.php +++ b/tests/functional/metadata_manager_test.php @@ -7,8 +7,6 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/db/db_tools.php'; - /** * @group functional */ diff --git a/tests/functional/report_post_captcha.php b/tests/functional/report_post_captcha_test.php index af713775c5..8283465041 100644 --- a/tests/functional/report_post_captcha.php +++ b/tests/functional/report_post_captcha_test.php @@ -12,13 +12,6 @@ */ class phpbb_functional_report_post_captcha_test extends phpbb_functional_test_case { - public function test_user_report_post() - { - $this->login(); - $crawler = self::request('GET', 'report.php?f=2&p=1'); - $this->assertNotContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text()); - } - public function test_guest_report_post() { $crawler = self::request('GET', 'report.php?f=2&p=1'); @@ -31,6 +24,18 @@ class phpbb_functional_report_post_captcha_test extends phpbb_functional_test_ca $this->set_reporting_guest(-1); } + public function test_user_report_post() + { + $this->login(); + $crawler = self::request('GET', 'report.php?f=2&p=1'); + $this->assertNotContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text()); + + $this->add_lang('mcp'); + $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); + $crawler = self::submit($form); + $this->assertContains($this->lang('POST_REPORTED_SUCCESS'), $crawler->text()); + } + protected function set_reporting_guest($report_post_allowed) { $this->login(); |