diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cache/apcu_driver_test.php | 17 | ||||
-rw-r--r-- | tests/event/fixtures/extra_description.test | 2 | ||||
-rw-r--r-- | tests/event/php_exporter_test.php | 2 | ||||
-rw-r--r-- | tests/migrator/get_callable_from_step_test.php | 136 | ||||
-rw-r--r-- | tests/template/context_test.php | 96 | ||||
-rw-r--r-- | tests/template/template_test.php | 2 | ||||
-rw-r--r-- | tests/test_framework/phpbb_functional_test_case.php | 4 |
7 files changed, 252 insertions, 7 deletions
diff --git a/tests/cache/apcu_driver_test.php b/tests/cache/apcu_driver_test.php index 9de1d82a15..57f640c313 100644 --- a/tests/cache/apcu_driver_test.php +++ b/tests/cache/apcu_driver_test.php @@ -49,10 +49,27 @@ class phpbb_cache_apcu_driver_test extends phpbb_cache_common_test_case protected function setUp() { + global $phpbb_container, $phpbb_root_path; + 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\apcu; $this->driver->purge(); } + + public function test_purge() + { + /* add a cache entry which does not match our key */ + $foreign_key = 'test_' . $this->driver->key_prefix . 'test'; + $this->assertSame(true, apcu_store($foreign_key, 0, 600)); + $this->assertSame(true, apcu_exists($foreign_key)); + + parent::test_purge(); + + $this->assertSame(true, apcu_exists($foreign_key)); + } } diff --git a/tests/event/fixtures/extra_description.test b/tests/event/fixtures/extra_description.test index ce8f97ce89..e93a1044ac 100644 --- a/tests/event/fixtures/extra_description.test +++ b/tests/event/fixtures/extra_description.test @@ -3,7 +3,7 @@ /** * Description * -* NOTE: This will not be exported +* NOTE: This will also be exported * * @event extra_description.dispatch * @since 3.1.0-b2 diff --git a/tests/event/php_exporter_test.php b/tests/event/php_exporter_test.php index 21dbb1e1d4..c6670e1340 100644 --- a/tests/event/php_exporter_test.php +++ b/tests/event/php_exporter_test.php @@ -57,7 +57,7 @@ class phpbb_event_php_exporter_test extends phpbb_test_case 'file' => 'extra_description.test', 'arguments' => array(), 'since' => '3.1.0-b2', - 'description' => 'Description', + 'description' => 'Description<br/><br/>NOTE: This will also be exported', ), ), ), diff --git a/tests/migrator/get_callable_from_step_test.php b/tests/migrator/get_callable_from_step_test.php new file mode 100644 index 0000000000..af636f5d21 --- /dev/null +++ b/tests/migrator/get_callable_from_step_test.php @@ -0,0 +1,136 @@ +<?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. + * + */ + +class get_callable_from_step_test extends phpbb_database_test_case +{ + public function setUp() + { + global $phpbb_root_path, $php_ext, $table_prefix, $phpbb_log; + + parent::setUp(); + + $phpbb_log = $this->getMockBuilder('\phpbb\log\log')->disableOriginalConstructor()->getMock(); + $db = $this->new_dbal(); + $factory = new \phpbb\db\tools\factory(); + $cache_service = $this->getMockBuilder('\phpbb\cache\service')->disableOriginalConstructor()->getMock(); + $user = $this->getMockBuilder('\phpbb\user')->disableOriginalConstructor()->getMock(); + $module_manager = new \phpbb\module\module_manager( + $this->getMockBuilder('\phpbb\cache\driver\dummy')->disableOriginalConstructor()->getMock(), + $db, + new phpbb_mock_extension_manager($phpbb_root_path), + 'phpbb_modules', + $phpbb_root_path, + $php_ext + ); + $module_tools = new \phpbb\db\migration\tool\module($db, $cache_service, $user, $module_manager, $phpbb_root_path, $php_ext, 'phpbb_modules'); + $this->migrator = new \phpbb\db\migrator( + new phpbb_mock_container_builder(), + new \phpbb\config\config(array()), + $db, + $factory->get($db), + 'phpbb_migrations', + $phpbb_root_path, + $php_ext, + $table_prefix, + array($module_tools), + new \phpbb\db\migration\helper() + ); + + if (!$module_tools->exists('acp', 0, 'new_module_langname')) + { + $module_tools->add('acp', 0, array( + 'module_basename' => 'new_module_basename', + 'module_langname' => 'new_module_langname', + 'module_mode' => 'settings', + 'module_auth' => '', + 'module_display' => true, + 'before' => false, + 'after' => false, + )); + $this->module_added = true; + } + } + + public function getDataSet() + { + return $this->createXMLDataSet(dirname(__FILE__).'/../dbal/fixtures/migrator.xml'); + } + + public function get_callable_from_step_provider() + { + return array( + array( + array('if', array( + false, + array('permission.add', array('some_data')), + )), + true, // expects false + ), + array( + array('if', array( + array('module.exists', array( + 'mcp', + 'RANDOM_PARENT', + 'RANDOM_MODULE' + )), + array('permission.add', array('some_data')), + )), + true, // expects false + ), + array( + array('if', array( + array('module.exists', array( + 'acp', + 0, + 'new_module_langname' + )), + array('module.add', array( + 'acp', + 0, + 'module_basename' => 'new_module_basename2', + 'module_langname' => 'new_module_langname2', + 'module_mode' => 'settings', + 'module_auth' => '', + 'module_display' => true, + 'before' => false, + 'after' => false, + )), + )), + false, // expects false + ), + ); + } + + /** + * @dataProvider get_callable_from_step_provider + */ + public function test_get_callable_from_step($step, $expects_false) + { + if ($expects_false) + { + $this->assertFalse($this->call_get_callable_from_step($step)); + } + else + { + $this->assertNotFalse($this->call_get_callable_from_step($step)); + } + } + + protected function call_get_callable_from_step($step) + { + $class = new ReflectionClass($this->migrator); + $method = $class->getMethod('get_callable_from_step'); + $method->setAccessible(true); + return $method->invokeArgs($this->migrator, array($step)); + } +} diff --git a/tests/template/context_test.php b/tests/template/context_test.php new file mode 100644 index 0000000000..52ce6c8fde --- /dev/null +++ b/tests/template/context_test.php @@ -0,0 +1,96 @@ +<?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. +* +*/ + +class context_test extends phpbb_test_case +{ + protected $context; + protected function setUp() + { + $this->context = new \phpbb\template\context(); + + for ($i = 0; $i < 10; $i++) + { + $this->context->assign_block_vars('block' . $i, array( + 'FOO' . $i => 'foo' . $i, + 'BAR' . $i => 'bar' . $i, + )); + + for ($j = 0; $j < 10; $j++) + { + $this->context->assign_block_vars('block' . $i . '.subblock', array( + 'SUBFOO' => 'subfoo' . $j, + 'SUBBAR' => 'subbar' . $j, + )); + + for ($k = 0; $k < 10; $k++) + { + $this->context->assign_block_vars('block' . $i . '.subblock.subsubblock', array( + 'SUBSUBFOO' => 'subsubfoo' . $k, + 'SUBSUBBAR' => 'subsubbar' . $k, + )); + } + } + } + } + + public function retrieve_block_vars_data() + { + return array( + array('foo', array(), array()), // non-existent top-level block + array('block1.foo', array(), array()), // non-existent sub-level block + array('block1', array(), array( // top-level block, all vars + 'FOO1' => 'foo1', + 'BAR1' => 'bar1', + )), + array('block1', array('FOO1'), array( // top-level block, one var + 'FOO1' => 'foo1', + )), + array('block2.subblock', array(), array( // sub-level block, all vars + 'SUBFOO' => 'subfoo9', + 'SUBBAR' => 'subbar9', + )), + array('block2.subblock', array('SUBBAR'), array( // sub-level block, one var + 'SUBBAR' => 'subbar9', + )), + array('block2.subblock.subsubblock', array(), array( // sub-sub-level block, all vars + 'SUBSUBFOO' => 'subsubfoo9', + 'SUBSUBBAR' => 'subsubbar9', + )), + array('block2.subblock.subsubblock', array('SUBSUBBAR'), array( // sub-sub-level block, one var + 'SUBSUBBAR' => 'subsubbar9', + )), + array('block3.subblock[2]', array(), array( // sub-level, exact index, all vars + 'SUBFOO' => 'subfoo2', + 'SUBBAR' => 'subbar2', + )), + array('block3.subblock[2]', array('SUBBAR'), array( // sub-level, exact index, one var + 'SUBBAR' => 'subbar2', + )), + array('block3.subblock[3].subsubblock[5]', array(), array( // sub-sub-level, exact index, all vars + 'SUBSUBFOO' => 'subsubfoo5', + 'SUBSUBBAR' => 'subsubbar5', + )), + array('block3.subblock[4].subsubblock[6]', array('SUBSUBFOO'), array( // sub-sub-level, exact index, one var + 'SUBSUBFOO' => 'subsubfoo6', + )), + ); + } + + /** + * @dataProvider retrieve_block_vars_data + */ + public function test_retrieve_block_vars($blockname, $vararray, $result) + { + $this->assertEquals($result, $this->context->retrieve_block_vars($blockname, $vararray)); + } +} diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 0f761abc76..727f35e9d2 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -364,7 +364,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), array(), array(), - "Value'\n1 O'Clock\nValue\\x27\n1\\x20O\\x27Clock", + "Value'\n1 O'Clock\nValue\\u0027\n1\\u0020O\\u0027Clock", array('VARIABLE' => "Value'", '1_VARIABLE' => "1 O'Clock"), ), array( diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index e1daa4558a..12a296a4bf 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -1176,10 +1176,6 @@ class phpbb_functional_test_case extends phpbb_test_case } } - // Bypass time restriction that said that if the lastclick time (i.e. time when the form was opened) - // is not at least 2 seconds before submission, cancel the form - $form_data['lastclick'] = 0; - // I use a request because the form submission method does not allow you to send data that is not // contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs) // Instead, I send it as a request with the submit button "post" set to true. |