diff options
Diffstat (limited to 'tests')
19 files changed, 251 insertions, 48 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/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/posting_test.php b/tests/functional/posting_test.php index 9dd8a1dc91..83acefd2f3 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() 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/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index d5e78d1d60..e678bfbaef 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -304,6 +304,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-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/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()); } } |