aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/bootstrap.php6
-rw-r--r--tests/class_loader/class_loader_test.php4
-rw-r--r--tests/controller/helper_url_test.php2
-rw-r--r--tests/dbal/migrator_test.php3
-rw-r--r--tests/extension/ext/bar/styles/prosilver/template/foobar_body.html1
-rw-r--r--tests/extension/finder_test.php21
-rw-r--r--tests/extension/manager_test.php3
-rw-r--r--tests/extension/metadata_manager_test.php3
-rw-r--r--tests/extension/style_path_provider_test.php50
-rw-r--r--tests/extension/subdir/style_path_provider_test.php18
-rw-r--r--tests/filesystem/clean_path_test.php (renamed from tests/functions/clean_path_test.php)20
-rw-r--r--tests/mock/extension_manager.php3
-rw-r--r--tests/notification/submit_post_base.php6
-rw-r--r--tests/security/redirect_test.php6
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php3
15 files changed, 122 insertions, 27 deletions
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 1017e0c72f..a38740c82d 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -16,11 +16,11 @@ $table_prefix = 'phpbb_';
require_once $phpbb_root_path . 'includes/constants.php';
require_once $phpbb_root_path . 'includes/class_loader.' . $phpEx;
-$phpbb_class_loader_mock = new phpbb_class_loader('phpbb_mock_', $phpbb_root_path . '../tests/mock/', ".php");
+$phpbb_class_loader_mock = new phpbb_class_loader('phpbb_mock_', $phpbb_root_path . '../tests/mock/', "php");
$phpbb_class_loader_mock->register();
-$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".php");
+$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', "php");
$phpbb_class_loader_ext->register();
-$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".php");
+$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', "php");
$phpbb_class_loader->register();
require_once 'test_framework/phpbb_test_case_helpers.php';
diff --git a/tests/class_loader/class_loader_test.php b/tests/class_loader/class_loader_test.php
index 76af4dde37..bf27c7c217 100644
--- a/tests/class_loader/class_loader_test.php
+++ b/tests/class_loader/class_loader_test.php
@@ -71,8 +71,8 @@ class phpbb_class_loader_test extends PHPUnit_Framework_TestCase
$cache = new phpbb_mock_cache($cache_map);
$prefix = dirname(__FILE__) . '/';
- $class_loader = new phpbb_class_loader('phpbb_', $prefix . 'includes/', '.php', $cache);
- $class_loader_ext = new phpbb_class_loader('phpbb_ext_', $prefix . 'includes/', '.php', $cache);
+ $class_loader = new phpbb_class_loader('phpbb_', $prefix . 'includes/', 'php', $cache);
+ $class_loader_ext = new phpbb_class_loader('phpbb_ext_', $prefix . 'includes/', 'php', $cache);
$prefix .= 'includes/';
diff --git a/tests/controller/helper_url_test.php b/tests/controller/helper_url_test.php
index 195f48d8a9..2c22700ca6 100644
--- a/tests/controller/helper_url_test.php
+++ b/tests/controller/helper_url_test.php
@@ -52,7 +52,7 @@ class phpbb_controller_helper_url_test extends phpbb_test_case
$this->user = $this->getMock('phpbb_user');
$this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $this->user, $this->style_resource_locator, new phpbb_template_context());
- $helper = new phpbb_controller_helper($this->template, $this->user, '', '.php');
+ $helper = new phpbb_controller_helper($this->template, $this->user, '', 'php');
$this->assertEquals($helper->url($route, $params, $is_amp, $session_id), $expected);
}
}
diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php
index 0d7fc2f839..6390d6a715 100644
--- a/tests/dbal/migrator_test.php
+++ b/tests/dbal/migrator_test.php
@@ -60,9 +60,10 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
$this->db,
$this->config,
$this->migrator,
+ new phpbb_filesystem(),
'phpbb_ext',
dirname(__FILE__) . '/../../phpBB/',
- '.php',
+ 'php',
null
);
}
diff --git a/tests/extension/ext/bar/styles/prosilver/template/foobar_body.html b/tests/extension/ext/bar/styles/prosilver/template/foobar_body.html
new file mode 100644
index 0000000000..00c2a84a18
--- /dev/null
+++ b/tests/extension/ext/bar/styles/prosilver/template/foobar_body.html
@@ -0,0 +1 @@
+bertie rules!
diff --git a/tests/extension/finder_test.php b/tests/extension/finder_test.php
index c96b11a73c..dc3e26be02 100644
--- a/tests/extension/finder_test.php
+++ b/tests/extension/finder_test.php
@@ -6,6 +6,7 @@
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_extension_finder_test extends phpbb_test_case
{
@@ -66,7 +67,7 @@ class phpbb_extension_finder_test extends phpbb_test_case
public function test_prefix_get_directories()
{
$dirs = $this->finder
- ->prefix('t')
+ ->prefix('ty')
->get_directories();
sort($dirs);
@@ -142,13 +143,28 @@ class phpbb_extension_finder_test extends phpbb_test_case
);
}
+ public function test_uncleansub_directory_get_classes()
+ {
+ $classes = $this->finder
+ ->directory('/sub/../sub/type')
+ ->get_classes();
+
+ sort($classes);
+ $this->assertEquals(
+ array(
+ 'phpbb_ext_foo_sub_type_alternative',
+ ),
+ $classes
+ );
+ }
+
/**
* These do not work because of changes with PHPBB3-11386
* They do not seem neccessary to me, so I am commenting them out for now
public function test_get_classes_create_cache()
{
$cache = new phpbb_mock_cache;
- $finder = new phpbb_extension_finder($this->extension_manager, dirname(__FILE__) . '/', $cache, '.php', '_custom_cache_name');
+ $finder = new phpbb_extension_finder($this->extension_manager, new phpbb_filesystem(), dirname(__FILE__) . '/', $cache, 'php', '_custom_cache_name');
$files = $finder->suffix('_class.php')->get_files();
$expected_files = array(
@@ -188,6 +204,7 @@ class phpbb_extension_finder_test extends phpbb_test_case
$finder = new phpbb_extension_finder(
$this->extension_manager,
+ new phpbb_filesystem(),
dirname(__FILE__) . '/',
new phpbb_mock_cache(array(
'_ext_finder' => array(
diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php
index 1f311116f4..106f078691 100644
--- a/tests/extension/manager_test.php
+++ b/tests/extension/manager_test.php
@@ -112,9 +112,10 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
$db,
$config,
$migrator,
+ new phpbb_filesystem(),
'phpbb_ext',
dirname(__FILE__) . '/',
- '.' . $php_ext,
+ $php_ext,
($with_cache) ? new phpbb_mock_cache() : null
);
}
diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php
index 081a32e277..05d1cbccc3 100644
--- a/tests/extension/metadata_manager_test.php
+++ b/tests/extension/metadata_manager_test.php
@@ -36,7 +36,7 @@ class metadata_manager_test extends phpbb_database_test_case
$this->db = $this->new_dbal();
$this->db_tools = new phpbb_db_tools($this->db);
$this->phpbb_root_path = dirname(__FILE__) . '/';
- $this->phpEx = '.php';
+ $this->phpEx = 'php';
$this->user = new phpbb_user();
$this->table_prefix = 'phpbb_';
@@ -64,6 +64,7 @@ class metadata_manager_test extends phpbb_database_test_case
$this->db,
$this->config,
$this->migrator,
+ new phpbb_filesystem(),
'phpbb_ext',
$this->phpbb_root_path,
$this->phpEx,
diff --git a/tests/extension/style_path_provider_test.php b/tests/extension/style_path_provider_test.php
new file mode 100644
index 0000000000..e1021c20ac
--- /dev/null
+++ b/tests/extension/style_path_provider_test.php
@@ -0,0 +1,50 @@
+<?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_extension_style_path_provider_test extends phpbb_test_case
+{
+ protected $relative_root_path;
+ protected $root_path;
+
+ public function setUp()
+ {
+ $this->relative_root_path = './';
+ $this->root_path = dirname(__FILE__) . '/';
+ }
+
+ public function test_find()
+ {
+ $phpbb_style_path_provider = new phpbb_style_path_provider();
+ $phpbb_style_path_provider->set_styles(array($this->relative_root_path . 'styles/prosilver'));
+ $phpbb_style_extension_path_provider = new phpbb_style_extension_path_provider(new phpbb_mock_extension_manager(
+ $this->root_path,
+ array(
+ 'foo' => array(
+ 'ext_name' => 'foo',
+ 'ext_active' => '1',
+ 'ext_path' => 'ext/foo/',
+ ),
+ 'bar' => array(
+ 'ext_name' => 'bar',
+ 'ext_active' => '1',
+ 'ext_path' => 'ext/bar/',
+ ),
+ )), $phpbb_style_path_provider, $this->relative_root_path);
+
+ $this->assertEquals(array(
+ 'style' => array(
+ $this->relative_root_path . 'styles/prosilver',
+ ),
+ 'bar' => array(
+ $this->root_path . 'ext/bar/styles/prosilver',
+ ),
+ ), $phpbb_style_extension_path_provider->find());
+ }
+}
diff --git a/tests/extension/subdir/style_path_provider_test.php b/tests/extension/subdir/style_path_provider_test.php
new file mode 100644
index 0000000000..1b5ce62e5f
--- /dev/null
+++ b/tests/extension/subdir/style_path_provider_test.php
@@ -0,0 +1,18 @@
+<?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__) . '/../style_path_provider_test.php';
+
+class phpbb_extension_subdir_style_path_provider_test extends phpbb_extension_style_path_provider_test
+{
+ public function setUp()
+ {
+ $this->relative_root_path = '../';
+ $this->root_path = dirname(__FILE__) . '/../';
+ }
+}
diff --git a/tests/functions/clean_path_test.php b/tests/filesystem/clean_path_test.php
index bcbe9838d9..50951fc88c 100644
--- a/tests/functions/clean_path_test.php
+++ b/tests/filesystem/clean_path_test.php
@@ -7,11 +7,17 @@
*
*/
-require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
-
-class phpbb_clean_path_test extends phpbb_test_case
+class phpbb_filesystem_clean_path_test extends phpbb_test_case
{
- public function clean_path_test_data()
+ protected $filesystem;
+
+ public function setUp()
+ {
+ parent::setUp();
+ $this->filesystem = new phpbb_filesystem();
+ }
+
+ public function clean_path_data()
{
return array(
array('foo', 'foo'),
@@ -33,12 +39,10 @@ class phpbb_clean_path_test extends phpbb_test_case
}
/**
- * @dataProvider clean_path_test_data
+ * @dataProvider clean_path_data
*/
public function test_clean_path($input, $expected)
{
- $output = phpbb_clean_path($input);
-
- $this->assertEquals($expected, $output);
+ $this->assertEquals($expected, $this->filesystem->clean_path($input));
}
}
diff --git a/tests/mock/extension_manager.php b/tests/mock/extension_manager.php
index fdda4cbadc..10b3595206 100644
--- a/tests/mock/extension_manager.php
+++ b/tests/mock/extension_manager.php
@@ -12,7 +12,8 @@ class phpbb_mock_extension_manager extends phpbb_extension_manager
public function __construct($phpbb_root_path, $extensions = array())
{
$this->phpbb_root_path = $phpbb_root_path;
- $this->php_ext = '.php';
+ $this->php_ext = 'php';
$this->extensions = $extensions;
+ $this->filesystem = new phpbb_filesystem();
}
}
diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php
index c5b2450e1c..953bedac80 100644
--- a/tests/notification/submit_post_base.php
+++ b/tests/notification/submit_post_base.php
@@ -92,12 +92,12 @@ class phpbb_notification_submit_post_base extends phpbb_database_test_case
// Container
$phpbb_container = new phpbb_mock_container_builder();
- $user_loader = new phpbb_user_loader($db, $phpbb_root_path, '.' . $phpEx, USERS_TABLE);
+ $user_loader = new phpbb_user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
// Notification Manager
$phpbb_notifications = new phpbb_notification_manager(array(), array(),
$phpbb_container, $user_loader, $db, $user,
- $phpbb_root_path, '.' . $phpEx,
+ $phpbb_root_path, $phpEx,
NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE);
$phpbb_container->set('notification_manager', $phpbb_notifications);
@@ -108,7 +108,7 @@ class phpbb_notification_submit_post_base extends phpbb_database_test_case
$class_name = 'phpbb_notification_type_' . $type;
$phpbb_container->set('notification.type.' . $type, new $class_name(
$user_loader, $db, $cache, $user, $auth, $config,
- $phpbb_root_path, '.' . $phpEx,
+ $phpbb_root_path, $phpEx,
NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE));
}
}
diff --git a/tests/security/redirect_test.php b/tests/security/redirect_test.php
index 1325466137..8e36780ca4 100644
--- a/tests/security/redirect_test.php
+++ b/tests/security/redirect_test.php
@@ -18,11 +18,11 @@ class phpbb_security_redirect_test extends phpbb_security_test_base
// array(Input -> redirect(), expected triggered error (else false), expected returned result url (else false))
return array(
array('data://x', false, 'http://localhost/phpBB'),
- array('bad://localhost/phpBB/index.php', 'Tried to redirect to potentially insecure url.', false),
+ array('bad://localhost/phpBB/index.php', 'INSECURE_REDIRECT', false),
array('http://www.otherdomain.com/somescript.php', false, 'http://localhost/phpBB'),
- array("http://localhost/phpBB/memberlist.php\n\rConnection: close", 'Tried to redirect to potentially insecure url.', false),
+ array("http://localhost/phpBB/memberlist.php\n\rConnection: close", 'INSECURE_REDIRECT', false),
array('javascript:test', false, 'http://localhost/phpBB/../javascript:test'),
- array('http://localhost/phpBB/index.php;url=', 'Tried to redirect to potentially insecure url.', false),
+ array('http://localhost/phpBB/index.php;url=', 'INSECURE_REDIRECT', false),
);
}
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index 15c063ec02..5534de89c9 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -153,9 +153,10 @@ class phpbb_functional_test_case extends phpbb_test_case
$db,
$config,
$migrator,
+ new phpbb_filesystem(),
self::$config['table_prefix'] . 'ext',
dirname(__FILE__) . '/',
- '.' . $php_ext,
+ $php_ext,
$this->get_cache_driver()
);