aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-03-07 12:42:06 +0100
committerJoas Schilling <nickvergessen@gmx.de>2014-03-07 14:07:45 +0100
commitecf1e94726a8a1e0f8d30aba3935e1899c2c6adc (patch)
tree9741193dbe144ed3635e18095fc110272acc3d42 /tests
parent51273f6fb1421b68c1931c3960f68cd483f1ee95 (diff)
downloadforums-ecf1e94726a8a1e0f8d30aba3935e1899c2c6adc.tar
forums-ecf1e94726a8a1e0f8d30aba3935e1899c2c6adc.tar.gz
forums-ecf1e94726a8a1e0f8d30aba3935e1899c2c6adc.tar.bz2
forums-ecf1e94726a8a1e0f8d30aba3935e1899c2c6adc.tar.xz
forums-ecf1e94726a8a1e0f8d30aba3935e1899c2c6adc.zip
[ticket/12090] Change redirect tests to use route()
PHPBB3-12090
Diffstat (limited to 'tests')
-rw-r--r--tests/controller/controller_test.php12
-rw-r--r--tests/functional/fixtures/ext/foo/bar/config/routing.yml12
-rw-r--r--tests/functional/fixtures/ext/foo/bar/controller/controller.php6
-rw-r--r--tests/security/redirect_test.php33
4 files changed, 23 insertions, 40 deletions
diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php
index b65e677dbe..8709f449db 100644
--- a/tests/controller/controller_test.php
+++ b/tests/controller/controller_test.php
@@ -21,10 +21,10 @@ 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/',
),
));
}
@@ -52,7 +52,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 +60,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/functional/fixtures/ext/foo/bar/config/routing.yml b/tests/functional/fixtures/ext/foo/bar/config/routing.yml
index 9b1ce3cfd7..d4d256c293 100644
--- a/tests/functional/fixtures/ext/foo/bar/config/routing.yml
+++ b/tests/functional/fixtures/ext/foo/bar/config/routing.yml
@@ -17,3 +17,15 @@ foo_exception_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 558b202948..7a52958ab6 100644
--- a/tests/functional/fixtures/ext/foo/bar/controller/controller.php
+++ b/tests/functional/fixtures/ext/foo/bar/controller/controller.php
@@ -63,15 +63,15 @@ class controller
'tests/index.php',
),
array(
- $this->helper->url('index'),
+ $this->helper->url('foo_index_controller'),
$rewrite_prefix . 'index',
),
array(
- $this->helper->url('tests/index'),
+ $this->helper->url('foo_tests_index_controller'),
$rewrite_prefix . 'tests/index',
),
array(
- $this->helper->url('tests/../index'),
+ $this->helper->url('foo_tests_dotdot_index_controller'),
$rewrite_prefix . 'index',
),
/*
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();
}
/**