diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/RUNNING_TESTS.md | 15 | ||||
-rw-r--r-- | tests/cache/memcached_test.php | 65 | ||||
-rw-r--r-- | tests/functional/private_messages_test.php | 2 | ||||
-rw-r--r-- | tests/functional/registration_test.php | 54 | ||||
-rw-r--r-- | tests/test_framework/phpbb_test_case_helpers.php | 20 | ||||
-rw-r--r-- | tests/test_framework/phpbb_ui_test_case.php | 3 | ||||
-rw-r--r-- | tests/text_formatter/s9e/bbcode_merger_test.php | 16 |
7 files changed, 173 insertions, 2 deletions
diff --git a/tests/RUNNING_TESTS.md b/tests/RUNNING_TESTS.md index 516541151c..54db823b4a 100644 --- a/tests/RUNNING_TESTS.md +++ b/tests/RUNNING_TESTS.md @@ -109,6 +109,21 @@ Or via environment variables as follows: $ PHPBB_TEST_REDIS_HOST=localhost PHPBB_TEST_REDIS_PORT=6379 phpunit +Memcached +--------- + +In order to run tests for the memcached cache driver, at least one of memcached +host or port must be specified in the test configuration. This can be done via +test_config.php as follows: + + <?php + $phpbb_memcached_host = 'localhost'; + $phpbb_memcached_port = '11211'; + +Or via environment variables as follows: + + $ PHPBB_TEST_MEMCACHED_HOST=localhost PHPBB_TEST_MEMCACHED_PORT=11211 phpunit + Running ======= diff --git a/tests/cache/memcached_test.php b/tests/cache/memcached_test.php new file mode 100644 index 0000000000..650b72ea18 --- /dev/null +++ b/tests/cache/memcached_test.php @@ -0,0 +1,65 @@ +<?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__) . '/common_test_case.php'; + +class phpbb_cache_memcached_driver_test extends \phpbb_cache_common_test_case +{ + protected static $config; + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); + } + + static public function setUpBeforeClass() + { + if (!extension_loaded('memcached')) + { + self::markTestSkipped('memcached extension is not loaded'); + } + + $config = phpbb_test_case_helpers::get_test_config(); + if (isset($config['memcached_host']) || isset($config['memcached_port'])) + { + $host = isset($config['memcached_host']) ? $config['memcached_host'] : 'localhost'; + $port = isset($config['memcached_port']) ? $config['memcached_port'] : 11211; + self::$config = array('host' => $host, 'port' => $port); + } + else + { + self::markTestSkipped('Test memcached host/port is not specified'); + } + + $memcached = new \Memcached(); + $memcached->addServer(self::$config['host'], self::$config['port']); + if (empty($memcached->getStats())) + { + self::markTestSkipped('Test memcached server is not available'); + } + + parent::setUpBeforeClass(); + } + + protected function setUp(): void + { + global $phpbb_root_path, $phpbb_container; + + parent::setUp(); + + $phpbb_container = new phpbb_mock_container_builder(); + $phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/'); + $this->driver = new \phpbb\cache\driver\memcached(self::$config['host'] . '/' . self::$config['port']); + $this->driver->purge(); + } +} diff --git a/tests/functional/private_messages_test.php b/tests/functional/private_messages_test.php index 7fda26fb49..ce709524a9 100644 --- a/tests/functional/private_messages_test.php +++ b/tests/functional/private_messages_test.php @@ -85,7 +85,7 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case public function test_quote_pm() { $text = 'This is a test private message sent by the testing framework.'; - $expected = "(\\[quote=admin time=\\d+ user_id=2\\]\n" . $text . "\n\\[/quote\\])"; + $expected = "(\\[quote=admin msg_id=\\d+ time=\\d+ user_id=2\\]\n" . $text . "\n\\[/quote\\])"; $this->login(); $message_id = $this->create_private_message('Test', $text, array(2)); diff --git a/tests/functional/registration_test.php b/tests/functional/registration_test.php index 690f4ae9f2..48982edc8c 100644 --- a/tests/functional/registration_test.php +++ b/tests/functional/registration_test.php @@ -36,6 +36,10 @@ class phpbb_functional_registration_test extends phpbb_functional_test_case { $this->add_lang('ucp'); + // Check that we can't skip + self::request('GET', 'ucp.php?mode=register&agreed=1'); + $this->assertContainsLang('AGREE', $this->get_content()); + $crawler = self::request('GET', 'ucp.php?mode=register'); $this->assertContainsLang('REGISTRATION', $crawler->filter('div.content h2')->text()); @@ -64,4 +68,54 @@ class phpbb_functional_registration_test extends phpbb_functional_test_case $this->assert_checkbox_is_checked($crawler, 'notification.type.post_notification.method.email'); $this->assert_checkbox_is_checked($crawler, 'notification.type.topic_notification.method.email'); } + + /** + * @depends test_disable_captcha_on_registration + */ + public function test_register_coppa_account() + { + $this->login(); + $this->admin_login(); + + $crawler = self::request('GET', "adm/index.php?i=acp_board&mode=registration&sid={$this->sid}"); + $form = $crawler->selectButton('Submit')->form(); + $form['config[coppa_enable]']->setValue('1'); + $crawler = self::submit($form); + + $this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('#main .successbox')->text()); + $this->logout(); + + $this->add_lang('ucp'); + + // Check that we can't skip + $crawler = self::request('GET', 'ucp.php?mode=register&coppa=1'); + $this->assertContainsLang('COPPA_BIRTHDAY', $crawler->html()); + + $form = $crawler->selectButton('coppa_yes')->form(); + $crawler = self::submit($form); + + $this->assertContainsLang('REGISTRATION', $crawler->filter('div.content h2')->text()); + + $form = $crawler->selectButton('I agree to these terms')->form(); + $crawler = self::submit($form); + + $form = $crawler->selectButton('Submit')->form(array( + 'username' => 'user-coppa-test', + 'email' => 'user-coppa-test@phpbb.com', + 'new_password' => 'user-coppa-testuser-coppa-test', + 'password_confirm' => 'user-coppa-testuser-coppa-test', + )); + $form['tz']->select('Europe/Berlin'); + $crawler = self::submit($form); + + $this->assertContainsLang('ACCOUNT_COPPA', $crawler->filter('#message')->text()); + + $this->login(); + $this->admin_login(); + + $crawler = self::request('GET', "adm/index.php?i=acp_board&mode=registration&sid={$this->sid}"); + $form = $crawler->selectButton('Submit')->form(); + $form['config[coppa_enable]']->setValue('0'); + $crawler = self::submit($form); + } } diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 807a64d810..9a2ea275d0 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -173,6 +173,16 @@ class phpbb_test_case_helpers { $config['fulltext_sphinx_id'] = $fulltext_sphinx_id; } + + if (isset($phpbb_memcached_host)) + { + $config['memcached_host'] = $phpbb_memcached_host; + } + + if (isset($phpbb_memcached_port)) + { + $config['memcached_port'] = $phpbb_memcached_port; + } } if (isset($_SERVER['PHPBB_TEST_DBMS'])) @@ -205,6 +215,16 @@ class phpbb_test_case_helpers $config['redis_port'] = $_SERVER['PHPBB_TEST_REDIS_PORT']; } + if (isset($_SERVER['PHPBB_TEST_MEMCACHED_HOST'])) + { + $config['memcached_host'] = $_SERVER['PHPBB_TEST_MEMCACHED_HOST']; + } + + if (isset($_SERVER['PHPBB_TEST_MEMCACHED_PORT'])) + { + $config['memcached_port'] = $_SERVER['PHPBB_TEST_MEMCACHED_PORT']; + } + return $config; } diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index fcac3594d0..243db39d69 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -473,7 +473,8 @@ class phpbb_ui_test_case extends phpbb_test_case $config = new \phpbb\config\config(array()); $db = $this->get_db(); - $db_tools = new \phpbb\db\tools($db); + $factory = new \phpbb\db\tools\factory(); + $db_tools = $factory->get($this->db); $container = new phpbb_mock_container_builder(); $migrator = new \phpbb\db\migrator( diff --git a/tests/text_formatter/s9e/bbcode_merger_test.php b/tests/text_formatter/s9e/bbcode_merger_test.php index 815539056b..5ec0c91971 100644 --- a/tests/text_formatter/s9e/bbcode_merger_test.php +++ b/tests/text_formatter/s9e/bbcode_merger_test.php @@ -275,6 +275,22 @@ class phpbb_textformatter_s9e_bbcode_merger_test extends phpbb_test_case </table> <p> </p>' ], + [ + // https://www.phpbb.com/community/viewtopic.php?f=438&t=2530451 + '[issue]{NUMBER}[/issue]', + '<a href="/default/issues/{NUMBER}"> Issue #{NUMBER}</a>', + + '[issue={SIMPLETEXT}]{NUMBER}[/issue]', + '<a href="/{SIMPLETEXT}/issues/{NUMBER}"> Issue #{NUMBER} ({SIMPLETEXT})</a>', + + '[issue={SIMPLETEXT?}]{NUMBER}[/issue]', + '<a> + <xsl:choose> + <xsl:when test="@issue"><xsl:attribute name="href">/<xsl:value-of select="@issue"/>/issues/<xsl:value-of select="@content"/></xsl:attribute> Issue #<xsl:value-of select="@content"/> (<xsl:value-of select="@issue"/>)</xsl:when> + <xsl:otherwise><xsl:attribute name="href">/default/issues/<xsl:value-of select="@content"/></xsl:attribute> Issue #<xsl:value-of select="@content"/></xsl:otherwise> + </xsl:choose> + </a>' + ], ]; } } |