diff options
Diffstat (limited to 'tests')
20 files changed, 304 insertions, 218 deletions
diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index 588adbcfb1..550679ff07 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -21,20 +21,18 @@ class phpbb_controller_controller_test extends phpbb_test_case $this->extension_manager = new phpbb_mock_extension_manager( dirname(__FILE__) . '/', array( - 'foo' => array( - 'ext_name' => 'foo', + 'vendor2/foo' => array( + 'ext_name' => 'vendor2/foo', 'ext_active' => '1', - 'ext_path' => 'ext/foo/', + 'ext_path' => 'ext/vendor2/foo/', ), )); } public function test_provider() { - $provider = new \phpbb\controller\provider; - $routes = $provider - ->import_paths_from_finder($this->extension_manager->get_finder()) - ->find(__DIR__); + $provider = new \phpbb\controller\provider($this->extension_manager->get_finder()); + $routes = $provider->find(__DIR__)->get_routes(); // This will need to be updated if any new routes are defined $this->assertInstanceOf('Symfony\Component\Routing\Route', $routes->get('core_controller')); @@ -52,7 +50,7 @@ class phpbb_controller_controller_test extends phpbb_test_case $container = new ContainerBuilder(); // YamlFileLoader only uses one path at a time, so we need to loop // through all of the ones we are using. - foreach (array(__DIR__.'/config', __DIR__.'/ext/foo/config') as $path) + foreach (array(__DIR__.'/config', __DIR__ . '/ext/vendor2/foo/config') as $path) { $loader = new YamlFileLoader($container, new FileLocator($path)); $loader->load('services.yml'); @@ -60,9 +58,9 @@ class phpbb_controller_controller_test extends phpbb_test_case // Autoloading classes within the tests folder does not work // so I'll include them manually. - if (!class_exists('foo\\controller')) + if (!class_exists('vendor2\\foo\\controller')) { - include(__DIR__.'/ext/foo/controller.php'); + include(__DIR__ . '/ext/vendor2/foo/controller.php'); } if (!class_exists('phpbb\\controller\\foo')) { diff --git a/tests/controller/ext/foo/config/routing_2.yml b/tests/controller/ext/foo/config/routing_2.yml deleted file mode 100644 index 35fff27037..0000000000 --- a/tests/controller/ext/foo/config/routing_2.yml +++ /dev/null @@ -1,3 +0,0 @@ -controller2: - pattern: /bar - defaults: { _controller: foo.controller:handle } diff --git a/tests/controller/ext/foo/config/routing.yml b/tests/controller/ext/vendor2/foo/config/routing.yml index 6cc275d96d..6cc275d96d 100644 --- a/tests/controller/ext/foo/config/routing.yml +++ b/tests/controller/ext/vendor2/foo/config/routing.yml diff --git a/tests/controller/ext/vendor2/foo/config/routing_2.yml b/tests/controller/ext/vendor2/foo/config/routing_2.yml new file mode 100644 index 0000000000..d987a65aea --- /dev/null +++ b/tests/controller/ext/vendor2/foo/config/routing_2.yml @@ -0,0 +1,6 @@ +controller2: + pattern: /bar + defaults: { _controller: foo.controller:handle } +controller3: + pattern: /bar/p-{p} + defaults: { _controller: foo.controller:handle } diff --git a/tests/controller/ext/foo/config/services.yml b/tests/controller/ext/vendor2/foo/config/services.yml index 9ed67d5bc2..9ed67d5bc2 100644 --- a/tests/controller/ext/foo/config/services.yml +++ b/tests/controller/ext/vendor2/foo/config/services.yml diff --git a/tests/controller/ext/foo/controller.php b/tests/controller/ext/vendor2/foo/controller.php index ce2233b3c9..ce2233b3c9 100644 --- a/tests/controller/ext/foo/controller.php +++ b/tests/controller/ext/vendor2/foo/controller.php diff --git a/tests/controller/helper_route_test.php b/tests/controller/helper_route_test.php new file mode 100644 index 0000000000..5264c788c7 --- /dev/null +++ b/tests/controller/helper_route_test.php @@ -0,0 +1,128 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + +class phpbb_controller_helper_route_test extends phpbb_test_case +{ + public function setUp() + { + global $phpbb_dispatcher, $phpbb_root_path, $phpEx; + + $phpbb_dispatcher = new phpbb_mock_event_dispatcher; + $this->user = $this->getMock('\phpbb\user'); + $phpbb_path_helper = new \phpbb\path_helper( + new \phpbb\symfony_request( + new phpbb_mock_request() + ), + new \phpbb\filesystem(), + $phpbb_root_path, + $phpEx + ); + $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); + $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $this->user, new \phpbb\template\context()); + + $finder = new \phpbb\extension\finder( + new phpbb_mock_extension_manager( + dirname(__FILE__) . '/', + array( + 'vendor2/foo' => array( + 'ext_name' => 'vendor2/foo', + 'ext_active' => '1', + 'ext_path' => 'ext/vendor2/foo/', + ), + ) + ), + new \phpbb\filesystem(), + dirname(__FILE__) . '/', + new phpbb_mock_cache() + ); + $this->provider = new \phpbb\controller\provider($finder); + $this->provider->find(dirname(__FILE__) . '/'); + } + + public function helper_url_data_no_rewrite() + { + return array( + array('controller2', array('t' => 1, 'f' => 2), true, false, 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'), + array('controller2', array('t' => 1, 'f' => 2), false, false, 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'), + array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'), + array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'), + + // Custom sid parameter + array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'), + array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'), + array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', 'app.php/foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'), + + // Testing anchors + array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'), + array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'), + array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'app.php/foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'), + + // Anchors and custom sid + array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'), + array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'), + array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'app.php/foo/bar/p-3?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'), + + // Empty parameters should not append the & or ? + array('controller2', array(), true, false, 'app.php/foo/bar', 'no params using empty array'), + array('controller2', array(), false, false, 'app.php/foo/bar', 'no params using empty array'), + array('controller3', array('p' => 3), true, false, 'app.php/foo/bar/p-3', 'no params using empty array'), + ); + } + + /** + * @dataProvider helper_url_data_no_rewrite() + */ + public function test_helper_url_no_rewrite($route, $params, $is_amp, $session_id, $expected, $description) + { + $this->helper = new \phpbb\controller\helper($this->template, $this->user, $this->config, $this->provider, '', 'php'); + $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id)); + } + + public function helper_url_data_with_rewrite() + { + return array( + array('controller2', array('t' => 1, 'f' => 2), true, false, 'foo/bar?t=1&f=2', 'parameters in params-argument as array'), + array('controller2', array('t' => 1, 'f' => 2), false, false, 'foo/bar?t=1&f=2', 'parameters in params-argument as array'), + array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'), + array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'), + + // Custom sid parameter + array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'), + array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'), + array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', 'foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'), + + // Testing anchors + array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'), + array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'), + array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'), + + // Anchors and custom sid + array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'), + array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'), + array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'foo/bar/p-3?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'), + + // Empty parameters should not append the & or ? + array('controller2', array(), true, false, 'foo/bar', 'no params using empty array'), + array('controller2', array(), false, false, 'foo/bar', 'no params using empty array'), + array('controller3', array('p' => 3), true, false, 'foo/bar/p-3', 'no params using empty array'), + ); + } + + /** + * @dataProvider helper_url_data_with_rewrite() + */ + public function test_helper_url_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) + { + $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); + $this->helper = new \phpbb\controller\helper($this->template, $this->user, $this->config, $this->provider, '', 'php'); + $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id)); + } +} diff --git a/tests/controller/helper_url_test.php b/tests/controller/helper_url_test.php deleted file mode 100644 index 33fc6c4f1b..0000000000 --- a/tests/controller/helper_url_test.php +++ /dev/null @@ -1,119 +0,0 @@ -<?php -/** -* -* @package testing -* @copyright (c) 2013 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 -* -*/ - -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; - -class phpbb_controller_helper_url_test extends phpbb_test_case -{ - - public function helper_url_data_no_rewrite() - { - return array( - array('foo/bar?t=1&f=2', false, true, false, 'app.php/foo/bar?t=1&f=2', 'parameters in url-argument'), - array('foo/bar', 't=1&f=2', true, false, 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument using amp'), - array('foo/bar', 't=1&f=2', false, false, 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument using &'), - array('foo/bar', array('t' => 1, 'f' => 2), true, false, 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'), - - // Custom sid parameter - array('foo/bar', 't=1&f=2', true, 'custom-sid', 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'using session_id'), - - // Testing anchors - array('foo/bar?t=1&f=2#anchor', false, true, false, 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in url-argument'), - array('foo/bar', 't=1&f=2#anchor', true, false, 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument'), - array('foo/bar', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'), - - // Anchors and custom sid - array('foo/bar?t=1&f=2#anchor', false, true, 'custom-sid', 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in url-argument using session_id'), - array('foo/bar', 't=1&f=2#anchor', true, 'custom-sid', 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument using session_id'), - array('foo/bar', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'), - - // Empty parameters should not append the & - array('foo/bar', false, true, false, 'app.php/foo/bar', 'no params using bool false'), - array('foo/bar', '', true, false, 'app.php/foo/bar', 'no params using empty string'), - array('foo/bar', array(), true, false, 'app.php/foo/bar', 'no params using empty array'), - ); - } - - /** - * @dataProvider helper_url_data_no_rewrite() - */ - public function test_helper_url_no_rewrite($route, $params, $is_amp, $session_id, $expected, $description) - { - global $phpbb_dispatcher, $phpbb_root_path, $phpEx; - - $phpbb_dispatcher = new phpbb_mock_event_dispatcher; - $this->user = $this->getMock('\phpbb\user'); - $phpbb_path_helper = new \phpbb\path_helper( - new \phpbb\symfony_request( - new phpbb_mock_request() - ), - new \phpbb\filesystem(), - $phpbb_root_path, - $phpEx - ); - $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $config, $this->user, new \phpbb\template\context()); - - // We don't use mod_rewrite in these tests - $config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $helper = new \phpbb\controller\helper($this->template, $this->user, $config, '', 'php'); - $this->assertEquals($helper->url($route, $params, $is_amp, $session_id), $expected); - } - - public function helper_url_data_with_rewrite() - { - return array( - array('foo/bar?t=1&f=2', false, true, false, 'foo/bar?t=1&f=2', 'parameters in url-argument'), - array('foo/bar', 't=1&f=2', true, false, 'foo/bar?t=1&f=2', 'parameters in params-argument using amp'), - array('foo/bar', 't=1&f=2', false, false, 'foo/bar?t=1&f=2', 'parameters in params-argument using &'), - array('foo/bar', array('t' => 1, 'f' => 2), true, false, 'foo/bar?t=1&f=2', 'parameters in params-argument as array'), - - // Custom sid parameter - array('foo/bar', 't=1&f=2', true, 'custom-sid', 'foo/bar?t=1&f=2&sid=custom-sid', 'using session_id'), - - // Testing anchors - array('foo/bar?t=1&f=2#anchor', false, true, false, 'foo/bar?t=1&f=2#anchor', 'anchor in url-argument'), - array('foo/bar', 't=1&f=2#anchor', true, false, 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument'), - array('foo/bar', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'), - - // Anchors and custom sid - array('foo/bar?t=1&f=2#anchor', false, true, 'custom-sid', 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in url-argument using session_id'), - array('foo/bar', 't=1&f=2#anchor', true, 'custom-sid', 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument using session_id'), - array('foo/bar', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'), - - // Empty parameters should not append the & - array('foo/bar', false, true, false, 'foo/bar', 'no params using bool false'), - array('foo/bar', '', true, false, 'foo/bar', 'no params using empty string'), - array('foo/bar', array(), true, false, 'foo/bar', 'no params using empty array'), - ); - } - - /** - * @dataProvider helper_url_data_with_rewrite() - */ - public function test_helper_url_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) - { - global $phpbb_dispatcher, $phpbb_root_path, $phpEx; - - $phpbb_dispatcher = new phpbb_mock_event_dispatcher; - $this->user = $this->getMock('\phpbb\user'); - $phpbb_path_helper = new \phpbb\path_helper( - new \phpbb\symfony_request( - new phpbb_mock_request() - ), - new \phpbb\filesystem(), - $phpbb_root_path, - $phpEx - ); - $this->template = new \phpbb\template\twig\twig($phpbb_path_helper, $config, $this->user, new \phpbb\template\context()); - - $config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $helper = new \phpbb\controller\helper($this->template, $this->user, $config, '', 'php'); - $this->assertEquals($helper->url($route, $params, $is_amp, $session_id), $expected); - } -} diff --git a/tests/functional/fixtures/ext/foo/bar/config/routing.yml b/tests/functional/fixtures/ext/foo/bar/config/routing.yml index a24d1cb986..08bc73038f 100644 --- a/tests/functional/fixtures/ext/foo/bar/config/routing.yml +++ b/tests/functional/fixtures/ext/foo/bar/config/routing.yml @@ -21,3 +21,15 @@ foo_login_redirect_controller: foo_redirect_controller: pattern: /foo/redirect defaults: { _controller: foo_bar.controller:redirect } + +foo_index_controller: + pattern: /index + defaults: { _controller: foo_bar.controller:redirect } + +foo_tests_index_controller: + pattern: /tests/index + defaults: { _controller: foo_bar.controller:redirect } + +foo_tests_dotdot_index_controller: + pattern: /tests/../index + defaults: { _controller: foo_bar.controller:redirect } diff --git a/tests/functional/fixtures/ext/foo/bar/controller/controller.php b/tests/functional/fixtures/ext/foo/bar/controller/controller.php index 3b365bcfee..47d856a5df 100644 --- a/tests/functional/fixtures/ext/foo/bar/controller/controller.php +++ b/tests/functional/fixtures/ext/foo/bar/controller/controller.php @@ -77,40 +77,19 @@ class controller 'tests/index.php', ), array( - $this->helper->url('index'), + $this->helper->route('foo_index_controller'), $rewrite_prefix . 'index', ), array( - $this->helper->url('tests/index'), + $this->helper->route('foo_tests_index_controller'), $rewrite_prefix . 'tests/index', ), + /** + * Symfony does not allow /../ in routes array( - $this->helper->url('tests/../index'), + $this->helper->route('foo_tests_dotdot_index_controller'), $rewrite_prefix . 'index', ), - /* - // helper URLs starting with ../ are prone to failure. - // Do not test them right now. - array( - $this->helper->url('../index'), - '../index', - ), - array( - $this->helper->url('../../index'), - '../index', - ), - array( - $this->helper->url('../tests/index'), - $rewrite_prefix . '../tests/index', - ), - array( - $this->helper->url('../tests/../index'), - '../index', - ), - array( - $this->helper->url('../../tests/index'), - '../tests/index', - ), */ ); diff --git a/tests/functional/search/mysql_test.php b/tests/functional/search/mysql_test.php index 7af8051417..52a7b14f40 100644 --- a/tests/functional/search/mysql_test.php +++ b/tests/functional/search/mysql_test.php @@ -16,8 +16,4 @@ class phpbb_functional_search_mysql_test extends phpbb_functional_search_base { protected $search_backend = '\phpbb\search\fulltext_mysql'; - protected function assert_search_not_found($keywords) - { - $this->markTestIncomplete('MySQL search when fails doesn\'t show the search query'); - } } diff --git a/tests/functional/search/native_test.php b/tests/functional/search/native_test.php index ce568df616..512c6f2830 100644 --- a/tests/functional/search/native_test.php +++ b/tests/functional/search/native_test.php @@ -15,9 +15,4 @@ require_once dirname(__FILE__) . '/base.php'; class phpbb_functional_search_native_test extends phpbb_functional_search_base { protected $search_backend = '\phpbb\search\fulltext_native'; - - protected function assert_search_not_found($keywords) - { - $this->markTestIncomplete('Native search when fails doesn\'t show the search query'); - } } diff --git a/tests/functional/search/postgres_test.php b/tests/functional/search/postgres_test.php index 487b8aeebb..974b417659 100644 --- a/tests/functional/search/postgres_test.php +++ b/tests/functional/search/postgres_test.php @@ -16,8 +16,4 @@ class phpbb_functional_search_postgres_test extends phpbb_functional_search_base { protected $search_backend = '\phpbb\search\fulltext_postgres'; - protected function assert_search_not_found($keywords) - { - $this->markTestIncomplete('Postgres search when fails doesn\'t show the search query'); - } } diff --git a/tests/pagination/config/routing.yml b/tests/pagination/config/routing.yml new file mode 100644 index 0000000000..dd667274cd --- /dev/null +++ b/tests/pagination/config/routing.yml @@ -0,0 +1,6 @@ +core_controller: + pattern: /test + defaults: { _controller: core_foo.controller:bar, page: 1} +core_page_controller: + pattern: /test/page/{page} + defaults: { _controller: core_foo.controller:bar} diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index b7a4f101aa..71206dff58 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -21,11 +21,27 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case public function setUp() { parent::setUp(); - $user = $this->getMock('\phpbb\user'); - $user->expects($this->any()) + + global $phpbb_dispatcher; + + $phpbb_dispatcher = new phpbb_mock_event_dispatcher; + $this->user = $this->getMock('\phpbb\user'); + $this->user->expects($this->any()) ->method('lang') ->will($this->returnCallback(array($this, 'return_callback_implode'))); - $this->pagination = new \phpbb\pagination($this->template, $user); + + $this->finder = new \phpbb\extension\finder( + new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array()), + new \phpbb\filesystem(), + dirname(__FILE__) . '/', + new phpbb_mock_cache() + ); + + $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); + $provider = new \phpbb\controller\provider($this->finder); + $provider->find(dirname(__FILE__) . '/'); + $this->helper = new \phpbb\controller\helper($this->template, $this->user, $this->config, $provider, '', 'php'); + $this->pagination = new \phpbb\pagination($this->template, $this->user, $this->helper); } public function generate_template_pagination_data() @@ -77,15 +93,18 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case :u_next:page.php?start=30', ), array( - 'test/page/%d', - '/page/%d', + array('routes' => array( + 'core_controller', + 'core_page_controller', + )), + 'page', 95, 10, 10, 'pagination :per_page:10 :current_page:2 - :base_url:test/page/%d + :base_url: :previous::test :else:1:test :current:2:test/page/2 @@ -99,15 +118,18 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case :u_next:test/page/3', ), array( - 'test/page/%d', - '/page/%d', + array('routes' => array( + 'core_controller', + 'core_page_controller', + )), + 'page', 95, 10, 20, 'pagination :per_page:10 :current_page:3 - :base_url:test/page/%d + :base_url: :previous::test/page/2 :else:1:test :else:2:test/page/2 diff --git a/tests/search/native_test.php b/tests/search/native_test.php index 18c6df2445..e860a4f89a 100644 --- a/tests/search/native_test.php +++ b/tests/search/native_test.php @@ -106,17 +106,66 @@ class phpbb_search_native_test extends phpbb_search_test_case array( '-foo', 'all', - false, - null, - null, + true, + array(), + array(1), array(), ), array( '-foo -bar', 'all', - false, - null, - null, + true, + array(), + array(1, 2), + array(), + ), + array( + 'foo -foo', + 'all', + true, + array(1), + array(1), + array(), + ), + array( + '-foo foo', + 'all', + true, + array(1), + array(1), + array(), + ), + // some creative edge cases + array( + 'foo foo-', + 'all', + true, + array(1), + array(), + array(), + ), + array( + 'foo- foo', + 'all', + true, + array(1), + array(), + array(), + ), + array( + 'foo-bar', + 'all', + true, + array(1, 2), + array(), + array(), + ), + array( + 'foo-bar-foo', + 'all', + true, + array(1, 2), + array(), array(), ), // all common diff --git a/tests/security/hash_test.php b/tests/security/hash_test.php index bc1bebd87a..32aa234316 100644 --- a/tests/security/hash_test.php +++ b/tests/security/hash_test.php @@ -7,7 +7,7 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions_compatibility.php'; class phpbb_security_hash_test extends phpbb_test_case { diff --git a/tests/security/redirect_test.php b/tests/security/redirect_test.php index 77dc955c26..e5ff3b1541 100644 --- a/tests/security/redirect_test.php +++ b/tests/security/redirect_test.php @@ -15,11 +15,8 @@ class phpbb_security_redirect_test extends phpbb_security_test_base { protected $path_helper; - protected $controller_helper; - public function provider() { - $this->controller_helper = $this->get_controller_helper(); // array(Input -> redirect(), expected triggered error (else false), expected returned result url (else false)) return array( array('data://x', false, false, 'http://localhost/phpBB'), @@ -38,8 +35,8 @@ class phpbb_security_redirect_test extends phpbb_security_test_base array('./../foo/bar', false, false, 'http://localhost/foo/bar'), array('./../foo/bar', true, false, 'http://localhost/foo/bar'), array('app.php/', false, false, 'http://localhost/phpBB/app.php/'), - array($this->controller_helper->url('a'), false, false, 'http://localhost/phpBB/app.php/a'), - array($this->controller_helper->url(''), false, false, 'http://localhost/phpBB/app.php/'), + array('app.php/a', false, false, 'http://localhost/phpBB/app.php/a'), + array('app.php/a/b', false, false, 'http://localhost/phpBB/app.php/a/b'), array('./app.php/', false, false, 'http://localhost/phpBB/app.php/'), array('foobar', false, false, 'http://localhost/phpBB/foobar'), array('./foobar', false, false, 'http://localhost/phpBB/foobar'), @@ -69,31 +66,6 @@ class phpbb_security_redirect_test extends phpbb_security_test_base return $this->path_helper; } - protected function get_controller_helper() - { - if (!($this->controller_helper instanceof \phpbb\controller\helper)) - { - global $phpbb_dispatcher; - - $phpbb_dispatcher = new phpbb_mock_event_dispatcher; - $this->user = $this->getMock('\phpbb\user'); - $phpbb_path_helper = new \phpbb\path_helper( - new \phpbb\symfony_request( - new phpbb_mock_request() - ), - new \phpbb\filesystem(), - $phpbb_root_path, - $phpEx - ); - $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $config, $this->user, new \phpbb\template\context()); - - // We don't use mod_rewrite in these tests - $config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $this->controller_helper = new \phpbb\controller\helper($this->template, $this->user, $config, '', 'php'); - } - return $this->controller_helper; - } - protected function setUp() { parent::setUp(); @@ -103,7 +75,6 @@ class phpbb_security_redirect_test extends phpbb_security_test_base ); $this->path_helper = $this->get_path_helper(); - $this->controller_helper = $this->get_controller_helper(); } /** diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 6e9b7d3ee9..aaf55fd15c 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -562,6 +562,40 @@ EOT $this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after modification'); } + public function assign_block_vars_array_data() + { + return array( + array( + array( + 'outer' => array( + array('VARIABLE' => 'Test assigning block vars array loop 0:'), + array('VARIABLE' => 'Test assigning block vars array loop 1:'), + ), + 'outer.middle' => array( + array('VARIABLE' => '1st iteration',), + array('VARIABLE' => '2nd iteration',), + array('VARIABLE' => '3rd iteration',), + ), + ) + ) + ); + } + + /** + * @dataProvider assign_block_vars_array_data + */ + public function test_assign_block_vars_array($block_data) + { + $this->template->set_filenames(array('test' => 'loop_nested.html')); + + foreach ($block_data as $blockname => $block_vars_array) + { + $this->template->assign_block_vars_array($blockname, $block_vars_array); + } + + $this->assertEquals("outer - 0 - Test assigning block vars array loop 0:outer - 1 - Test assigning block vars array loop 1:middle - 0 - 1st iterationmiddle - 1 - 2nd iterationmiddle - 2 - 3rd iteration", $this->display('test'), 'Ensuring assigning block vars array to template is working correctly'); + } + /** * @expectedException Twig_Error_Syntax */ diff --git a/tests/tree/nestedset_forum_get_data_test.php b/tests/tree/nestedset_forum_get_data_test.php index ca1863e55e..a0d0778e82 100644 --- a/tests/tree/nestedset_forum_get_data_test.php +++ b/tests/tree/nestedset_forum_get_data_test.php @@ -116,4 +116,20 @@ class phpbb_tests_tree_nestedset_forum_get_data_test extends phpbb_tests_tree_ne $forum_data['forum_parents'] = $forum_parents; $this->assertEquals($expected, array_keys($this->set->get_path_basic_data($forum_data))); } + + public function get_all_tree_data_data() + { + return array( + array(true, array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)), + array(false, array(11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)), + ); + } + + /** + * @dataProvider get_all_tree_data_data + */ + public function test_get_all_tree_data($order_asc, $expected) + { + $this->assertEquals($expected, array_keys($this->set->get_all_tree_data($order_asc))); + } } |