diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/controller/common_helper_route.php | 2 | ||||
-rw-r--r-- | tests/controller/controller_test.php | 2 | ||||
-rw-r--r-- | tests/pagination/pagination_test.php | 2 | ||||
-rw-r--r-- | tests/session/testable_factory.php | 3 | ||||
-rw-r--r-- | tests/test_framework/phpbb_functional_test_case.php | 3 | ||||
-rw-r--r-- | tests/text_processing/decode_message_test.php | 17 | ||||
-rw-r--r-- | tests/text_reparser/base_test.php | 70 | ||||
-rw-r--r-- | tests/text_reparser/fixtures/base.xml | 19 |
8 files changed, 113 insertions, 5 deletions
diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 72c5328b0b..808eb684f2 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -126,7 +126,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case new \phpbb\routing\file_locator($this->filesystem, dirname(__FILE__) . '/') ); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager); - $this->router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $this->router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php'); // Set correct current phpBB root path $this->root_path = $this->get_phpbb_root_path(); diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index 431b26b2bc..e8af2f7485 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -47,7 +47,7 @@ class phpbb_controller_controller_test extends phpbb_test_case new \phpbb\routing\file_locator(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/') ); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager); - $router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php'); $routes = $router->get_routes(); // This will need to be updated if any new routes are defined diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index 6a3b46cdae..024b6fc02d 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -46,7 +46,7 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case new \phpbb\routing\file_locator($filesystem, dirname(__FILE__) . '/') ); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $manager); - $router = new phpbb_mock_router(new phpbb_mock_container_builder(), $resources_locator, $loader, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT); + $router = new phpbb_mock_router(new phpbb_mock_container_builder(), $resources_locator, $loader, dirname(__FILE__) . '/', 'php'); $request = new phpbb_mock_request(); $request->overwrite('SCRIPT_NAME', '/app.php', \phpbb\request\request_interface::SERVER); diff --git a/tests/session/testable_factory.php b/tests/session/testable_factory.php index 7819063505..6f8b49122b 100644 --- a/tests/session/testable_factory.php +++ b/tests/session/testable_factory.php @@ -73,7 +73,7 @@ class phpbb_session_testable_factory public function get_session(\phpbb\db\driver\driver_interface $dbal) { // set up all the global variables used by session - global $SID, $_SID, $db, $config, $cache, $request, $phpbb_container; + global $SID, $_SID, $db, $config, $cache, $request, $phpbb_container, $phpbb_root_path; $request = $this->request = new phpbb_mock_request( array(), @@ -95,6 +95,7 @@ class phpbb_session_testable_factory new phpbb_mock_auth_provider() ); $phpbb_container->setParameter('core.environment', PHPBB_ENVIRONMENT); + $phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/'); $provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config); $provider_collection->add('auth.provider.db'); $phpbb_container->set( diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 53519617b3..d234642898 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -209,10 +209,11 @@ class phpbb_functional_test_case extends phpbb_test_case { if (!$this->cache) { - global $phpbb_container; + global $phpbb_container, $phpbb_root_path; $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->setParameter('core.environment', PHPBB_ENVIRONMENT); + $phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/'); $this->cache = new \phpbb\cache\driver\file; } diff --git a/tests/text_processing/decode_message_test.php b/tests/text_processing/decode_message_test.php index 7de599f2b1..fd1719fedc 100644 --- a/tests/text_processing/decode_message_test.php +++ b/tests/text_processing/decode_message_test.php @@ -16,6 +16,15 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; class phpbb_text_processing_decode_message_test extends phpbb_test_case { + public function setUp() + { + parent::setUp(); + + global $phpbb_dispatcher; + + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + } + /** * @dataProvider get_legacy_tests */ @@ -46,6 +55,14 @@ class phpbb_text_processing_decode_message_test extends phpbb_test_case '<!-- m --><a class="postlink" href="http://www.phpbb.com">http://www.phpbb.com</a><!-- m -->', 'http://www.phpbb.com' ), + array( + '<!-- m --><a class="postlink" href="http://www.phpbb.com">this is just text</a><!-- m -->', + 'http://www.phpbb.com' + ), + array( + '<!-- m --><a class="postlink" href="http://www.phpbb.com/some/more/link/that/is/shortened">http://www.phpbb.com/some/ ... /shortened</a><!-- m -->', + 'http://www.phpbb.com/some/more/link/that/is/shortened' + ), /** * Fails as per PHPBB3-8420 * @link http://tracker.phpbb.com/browse/PHPBB3-8420 diff --git a/tests/text_reparser/base_test.php b/tests/text_reparser/base_test.php new file mode 100644 index 0000000000..2223ead9a6 --- /dev/null +++ b/tests/text_reparser/base_test.php @@ -0,0 +1,70 @@ +<?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 __DIR__ . '/../../phpBB/includes/functions.php'; +require_once __DIR__ . '/../../phpBB/includes/functions_content.php'; +require_once __DIR__ . '/../test_framework/phpbb_database_test_case.php'; + +class phpbb_textreparser_base_test extends phpbb_database_test_case +{ + protected $db; + + public function setUp() + { + global $config; + if (!isset($config)) + { + $config = new \phpbb\config\config(array()); + } + $this->get_test_case_helpers()->set_s9e_services(); + $this->db = $this->new_dbal(); + parent::setUp(); + } + + public function getDataSet() + { + return $this->createXMLDataSet(__DIR__ . '/fixtures/base.xml'); + } + + protected function get_reparser() + { + return new \phpbb\textreparser\plugins\post_text($this->db, POSTS_TABLE); + } + + protected function get_rows(array $ids) + { + $sql = 'SELECT post_id AS id, post_text AS text + FROM ' . POSTS_TABLE . ' + WHERE ' . $this->db->sql_in_set('post_id', $ids) . ' + ORDER BY id'; + $result = $this->db->sql_query($sql); + $rows = $this->db->sql_fetchrowset($result); + $this->db->sql_freeresult($result); + + return $rows; + } + + public function test_reparse_empty() + { + $this->get_reparser()->reparse_range(1, 1); + + $this->assertEquals( + array( + array( + 'id' => 1, + 'text' => '<t></t>' + ) + ), + $this->get_rows(array(1)) + ); + } +} diff --git a/tests/text_reparser/fixtures/base.xml b/tests/text_reparser/fixtures/base.xml new file mode 100644 index 0000000000..a4921a8823 --- /dev/null +++ b/tests/text_reparser/fixtures/base.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<dataset> + <table name="phpbb_posts"> + <column>post_id</column> + <column>enable_bbcode</column> + <column>enable_smilies</column> + <column>enable_magic_url</column> + <column>post_text</column> + <column>bbcode_uid</column> + <row> + <value>1</value> + <value>1</value> + <value>1</value> + <value>1</value> + <value></value> + <value>abcd1234</value> + </row> + </table> +</dataset> |