aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/RUNNING_TESTS.md15
-rw-r--r--tests/cache/memcached_test.php65
-rw-r--r--tests/functional/private_messages_test.php2
-rw-r--r--tests/test_framework/phpbb_test_case_helpers.php20
-rw-r--r--tests/text_formatter/s9e/bbcode_merger_test.php16
5 files changed, 117 insertions, 1 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/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/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>'
+ ],
];
}
}