diff options
Diffstat (limited to 'tests')
30 files changed, 687 insertions, 52 deletions
diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index aba7a3560b..1fd2cbd7ee 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -46,6 +46,7 @@ namespace { $container = $this->builder->get_container(); $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); + $this->assertFalse($container->hasParameter('container_exception')); // Checks the core services $this->assertTrue($container->hasParameter('core')); @@ -54,7 +55,7 @@ namespace $this->assertTrue($container->isFrozen()); // Checks inject_config - $this->assertTrue($container->hasParameter('dbal.dbhost')); + $this->assertTrue($container->hasParameter('core.table_prefix')); // Checks use_extensions $this->assertTrue($container->hasParameter('enabled')); diff --git a/tests/di/fixtures/config/production/container/environment.yml b/tests/di/fixtures/config/production/container/environment.yml index 4216b187cc..8281d9e941 100644 --- a/tests/di/fixtures/config/production/container/environment.yml +++ b/tests/di/fixtures/config/production/container/environment.yml @@ -10,6 +10,9 @@ services: arguments: - '@service_container' + dbal.conn.driver: + synthetic: true + dispatcher: class: phpbb\db\driver\container_mock diff --git a/tests/di/fixtures/config/test/container/environment.yml b/tests/di/fixtures/config/test/container/environment.yml index 7d528fed19..252117dd32 100644 --- a/tests/di/fixtures/config/test/container/environment.yml +++ b/tests/di/fixtures/config/test/container/environment.yml @@ -10,6 +10,9 @@ services: arguments: - '@service_container' + dbal.conn.driver: + synthetic: true + dispatcher: class: phpbb\db\driver\container_mock diff --git a/tests/di/fixtures/other_config/production/container/environment.yml b/tests/di/fixtures/other_config/production/container/environment.yml index 1170145b66..c0d2f87bab 100644 --- a/tests/di/fixtures/other_config/production/container/environment.yml +++ b/tests/di/fixtures/other_config/production/container/environment.yml @@ -10,6 +10,9 @@ services: arguments: - '@service_container' + dbal.conn.driver: + synthetic: true + dispatcher: class: phpbb\db\driver\container_mock diff --git a/tests/di/fixtures/other_config/test/container/environment.yml b/tests/di/fixtures/other_config/test/container/environment.yml index 6c36977d4d..b9f6d05018 100644 --- a/tests/di/fixtures/other_config/test/container/environment.yml +++ b/tests/di/fixtures/other_config/test/container/environment.yml @@ -10,6 +10,9 @@ services: arguments: - '@service_container' + dbal.conn.driver: + synthetic: true + dispatcher: class: phpbb\db\driver\container_mock diff --git a/tests/event/fixtures/trigger_many_vars.test b/tests/event/fixtures/trigger_many_vars.test index a624138588..5e0720d13b 100644 --- a/tests/event/fixtures/trigger_many_vars.test +++ b/tests/event/fixtures/trigger_many_vars.test @@ -34,7 +34,7 @@ * posting page via $template->assign_vars() * @var object message_parser The message parser object * @since 3.1.0-a1 - * @change 3.1.0-b3 Added vars post_data, moderators, mode, page_title, + * @changed 3.1.0-b3 Added vars post_data, moderators, mode, page_title, * s_topic_icons, form_enctype, s_action, s_hidden_fields, * post_id, topic_id, forum_id, submit, preview, save, load, * delete, cancel, refresh, error, page_data, message_parser diff --git a/tests/feed/attachments_base_test.php b/tests/feed/attachments_base_test.php new file mode 100644 index 0000000000..dd432d13f5 --- /dev/null +++ b/tests/feed/attachments_base_test.php @@ -0,0 +1,99 @@ +<?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__) . '/attachments_mock_feed.php'); + +class phpbb_feed_attachments_base_test extends phpbb_database_test_case +{ + protected $filesystem; + + /** @var \phpbb_feed_attachments_mock_feed */ + protected $attachments_mocks_feed; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/../extension/fixtures/extensions.xml'); + } + + public function setUp() + { + global $phpbb_root_path, $phpEx; + + $this->filesystem = new \phpbb\filesystem(); + $config = new \phpbb\config\config(array()); + $user = new \phpbb\user( + new \phpbb\language\language( + new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx) + ), + '\phpbb\datetime' + ); + $feed_helper = new \phpbb\feed\helper($config, $user, $phpbb_root_path, $phpEx); + $db = $this->new_dbal(); + $cache = new \phpbb_mock_cache(); + $auth = new \phpbb\auth\auth(); + $content_visibility = new \phpbb\content_visibility( + $auth, + $config, + new \phpbb_mock_event_dispatcher(), + $db, + $user, + $phpbb_root_path, + $phpEx, + FORUMS_TABLE, + POSTS_TABLE, + TOPICS_TABLE, + USERS_TABLE + ); + + $this->attachments_mocks_feed = new \phpbb_feed_attachments_mock_feed( + $feed_helper, + $config, + $db, + $cache, + $user, + $auth, + $content_visibility, + new \phpbb_mock_event_dispatcher(), + $phpEx + ); + } + + public function data_fetch_attachments() + { + return array( + array(array(0), array(0)), + array(array(), array(1)), + array(array(), array(), 'RuntimeException') + ); + } + + /** + * @dataProvider data_fetch_attachments + */ + public function test_fetch_attachments($post_ids, $topic_ids, $expected_exception = false) + { + $this->attachments_mocks_feed->post_ids = $post_ids; + $this->attachments_mocks_feed->topic_ids = $topic_ids; + + if ($expected_exception !== false) + { + $this->setExpectedException($expected_exception); + + $this->attachments_mocks_feed->get_sql(); + } + else + { + $this->assertTrue($this->attachments_mocks_feed->get_sql()); + } + } +} diff --git a/tests/feed/attachments_mock_feed.php b/tests/feed/attachments_mock_feed.php new file mode 100644 index 0000000000..fb67a48f7c --- /dev/null +++ b/tests/feed/attachments_mock_feed.php @@ -0,0 +1,36 @@ +<?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. + * + */ + +/** + * Board wide feed (aka overall feed) + * + * This will give you the newest {$this->num_items} posts + * from the whole board. + */ +class phpbb_feed_attachments_mock_feed extends \phpbb\feed\attachments_base +{ + public $topic_ids = array(); + public $post_ids = array(); + + function get_sql() + { + parent::fetch_attachments($this->post_ids, $this->topic_ids); + + return true; + } + + public function adjust_item(&$item_row, &$row) + { + return array(); + } +} diff --git a/tests/functional/acp_bbcodes_test.php b/tests/functional/acp_bbcodes_test.php new file mode 100644 index 0000000000..58681dfa07 --- /dev/null +++ b/tests/functional/acp_bbcodes_test.php @@ -0,0 +1,46 @@ +<?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_bbcodes_test extends phpbb_functional_test_case +{ + public function test_htmlspecialchars() + { + $this->login(); + $this->admin_login(); + + // Create the BBCode + $crawler = self::request('GET', 'adm/index.php?i=acp_bbcodes&sid=' . $this->sid . '&mode=bbcodes&action=add'); + $form = $crawler->selectButton('Submit')->form(array( + 'bbcode_match' => '[mod="{TEXT1}"]{TEXT2}[/mod]', + 'bbcode_tpl' => '<div>{TEXT1}</div><div>{TEXT2}</div>' + )); + self::submit($form); + + // Test it in the "new topic" preview + $crawler = self::request('GET', 'posting.php?mode=post&f=2&sid=' . $this->sid); + $form = $crawler->selectButton('Preview')->form(array( + 'subject' => 'subject', + 'message' => '[mod=a]b[/mod][mod="c"]d[/mod]' + )); + $crawler = self::submit($form); + + $html = $crawler->filter('#preview')->html(); + $this->assertContains('<div>a</div>', $html); + $this->assertContains('<div>b</div>', $html); + $this->assertContains('<div>c</div>', $html); + $this->assertContains('<div>d</div>', $html); + } +} diff --git a/tests/functional/acp_smilies_test.php b/tests/functional/acp_smilies_test.php new file mode 100644 index 0000000000..ebe8717fa7 --- /dev/null +++ b/tests/functional/acp_smilies_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. + * + */ + +/** + * @group functional + */ +class phpbb_functional_acp_smilies_test extends phpbb_functional_test_case +{ + public function test_htmlspecialchars() + { + $this->login(); + $this->admin_login(); + + // Create the BBCode + $crawler = self::request('GET', 'adm/index.php?i=acp_icons&sid=' . $this->sid . '&mode=smilies&action=edit&id=1'); + $form = $crawler->selectButton('Submit')->form(array( + 'code[icon_e_biggrin.gif]' => '>:D', + 'emotion[icon_e_biggrin.gif]' => '>:D' + )); + self::submit($form); + + // Test it in the "new topic" preview + $crawler = self::request('GET', 'posting.php?mode=post&f=2&sid=' . $this->sid); + $form = $crawler->selectButton('Preview')->form(array( + 'subject' => 'subject', + 'message' => '>:D' + )); + $crawler = self::submit($form); + + $html = $crawler->filter('#preview')->html(); + $this->assertRegexp('(<img [^>]+ alt=">:D" title=">:D"[^>]*>)', $html); + } +} diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index b70d49cddd..88f8999005 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -100,8 +100,8 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) - ->set_max_filesize(1000); - $file = $upload->handle_upload('files.types.remote', self::$root_url . 'styles/prosilver/theme/images/forum_read.gif'); + ->set_max_filesize(2000); + $file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/test.gif'); $this->assertEquals(0, sizeof($file->error)); $this->assertTrue(file_exists($file->get('filename'))); $this->assertTrue($file->is_uploaded()); @@ -114,7 +114,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $upload->set_error_prefix('') ->set_allowed_extensions(array('gif')) ->set_max_filesize(100); - $file = $upload->handle_upload('files.types.remote', self::$root_url . 'styles/prosilver/theme/images/forum_read.gif'); + $file = $upload->handle_upload('files.types.remote', self::$root_url . 'develop/test.gif'); $this->assertEquals(1, sizeof($file->error)); $this->assertEquals('WRONG_FILESIZE', $file->error[0]); } diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 9dd8a1dc91..8e6328d1d3 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -87,6 +87,24 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case } /** + * @see https://tracker.phpbb.com/browse/PHPBB3-14962 + */ + public function test_edit() + { + $this->login(); + $this->create_topic(2, 'Test Topic post', 'Test topic post'); + + $url = self::$client->getCrawler()->selectLink('Edit')->link()->getUri(); + $post_id = $this->get_parameter_from_link($url, 'p'); + $crawler = self::request('GET', "posting.php?mode=edit&f=2&p={$post_id}&sid={$this->sid}"); + $form = $crawler->selectButton('Submit')->form(); + $form->setValues(array('message' => 'Edited post')); + $crawler = self::submit($form); + + $this->assertContains('Edited post', $crawler->filter("#post_content{$post_id} .content")->text()); + } + + /** * @testdox max_quote_depth is applied to the text populating the posting form */ public function test_quote_depth_form() @@ -246,4 +264,45 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case // Test that the preview contains the correct link $this->assertEquals($url, $crawler->filter('#preview a')->attr('href')); } + + public function test_allowed_schemes_links() + { + $text = 'http://example.org/ tcp://localhost:22/ServiceName'; + + $this->login(); + $this->admin_login(); + + // Post with default settings + $crawler = self::request('GET', 'posting.php?mode=post&f=2'); + $form = $crawler->selectButton('Preview')->form(array( + 'subject' => 'Test subject', + 'message' => $text, + )); + $crawler = self::submit($form); + $this->assertContains( + '<a href="http://example.org/" class="postlink">http://example.org/</a> tcp://localhost:22/ServiceName', + $crawler->filter('#preview .content')->html() + ); + + // Update allowed schemes + $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[allowed_schemes_links]'] = 'https,tcp'; + $form->setValues($values); + $crawler = self::submit($form); + $this->assertEquals(1, $crawler->filter('.successbox')->count()); + + // Post with new settings + $crawler = self::request('GET', 'posting.php?mode=post&f=2'); + $form = $crawler->selectButton('Preview')->form(array( + 'subject' => 'Test subject', + 'message' => $text, + )); + $crawler = self::submit($form); + $this->assertContains( + 'http://example.org/ <a href="tcp://localhost:22/ServiceName" class="postlink">tcp://localhost:22/ServiceName</a>', + $crawler->filter('#preview .content')->html() + ); + } } diff --git a/tests/functions_privmsgs/get_max_setting_from_group_test.php b/tests/functions_privmsgs/get_max_setting_from_group_test.php index 3eb7866802..fbabf1222a 100644 --- a/tests/functions_privmsgs/get_max_setting_from_group_test.php +++ b/tests/functions_privmsgs/get_max_setting_from_group_test.php @@ -33,12 +33,12 @@ class phpbb_functions_privmsgs_get_max_setting_from_group_test extends phpbb_dat static public function get_max_setting_from_group_data() { return array( - array(1, 0, 'message_limit'), + array(1, 2, 'message_limit'), array(2, 2, 'message_limit'), array(3, 0, 'message_limit'), array(4, 0, 'message_limit'), array(5, 2, 'message_limit'), - array(1, 0, 'max_recipients'), + array(1, 4, 'max_recipients'), array(2, 4, 'max_recipients'), array(3, 0, 'max_recipients'), array(4, 5, 'max_recipients'), diff --git a/tests/mock/phpbb_di_container_builder.php b/tests/mock/phpbb_di_container_builder.php index 23dc3d1e8b..c78b41d8ec 100644 --- a/tests/mock/phpbb_di_container_builder.php +++ b/tests/mock/phpbb_di_container_builder.php @@ -27,4 +27,12 @@ class phpbb_mock_phpbb_di_container_builder extends \phpbb\di\container_builder { return $this->phpbb_root_path . '../../tmp/autoload.' . $this->php_ext; } + + /** + * {@inheritdoc} + */ + protected function inject_dbal_driver() + { + return; + } } diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index 30b25913f7..2d7d1671a8 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -219,6 +219,12 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case 0, 'PAGE_OF-1-1', ), + array( + '10', + '10', + '0', + 'PAGE_OF-1-1', + ), ); } diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 63e7cb869a..79c0ac8038 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -755,6 +755,43 @@ EOT $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after modification'); } + public function test_find_key_index() + { + $this->template->set_filenames(array('test' => 'loop_nested.html')); + + $this->template->assign_var('TEST_MORE', true); + + // @todo Change this + $this->template->assign_block_vars('outer', array('VARIABLE' => 'zero')); + $this->template->assign_block_vars('outer', array('VARIABLE' => 'one')); + $this->template->assign_block_vars('outer.middle', array('VARIABLE' => '1A')); + $this->template->assign_block_vars('outer', array('VARIABLE' => 'two')); + $this->template->assign_block_vars('outer.middle', array('VARIABLE' => '2A')); + $this->template->assign_block_vars('outer.middle', array('VARIABLE' => '2B')); + $this->template->assign_block_vars('outer', array('VARIABLE' => 'three')); + $this->template->assign_block_vars('outer.middle', array('VARIABLE' => '3A')); + $this->template->assign_block_vars('outer.middle', array('VARIABLE' => '3B')); + $this->template->assign_block_vars('outer.middle', array('VARIABLE' => '3C')); + + $expect = 'outer - 0 - zero[outer|4]outer - 1 - one[outer|4]middle - 0 - 1A[middle|1]outer - 2 - two[outer|4]middle - 0 - 2A[middle|2]middle - 1 - 2B[middle|2]outer - 3 - three[outer|4]middle - 0 - 3A[middle|3]middle - 1 - 3B[middle|3]middle - 2 - 3C[middle|3]'; + $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring template is built correctly before modification'); + + $this->template->find_key_index('outer', false); + + $this->assertEquals(0, $this->template->find_key_index('outer', false), 'Find index at the beginning of outer loop'); + $this->assertEquals(1, $this->template->find_key_index('outer', 1), 'Find index by index in outer loop'); + $this->assertEquals(2, $this->template->find_key_index('outer', array('VARIABLE' => 'two')), 'Find index by key in outer loop'); + $this->assertEquals(3, $this->template->find_key_index('outer', true), 'Find index at the end of outer loop'); + $this->assertEquals(false, $this->template->find_key_index('outer', 7), 'Find index out of bounds of outer loop'); + + $this->assertEquals(false, $this->template->find_key_index('outer[0].middle', false), 'Find index at the beginning of middle loop, no middle block'); + $this->assertEquals(false, $this->template->find_key_index('outer[1].middle', 1), 'Find index by index in inner loop, out of bounds'); + $this->assertEquals(1, $this->template->find_key_index('outer[2].middle', array('VARIABLE' => '2B')), 'Find index by key in middle loop'); + $this->assertEquals(2, $this->template->find_key_index('outer.middle', true), 'Find index at the end of middle loop'); + + $this->assertEquals(false, $this->template->find_key_index('outer.wrong', true), 'Wrong middle block name'); + $this->assertEquals(false, $this->template->find_key_index('wrong.middle', false), 'Wrong outer block name'); + } public function assign_block_vars_array_data() { return array( diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index d5e78d1d60..eb56049515 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -291,6 +291,13 @@ class phpbb_functional_test_case extends phpbb_test_case } } + $install_config_file = $phpbb_root_path . 'store/install_config.php'; + + if (file_exists($install_config_file)) + { + unlink($install_config_file); + } + $container_builder = new \phpbb\di\container_builder($phpbb_root_path, $phpEx); $container = $container_builder ->with_environment('installer') @@ -304,6 +311,7 @@ class phpbb_functional_test_case extends phpbb_test_case ], 'cache.driver.class' => 'phpbb\cache\driver\file' ]) + ->with_config(new \phpbb\config_php_file($phpbb_root_path, $phpEx)) ->without_compiled_container() ->get_container(); diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index e3f636679c..b875d3212b 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -78,14 +78,11 @@ class phpbb_ui_test_case extends phpbb_test_case self::markTestSkipped('phpbb_functional_url was not set in test_config and wasn\'t set as PHPBB_FUNCTIONAL_URL environment variable either.'); } - if (!self::$webDriver) - { - try { - $capabilities = DesiredCapabilities::firefox(); - self::$webDriver = RemoteWebDriver::create(self::$host . ':' . self::$port, $capabilities); - } catch (WebDriverCurlException $e) { - self::markTestSkipped('PhantomJS webserver is not running.'); - } + try { + $capabilities = DesiredCapabilities::firefox(); + self::$webDriver = RemoteWebDriver::create(self::$host . ':' . self::$port, $capabilities); + } catch (WebDriverCurlException $e) { + self::markTestSkipped('PhantomJS webserver is not running.'); } if (!self::$already_installed) @@ -146,9 +143,14 @@ class phpbb_ui_test_case extends phpbb_test_case } } - static public function visit($path) + public function getDriver() + { + return self::$webDriver; + } + + public function visit($path) { - self::$webDriver->get(self::$root_url . $path); + $this->getDriver()->get(self::$root_url . $path); } static protected function recreate_database($config) @@ -157,14 +159,14 @@ class phpbb_ui_test_case extends phpbb_test_case $db_conn_mgr->recreate_db(); } - static public function find_element($type, $value) + public function find_element($type, $value) { - return self::$webDriver->findElement(WebDriverBy::$type($value)); + return $this->getDriver()->findElement(WebDriverBy::$type($value)); } - static public function submit($type = 'id', $value = 'submit') + public function submit($type = 'id', $value = 'submit') { - $element = self::find_element($type, $value); + $element = $this->find_element($type, $value); $element->click(); } @@ -305,21 +307,21 @@ class phpbb_ui_test_case extends phpbb_test_case $ext_path = str_replace('/', '%2F', $extension); $this->visit('adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=' . $ext_path . '&sid=' . $this->sid); - $this->assertNotEmpty(count(self::find_element('cssSelector', '.submit-buttons'))); + $this->assertNotEmpty(count($this->find_element('cssSelector', '.submit-buttons'))); - self::find_element('cssSelector', "input[value='Enable']")->submit(); + $this->find_element('cssSelector', "input[value='Enable']")->submit(); $this->add_lang('acp/extensions'); try { - $meta_refresh = self::find_element('cssSelector', 'meta[http-equiv="refresh"]'); + $meta_refresh = $this->find_element('cssSelector', 'meta[http-equiv="refresh"]'); // Wait for extension to be fully enabled while (sizeof($meta_refresh)) { preg_match('#url=.+/(adm+.+)#', $meta_refresh->getAttribute('content'), $match); - self::$webDriver->execute(array('method' => 'post', 'url' => $match[1])); - $meta_refresh = self::find_element('cssSelector', 'meta[http-equiv="refresh"]'); + $this->getDriver()->execute(array('method' => 'post', 'url' => $match[1])); + $meta_refresh = $this->find_element('cssSelector', 'meta[http-equiv="refresh"]'); } } catch (\Facebook\WebDriver\Exception\NoSuchElementException $e) @@ -327,7 +329,7 @@ class phpbb_ui_test_case extends phpbb_test_case // Probably no refresh triggered } - $this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', self::find_element('cssSelector', 'div.successbox')->getText()); + $this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', $this->find_element('cssSelector', 'div.successbox')->getText()); $this->logout(); } @@ -415,7 +417,7 @@ class phpbb_ui_test_case extends phpbb_test_case } $this->visit('ucp.php?sid=' . $this->sid . '&mode=logout'); - $this->assertContains($this->lang('REGISTER'), self::$webDriver->getPageSource()); + $this->assertContains($this->lang('REGISTER'), $this->getDriver()->getPageSource()); unset($this->sid); } @@ -435,17 +437,17 @@ class phpbb_ui_test_case extends phpbb_test_case return; } - self::$webDriver->manage()->deleteAllCookies(); + $this->getDriver()->manage()->deleteAllCookies(); $this->visit('adm/index.php?sid=' . $this->sid); - $this->assertContains($this->lang('LOGIN_ADMIN_CONFIRM'), self::$webDriver->getPageSource()); + $this->assertContains($this->lang('LOGIN_ADMIN_CONFIRM'), $this->getDriver()->getPageSource()); - self::find_element('cssSelector', 'input[name=username]')->clear()->sendKeys($username); - self::find_element('cssSelector', 'input[type=password]')->sendKeys($username . $username); - self::find_element('cssSelector', 'input[name=login]')->click(); + $this->find_element('cssSelector', 'input[name=username]')->clear()->sendKeys($username); + $this->find_element('cssSelector', 'input[type=password]')->sendKeys($username . $username); + $this->find_element('cssSelector', 'input[name=login]')->click(); $this->assertContains($this->lang('ADMIN_PANEL'), $this->find_element('cssSelector', 'h1')->getText()); - $cookies = self::$webDriver->manage()->getCookies(); + $cookies = $this->getDriver()->manage()->getCookies(); // The session id is stored in a cookie that ends with _sid - we assume there is only one such cookie foreach ($cookies as $cookie) @@ -550,19 +552,19 @@ class phpbb_ui_test_case extends phpbb_test_case { $this->add_lang('ucp'); - self::$webDriver->manage()->deleteAllCookies(); + $this->getDriver()->manage()->deleteAllCookies(); $this->visit('ucp.php'); - $this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), self::$webDriver->getPageSource()); + $this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), $this->getDriver()->getPageSource()); - self::$webDriver->manage()->deleteAllCookies(); + $this->getDriver()->manage()->deleteAllCookies(); - self::find_element('cssSelector', 'input[name=username]')->sendKeys($username); - self::find_element('cssSelector', 'input[name=password]')->sendKeys($username . $username); - self::find_element('cssSelector', 'input[name=login]')->click(); + $this->find_element('cssSelector', 'input[name=username]')->sendKeys($username); + $this->find_element('cssSelector', 'input[name=password]')->sendKeys($username . $username); + $this->find_element('cssSelector', 'input[name=login]')->click(); $this->assertNotContains($this->lang('LOGIN'), $this->find_element('className', 'navbar')->getText()); - $cookies = self::$webDriver->manage()->getCookies(); + $cookies = $this->getDriver()->manage()->getCookies(); // The session id is stored in a cookie that ends with _sid - we assume there is only one such cookie foreach ($cookies as $cookie) @@ -586,6 +588,6 @@ class phpbb_ui_test_case extends phpbb_test_case // Change the Path to your own settings $screenshot = time() . ".png"; - self::$webDriver->takeScreenshot($screenshot); + $this->getDriver()->takeScreenshot($screenshot); } } diff --git a/tests/text_formatter/s9e/default_formatting_test.php b/tests/text_formatter/s9e/default_formatting_test.php index e25c3246b5..a0c57214e4 100644 --- a/tests/text_formatter/s9e/default_formatting_test.php +++ b/tests/text_formatter/s9e/default_formatting_test.php @@ -298,7 +298,7 @@ class phpbb_textformatter_s9e_default_formatting_test extends phpbb_test_case ), array( "Emoji: \xF0\x9F\x98\x80", - 'Emoji: <img alt="' . "\xF0\x9F\x98\x80" . '" class="smilies" draggable="false" width="18" height="18" src="//cdn.jsdelivr.net/emojione/assets/svg/1f600.svg">' + 'Emoji: <img alt="' . "\xF0\x9F\x98\x80" . '" class="emoji smilies" draggable="false" src="//cdn.jsdelivr.net/emojione/assets/svg/1f600.svg">' ), array( "Emoji: \xF0\x9F\x98\x80", diff --git a/tests/text_processing/tickets_data/PHPBB3-14790.html b/tests/text_processing/tickets_data/PHPBB3-14790.html new file mode 100644 index 0000000000..7624b2d36c --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-14790.html @@ -0,0 +1,4 @@ +<span style="color: #0000FF"></span><ul><li><span style="color: #0000FF">text</span></li> +<li><span style="color: #0000FF">text</span></li> +<li><span style="color: #0000FF">text</span></li> +<li><span style="color: #0000FF">text</span></li></ul>
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-14790.txt b/tests/text_processing/tickets_data/PHPBB3-14790.txt new file mode 100644 index 0000000000..1cd83d97d8 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-14790.txt @@ -0,0 +1,4 @@ +[color=#0000FF][list][*]text +[*]text +[*]text +[*]text[/list][/color]
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15008.before.php b/tests/text_processing/tickets_data/PHPBB3-15008.before.php new file mode 100644 index 0000000000..a3243e74cd --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15008.before.php @@ -0,0 +1,18 @@ +<?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. +* +*/ + +function before_assert_phpbb3_15008($vars) +{ + extract($vars); + $parser->disable_smilies(); +} diff --git a/tests/text_processing/tickets_data/PHPBB3-15008.html b/tests/text_processing/tickets_data/PHPBB3-15008.html new file mode 100644 index 0000000000..7642eb63ee --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15008.html @@ -0,0 +1 @@ +No smilies :) or shortnames :strawberry:
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15008.txt b/tests/text_processing/tickets_data/PHPBB3-15008.txt new file mode 100644 index 0000000000..7642eb63ee --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15008.txt @@ -0,0 +1 @@ +No smilies :) or shortnames :strawberry:
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15016.html b/tests/text_processing/tickets_data/PHPBB3-15016.html new file mode 100644 index 0000000000..47b66ad771 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15016.html @@ -0,0 +1 @@ +<img class="smilies" src="phpBB/images/smilies/icon_lol.gif" width="15" height="17" alt=")--(" title=")--("> <img class="smilies" src="phpBB/images/smilies/icon_lol.gif" width="15" height="17" alt=")-(" title=")-("> <img class="smilies" src="phpBB/images/smilies/icon_lol.gif" width="15" height="17" alt=")--" title=")--">
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15016.txt b/tests/text_processing/tickets_data/PHPBB3-15016.txt new file mode 100644 index 0000000000..081d9e3dc9 --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15016.txt @@ -0,0 +1 @@ +)--( )-( )--
\ No newline at end of file diff --git a/tests/text_processing/tickets_data/PHPBB3-15016.xml b/tests/text_processing/tickets_data/PHPBB3-15016.xml new file mode 100644 index 0000000000..644481861e --- /dev/null +++ b/tests/text_processing/tickets_data/PHPBB3-15016.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> + <table name="phpbb_smilies"> + <column>smiley_id</column> + <column>code</column> + <column>emotion</column> + <column>smiley_url</column> + <column>smiley_width</column> + <column>smiley_height</column> + <column>smiley_order</column> + <column>display_on_posting</column> + <row> + <value>1</value> + <value>)--(</value> + <value>)--(</value> + <value>icon_lol.gif</value> + <value>15</value> + <value>17</value> + <value>22</value> + <value>1</value> + </row> + <row> + <value>2</value> + <value>)--</value> + <value>)--</value> + <value>icon_lol.gif</value> + <value>15</value> + <value>17</value> + <value>22</value> + <value>1</value> + </row> + <row> + <value>3</value> + <value>)-(</value> + <value>)-(</value> + <value>icon_lol.gif</value> + <value>15</value> + <value>17</value> + <value>22</value> + <value>1</value> + </row> + </table> +</dataset> diff --git a/tests/ui/permission_roles_test.php b/tests/ui/permission_roles_test.php index 3501124fc1..de54cc788d 100644 --- a/tests/ui/permission_roles_test.php +++ b/tests/ui/permission_roles_test.php @@ -25,19 +25,19 @@ class ui_permission_roles_test extends phpbb_ui_test_case $this->visit('adm/index.php?i=acp_permissions&mode=setting_forum_local&sid=' . $this->sid); // Select forums - $elements = self::find_element('cssSelector', 'select#forum') + $elements = $this->find_element('cssSelector', 'select#forum') ->findElements(\Facebook\WebDriver\WebDriverBy::tagName('option')); foreach ($elements as $element) { $element->click(); } - self::find_element('cssSelector', 'form#select_victim') + $this->find_element('cssSelector', 'form#select_victim') ->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[type=submit]')) ->click(); // Select administrators and guests - $groups_form = self::find_element('cssSelector', 'form#groups'); + $groups_form = $this->find_element('cssSelector', 'form#groups'); $elements = $groups_form ->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('select')) ->findElements(\Facebook\WebDriver\WebDriverBy::tagName('option')); @@ -51,7 +51,7 @@ class ui_permission_roles_test extends phpbb_ui_test_case } $groups_form->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[name=submit_edit_options]'))->click(); - $first_fieldset = self::find_element('cssSelector', '#perm11'); + $first_fieldset = $this->find_element('cssSelector', '#perm11'); $this->assertEquals('none', $first_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('div.dropdown'))->getCSSValue('display')); $first_fieldset ->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('span.dropdown-toggle')) @@ -74,14 +74,14 @@ class ui_permission_roles_test extends phpbb_ui_test_case $this->assertEquals($this->lang('ROLE_FORUM_LIMITED'), $first_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('span.dropdown-toggle'))->getText()); // Check that admin settings didn't get changed - $second_fieldset = self::find_element('cssSelector', '#perm10'); + $second_fieldset = $this->find_element('cssSelector', '#perm10'); $this->assertEquals('none', $second_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('div.dropdown'))->getCSSValue('display')); // Full access = 14 $this->assertEquals(14, $second_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[type=hidden]'))->getAttribute('value')); $this->assertEquals($this->lang('ROLE_FORUM_FULL'), $second_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('span.dropdown-toggle'))->getText()); // Check that category settings were not modified - $category_fieldset = self::find_element('cssSelector', '#perm00'); + $category_fieldset = $this->find_element('cssSelector', '#perm00'); $this->assertEquals('none', $category_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('div.dropdown'))->getCSSValue('display')); // No settings $this->assertEquals('', $category_fieldset->findElement(\Facebook\WebDriver\WebDriverBy::cssSelector('input[type=hidden]'))->getAttribute('value')); diff --git a/tests/ui/quick_links_test.php b/tests/ui/quick_links_test.php index 582aeafcae..171ef3ca53 100644 --- a/tests/ui/quick_links_test.php +++ b/tests/ui/quick_links_test.php @@ -19,8 +19,8 @@ class quick_links_test extends phpbb_ui_test_case public function test_quick_links() { $this->visit('index.php'); - $this->assertEmpty(self::find_element('className', 'dropdown')->getText()); - self::find_element('className', 'dropdown-toggle')->click(); - $this->assertNotNull(self::find_element('className', 'dropdown')->getText()); + $this->assertEmpty($this->find_element('className', 'dropdown')->getText()); + $this->find_element('className', 'dropdown-toggle')->click(); + $this->assertNotNull($this->find_element('className', 'dropdown')->getText()); } } diff --git a/tests/version/version_test.php b/tests/version/version_test.php index 93d47a40a6..abe51ef539 100644 --- a/tests/version/version_test.php +++ b/tests/version/version_test.php @@ -341,4 +341,209 @@ class phpbb_version_helper_test extends phpbb_test_case $this->assertSame($expected, $version_helper->get_latest_on_current_branch()); } + + public function get_update_on_branch_data() + { + return array( + array( + '1.0.0', + array( + '1.0' => array( + 'current' => '1.0.1', + ), + '1.1' => array( + 'current' => '1.1.1', + ), + ), + array( + 'current' => '1.0.1', + ), + ), + array( + '1.0.1', + array( + '1.0' => array( + 'current' => '1.0.1', + ), + '1.1' => array( + 'current' => '1.1.1', + ), + ), + array(), + ), + array( + '1.0.1-a1', + array( + '1.0' => array( + 'current' => '1.0.1-a2', + ), + '1.1' => array( + 'current' => '1.1.0', + ), + ), + array( + 'current' => '1.0.1-a2', + ), + ), + array( + '1.1.0', + array( + '1.0' => array( + 'current' => '1.0.1', + ), + '1.1' => array( + 'current' => '1.1.1', + ), + ), + array( + 'current' => '1.1.1', + ), + ), + array( + '1.1.1', + array( + '1.0' => array( + 'current' => '1.0.1', + ), + '1.1' => array( + 'current' => '1.1.1', + ), + ), + array(), + ), + array( + '1.1.0-a1', + array( + '1.0' => array( + 'current' => '1.0.1', + ), + '1.1' => array( + 'current' => '1.1.0-a2', + ), + ), + array( + 'current' => '1.1.0-a2', + ), + ), + array( + '1.1.0', + array(), + array(), + ), + // Latest safe release is 1.0.1 + array( + '1.0.0', + array( + '1.0' => array( + 'current' => '1.0.1', + 'security' => '1.0.1', + ), + '1.1' => array( + 'current' => '1.1.1', + ), + ), + array( + 'current' => '1.0.1', + 'security' => '1.0.1', + ), + ), + // Latest safe release is 1.0.0 + array( + '1.0.0', + array( + '1.0' => array( + 'current' => '1.0.1', + 'security' => '1.0.0', + ), + '1.1' => array( + 'current' => '1.1.1', + ), + ), + array( + 'current' => '1.0.1', + 'security' => '1.0.0', + ), + ), + // Latest safe release is 1.1.0 + array( + '1.0.0', + array( + '1.0' => array( + 'current' => '1.0.1', + 'security' => '1.1.0', + ), + '1.1' => array( + 'current' => '1.1.1', + ), + ), + array( + 'current' => '1.1.1', + ), + ), + // Latest 1.0 release is EOL + array( + '1.0.0', + array( + '1.0' => array( + 'current' => '1.0.1', + 'eol' => true, + ), + '1.1' => array( + 'current' => '1.1.1', + ), + ), + array( + 'current' => '1.1.1', + ), + ), + // All are EOL -- somewhat undefined behavior + array( + '1.0.0', + array( + '1.0' => array( + 'current' => '1.0.1', + 'eol' => true, + ), + '1.1' => array( + 'current' => '1.1.1', + 'eol' => true, + ), + ), + array(), + ), + ); + } + + /** + * @dataProvider get_update_on_branch_data + */ + public function test_get_update_on_branch($current_version, $versions, $expected) + { + global $phpbb_root_path, $phpEx; + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + + $version_helper = $this + ->getMockBuilder('\phpbb\version_helper') + ->setMethods(array( + 'get_versions_matching_stability', + )) + ->setConstructorArgs(array( + $this->cache, + new \phpbb\config\config(array( + 'version' => $current_version, + )), + new \phpbb\file_downloader(), + new \phpbb\user($lang, '\phpbb\datetime'), + )) + ->getMock() + ; + + $version_helper->expects($this->any()) + ->method('get_versions_matching_stability') + ->will($this->returnValue($versions)); + + $this->assertSame($expected, $version_helper->get_update_on_branch()); + } } |