diff options
author | Nathan Guse <nathaniel.guse@gmail.com> | 2013-09-30 18:24:46 -0500 |
---|---|---|
committer | Nathan Guse <nathaniel.guse@gmail.com> | 2013-09-30 18:24:46 -0500 |
commit | a6df011a107132390ecc35b80ab0e88bc31fd103 (patch) | |
tree | c91b2a90f4c3cef95c1f734aa0b6b0da4007e2ac /tests | |
parent | 2ee22d4615a86a33d3c65f94d7a9c4b99dfb1b7e (diff) | |
parent | 179f41475b555d0a3314d779d0d7423f66f0fb95 (diff) | |
download | forums-a6df011a107132390ecc35b80ab0e88bc31fd103.tar forums-a6df011a107132390ecc35b80ab0e88bc31fd103.tar.gz forums-a6df011a107132390ecc35b80ab0e88bc31fd103.tar.bz2 forums-a6df011a107132390ecc35b80ab0e88bc31fd103.tar.xz forums-a6df011a107132390ecc35b80ab0e88bc31fd103.zip |
Merge branch 'develop' of github.com:phpbb/phpbb3 into ticket/11850
# By Nils Adermann (68) and others
# Via Andreas Fischer (12) and others
* 'develop' of github.com:phpbb/phpbb3: (102 commits)
[ticket/11876] Replace MD5 with SHA256.
[ticket/11876] Move checksum generation from build PHP files to phing build.xml
[develop-olympus] Build against 3.0.12 instead of 3.0.12-RC3. Tag exists now.
[prep-release-3.0.12] Update changelog for 3.0.12 release.
[ticket/11873] Add unit test for large password input.
[ticket/11873] Do not hash very large passwords in order to safe resources.
[ticket/11862] Correct var names in user_delete() events due to prune-users
[develop-olympus] Use 3.0.13-dev as build version. Use latest 3.0.12 RC tag.
[prep-release-3.0.12] Bumping version number for 3.0.12 final.
[ticket/11852] Add class file
[ticket/11852] Move tests to folder with new class name
[ticket/11852] Split filesystem and path_helper into 2 classes
[ticket/11868] Add @depends to test
[ticket/11868] Add functional test for registration
[ticket/11868] Replace phpbb_request_interface references
[ticket/11866] Only single backslash in .md files
[ticket/11866] Remove outdated and broken develop script
[ticket/11866] More namespaces
[ticket/11866] Update some occurances of phpbb_db_ to new Namespace
[ticket/11865] Convert old class name to namespaced version
...
Conflicts:
tests/security/extract_current_page_test.php
tests/session/testable_facade.php
Diffstat (limited to 'tests')
159 files changed, 866 insertions, 637 deletions
diff --git a/tests/RUNNING_TESTS.md b/tests/RUNNING_TESTS.md index f2688ab675..0778046141 100644 --- a/tests/RUNNING_TESTS.md +++ b/tests/RUNNING_TESTS.md @@ -57,7 +57,7 @@ found below. More information on configuration options can be found on the wiki (see below). <?php - $dbms = 'phpbb_db_driver_mysqli'; + $dbms = 'phpbb\db\driver\mysqli'; $dbhost = 'localhost'; $dbport = ''; $dbname = 'database'; diff --git a/tests/acp_board/auth_provider/invalid.php b/tests/acp_board/auth_provider/invalid.php index c12851afe6..acce3b7e2d 100644 --- a/tests/acp_board/auth_provider/invalid.php +++ b/tests/acp_board/auth_provider/invalid.php @@ -7,7 +7,9 @@ * */ -class phpbb_auth_provider_acp_board_invalid +namespace phpbb\auth\provider\acp; + +class board_invalid { } diff --git a/tests/acp_board/auth_provider/valid.php b/tests/acp_board/auth_provider/valid.php index 42b14cb0af..13ec1e3250 100644 --- a/tests/acp_board/auth_provider/valid.php +++ b/tests/acp_board/auth_provider/valid.php @@ -7,7 +7,9 @@ * */ -class phpbb_auth_provider_acp_board_valid extends phpbb_auth_provider_base +namespace phpbb\auth\provider\acp; + +class board_valid extends \phpbb\auth\provider\base { public function login($username, $password) { diff --git a/tests/acp_board/select_auth_method_test.php b/tests/acp_board/select_auth_method_test.php index 91aa5d1232..b943554564 100644 --- a/tests/acp_board/select_auth_method_test.php +++ b/tests/acp_board/select_auth_method_test.php @@ -31,8 +31,8 @@ class phpbb_acp_board_select_auth_method_test extends phpbb_test_case $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('auth.provider_collection', array( - 'auth.provider.acp_board_valid' => new phpbb_auth_provider_acp_board_valid, - 'auth.provider.acp_board_invalid' => new phpbb_auth_provider_acp_board_invalid, + 'auth.provider.acp_board_valid' => new phpbb\auth\provider\acp\board_valid, + 'auth.provider.acp_board_invalid' => new phpbb\auth\provider\acp\board_invalid, )); $this->acp_board = new acp_board(); diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php index 0ca6ef763e..e135a1f002 100644 --- a/tests/auth/provider_apache_test.php +++ b/tests/auth/provider_apache_test.php @@ -22,11 +22,11 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case global $phpbb_root_path, $phpEx; $db = $this->new_dbal(); - $config = new phpbb_config(array()); - $this->request = $this->getMock('phpbb_request'); - $this->user = $this->getMock('phpbb_user'); + $config = new \phpbb\config\config(array()); + $this->request = $this->getMock('\phpbb\request\request'); + $this->user = $this->getMock('\phpbb\user'); - $this->provider = new phpbb_auth_provider_apache($db, $config, $this->request, $this->user, $phpbb_root_path, $phpEx); + $this->provider = new \phpbb\auth\provider\apache($db, $config, $this->request, $this->user, $phpbb_root_path, $phpEx); } public function getDataSet() @@ -43,7 +43,7 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case $this->request->expects($this->once()) ->method('is_set') ->with('PHP_AUTH_USER', - phpbb_request_interface::SERVER) + \phpbb\request\request_interface::SERVER) ->will($this->returnValue(true)); $this->request->expects($this->once()) ->method('server') @@ -61,7 +61,7 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case $this->request->expects($this->once()) ->method('is_set') ->with('PHP_AUTH_USER', - phpbb_request_interface::SERVER) + \phpbb\request\request_interface::SERVER) ->will($this->returnValue(true)); $this->request->expects($this->at(1)) ->method('server') @@ -93,7 +93,7 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case $this->request->expects($this->once()) ->method('is_set') ->with('PHP_AUTH_USER', - phpbb_request_interface::SERVER) + \phpbb\request\request_interface::SERVER) ->will($this->returnValue(true)); $this->request->expects($this->at(1)) ->method('server') @@ -194,7 +194,7 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case $this->request->expects($this->once()) ->method('is_set') ->with('PHP_AUTH_USER', - phpbb_request_interface::SERVER) + \phpbb\request\request_interface::SERVER) ->will($this->returnValue(true)); $this->request->expects($this->once()) ->method('server') diff --git a/tests/auth/provider_db_test.php b/tests/auth/provider_db_test.php index d876683f84..140a28cd3d 100644 --- a/tests/auth/provider_db_test.php +++ b/tests/auth/provider_db_test.php @@ -21,14 +21,14 @@ class phpbb_auth_provider_db_test extends phpbb_database_test_case global $phpbb_root_path, $phpEx; $db = $this->new_dbal(); - $config = new phpbb_config(array( + $config = new \phpbb\config\config(array( 'ip_login_limit_max' => 0, 'ip_login_limit_use_forwarded' => 0, 'max_login_attempts' => 0, )); - $request = $this->getMock('phpbb_request'); - $user = $this->getMock('phpbb_user'); - $provider = new phpbb_auth_provider_db($db, $config, $request, $user, $phpbb_root_path, $phpEx); + $request = $this->getMock('\phpbb\request\request'); + $user = $this->getMock('\phpbb\user'); + $provider = new \phpbb\auth\provider\db($db, $config, $request, $user, $phpbb_root_path, $phpEx); $expected = array( 'status' => LOGIN_SUCCESS, diff --git a/tests/auth/provider_oauth_token_storage_test.php b/tests/auth/provider_oauth_token_storage_test.php index 401f049405..fdc08833a3 100644 --- a/tests/auth/provider_oauth_token_storage_test.php +++ b/tests/auth/provider_oauth_token_storage_test.php @@ -25,7 +25,7 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c global $phpbb_root_path, $phpEx; $this->db = $this->new_dbal(); - $this->user = $this->getMock('phpbb_user'); + $this->user = $this->getMock('\phpbb\user'); $this->service_name = 'auth.provider.oauth.service.testing'; $this->token_storage_table = 'phpbb_oauth_tokens'; @@ -36,7 +36,7 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c // Set the user id to anonymous $this->user->data['user_id'] = ANONYMOUS; - $this->token_storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $this->token_storage_table); + $this->token_storage = new \phpbb\auth\provider\oauth\token_storage($this->db, $this->user, $this->token_storage_table); } public function getDataSet() @@ -74,7 +74,7 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c $expected_token = new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES); // Store a token in the database - $temp_storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $this->token_storage_table); + $temp_storage = new \phpbb\auth\provider\oauth\token_storage($this->db, $this->user, $this->token_storage_table); $temp_storage->storeAccessToken($this->service_name, $expected_token); unset($temp_storage); @@ -105,7 +105,7 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c $expected_token = new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES); // Store a token in the database - $temp_storage = new phpbb_auth_provider_oauth_token_storage($this->db, $this->user, $this->token_storage_table); + $temp_storage = new \phpbb\auth\provider\oauth\token_storage($this->db, $this->user, $this->token_storage_table); $temp_storage->storeAccessToken($this->service_name, $expected_token); unset($temp_storage); @@ -196,7 +196,7 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c protected function get_token_row_by_session_id($session_id) { // Test that the token is stored in the database - $sql = 'SELECT * FROM phpbb_oauth_tokens + $sql = 'SELECT * FROM phpbb_oauth_tokens WHERE session_id = \'' . $this->db->sql_escape($session_id) . '\''; $result = $this->db->sql_query($sql); $row = $this->db->sql_fetchrow($result); diff --git a/tests/avatar/driver/barfoo.php b/tests/avatar/driver/barfoo.php index 0b701a4d70..11c100db36 100644 --- a/tests/avatar/driver/barfoo.php +++ b/tests/avatar/driver/barfoo.php @@ -1,6 +1,8 @@ <?php
-class phpbb_avatar_driver_barfoo extends phpbb_avatar_driver
+namespace phpbb\avatar\driver;
+
+class barfoo extends \phpbb\avatar\driver\driver
{
public function get_data($row)
{
diff --git a/tests/avatar/driver/foobar.php b/tests/avatar/driver/foobar.php index 995f35818b..a1e7bdf7cc 100644 --- a/tests/avatar/driver/foobar.php +++ b/tests/avatar/driver/foobar.php @@ -1,6 +1,8 @@ <?php
-class phpbb_avatar_driver_foobar extends phpbb_avatar_driver
+namespace phpbb\avatar\driver;
+
+class foobar extends \phpbb\avatar\driver\driver
{
public function get_data($row)
{
diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 4ebe79c9cd..ba1fb04b33 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -22,17 +22,17 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase ->will($this->returnArgument(0)); // Prepare dependencies for avatar manager and driver - $config = new phpbb_config(array()); - $request = $this->getMock('phpbb_request'); - $cache = $this->getMock('phpbb_cache_driver_interface'); + $config = new \phpbb\config\config(array()); + $request = $this->getMock('\phpbb\request\request'); + $cache = $this->getMock('\phpbb\cache\driver\driver_interface'); // $this->avatar_foobar will be needed later on - $this->avatar_foobar = $this->getMock('phpbb_avatar_driver_foobar', array('get_name'), array($config, $phpbb_root_path, $phpEx, $cache)); + $this->avatar_foobar = $this->getMock('\phpbb\avatar\driver\foobar', array('get_name'), array($config, $phpbb_root_path, $phpEx, $cache)); $this->avatar_foobar->expects($this->any()) ->method('get_name') ->will($this->returnValue('avatar.driver.foobar')); // barfoo driver can't be mocked with constructor arguments - $this->avatar_barfoo = $this->getMock('phpbb_avatar_driver_barfoo', array('get_name')); + $this->avatar_barfoo = $this->getMock('\phpbb\avatar\driver\barfoo', array('get_name')); $this->avatar_barfoo->expects($this->any()) ->method('get_name') ->will($this->returnValue('avatar.driver.barfoo')); @@ -40,7 +40,7 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase foreach ($this->avatar_drivers() as $driver) { - $cur_avatar = $this->getMock('phpbb_avatar_driver_' . $driver, array('get_name'), array($config, $phpbb_root_path, $phpEx, $cache)); + $cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($config, $phpbb_root_path, $phpEx, $cache)); $cur_avatar->expects($this->any()) ->method('get_name') ->will($this->returnValue('avatar.driver.' . $driver)); @@ -52,7 +52,7 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase $config['allow_avatar_' . get_class($this->avatar_barfoo)] = false; // Set up avatar manager - $this->manager = new phpbb_avatar_manager($config, $avatar_drivers, $this->phpbb_container); + $this->manager = new \phpbb\avatar\manager($config, $avatar_drivers, $this->phpbb_container); } protected function avatar_drivers() @@ -203,7 +203,7 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase { $cleaned_row = array(); - $cleaned_row = phpbb_avatar_manager::clean_row($input); + $cleaned_row = \phpbb\avatar\manager::clean_row($input); foreach ($output as $key => $null) { $this->assertArrayHasKey($key, $cleaned_row); @@ -222,7 +222,7 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase public function test_localize_errors() { - $user = $this->getMock('phpbb_user'); + $user = $this->getMock('\phpbb\user'); $lang_array = array( array('FOOBAR_OFF', 'foobar_off'), array('FOOBAR_EXPLAIN', 'FOOBAR_EXPLAIN %s'), diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 68cbb64c03..afb586435c 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 . 'phpbb/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_root_path . 'ext/', "php"); $phpbb_class_loader_ext->register(); -$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'phpbb/', "php"); +$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', $phpbb_root_path . 'phpbb/', "php"); $phpbb_class_loader->register(); require_once 'test_framework/phpbb_test_case_helpers.php'; diff --git a/tests/cache/apc_driver_test.php b/tests/cache/apc_driver_test.php index 3380762878..51f3ac24b6 100644 --- a/tests/cache/apc_driver_test.php +++ b/tests/cache/apc_driver_test.php @@ -30,7 +30,7 @@ class phpbb_cache_apc_driver_test extends phpbb_cache_common_test_case self::markTestSkipped('APC extension is not loaded'); } - $php_ini = new phpbb_php_ini; + $php_ini = new \phpbb\php\ini; if (!$php_ini->get_bool('apc.enabled')) { @@ -47,7 +47,7 @@ class phpbb_cache_apc_driver_test extends phpbb_cache_common_test_case { parent::setUp(); - $this->driver = new phpbb_cache_driver_apc; + $this->driver = new \phpbb\cache\driver\apc; $this->driver->purge(); } } diff --git a/tests/cache/common_test_case.php b/tests/cache/common_test_case.php index a5bc2bfda9..3fe10c63e1 100644 --- a/tests/cache/common_test_case.php +++ b/tests/cache/common_test_case.php @@ -65,9 +65,9 @@ abstract class phpbb_cache_common_test_case extends phpbb_database_test_case public function test_cache_sql() { global $db, $cache, $phpbb_root_path, $phpEx; - $config = new phpbb_config(array()); + $config = new phpbb\config\config(array()); $db = $this->new_dbal(); - $cache = new phpbb_cache_service($this->driver, $config, $db, $phpbb_root_path, $phpEx); + $cache = new \phpbb\cache\service($this->driver, $config, $db, $phpbb_root_path, $phpEx); $sql = "SELECT * FROM phpbb_config WHERE config_name = 'foo'"; diff --git a/tests/cache/file_driver_test.php b/tests/cache/file_driver_test.php index 745c6bb081..c0843e8ed9 100644 --- a/tests/cache/file_driver_test.php +++ b/tests/cache/file_driver_test.php @@ -36,7 +36,7 @@ class phpbb_cache_file_driver_test extends phpbb_cache_common_test_case } $this->create_cache_dir(); - $this->driver = new phpbb_cache_driver_file($this->cache_dir); + $this->driver = new \phpbb\cache\driver\file($this->cache_dir); } protected function tearDown() diff --git a/tests/cache/null_driver_test.php b/tests/cache/null_driver_test.php index 43a0cc806c..58e57f2b3a 100644 --- a/tests/cache/null_driver_test.php +++ b/tests/cache/null_driver_test.php @@ -20,7 +20,7 @@ class phpbb_cache_null_driver_test extends phpbb_database_test_case { parent::setUp(); - $this->driver = new phpbb_cache_driver_null; + $this->driver = new \phpbb\cache\driver\null; } public function test_get_put() @@ -48,9 +48,9 @@ class phpbb_cache_null_driver_test extends phpbb_database_test_case public function test_cache_sql() { global $db, $cache, $phpbb_root_path, $phpEx; - $config = new phpbb_config(array()); + $config = new phpbb\config\config(array()); $db = $this->new_dbal(); - $cache = new phpbb_cache_service($this->driver, $config, $db, $phpbb_root_path, $phpEx); + $cache = new \phpbb\cache\service($this->driver, $config, $db, $phpbb_root_path, $phpEx); $sql = "SELECT * FROM phpbb_config WHERE config_name = 'foo'"; diff --git a/tests/cache/redis_driver_test.php b/tests/cache/redis_driver_test.php index 1308519a18..3d954dc0db 100644 --- a/tests/cache/redis_driver_test.php +++ b/tests/cache/redis_driver_test.php @@ -43,7 +43,7 @@ class phpbb_cache_redis_driver_test extends phpbb_cache_common_test_case { parent::setUp(); - $this->driver = new phpbb_cache_driver_redis(self::$config['host'], self::$config['port']); + $this->driver = new \phpbb\cache\driver\redis(self::$config['host'], self::$config['port']); $this->driver->purge(); } } diff --git a/tests/class_loader/class_loader_test.php b/tests/class_loader/class_loader_test.php index 2b55c1ff8d..6e551f658a 100644 --- a/tests/class_loader/class_loader_test.php +++ b/tests/class_loader/class_loader_test.php @@ -30,74 +30,68 @@ class phpbb_class_loader_test extends PHPUnit_Framework_TestCase public function test_resolve_path() { $prefix = dirname(__FILE__) . '/'; - $class_loader = new phpbb_class_loader('phpbb_', $prefix . 'phpbb/'); + $class_loader = new \phpbb\class_loader('phpbb\\', $prefix . 'phpbb/'); $prefix .= 'phpbb/'; $this->assertEquals( - '', - $class_loader->resolve_path('phpbb_dir'), - 'Class with same name as a directory is unloadable' - ); - - $this->assertEquals( $prefix . 'class_name.php', - $class_loader->resolve_path('phpbb_class_name'), + $class_loader->resolve_path('\\phpbb\\class_name'), 'Top level class' ); $this->assertEquals( $prefix . 'dir/class_name.php', - $class_loader->resolve_path('phpbb_dir_class_name'), + $class_loader->resolve_path('\\phpbb\\dir\\class_name'), 'Class in a directory' ); $this->assertEquals( $prefix . 'dir/subdir/class_name.php', - $class_loader->resolve_path('phpbb_dir_subdir_class_name'), + $class_loader->resolve_path('\\phpbb\\dir\\subdir\\class_name'), 'Class in a sub-directory' ); $this->assertEquals( $prefix . 'dir2/dir2.php', - $class_loader->resolve_path('phpbb_dir2'), - 'Class with name of dir within dir (short class name)' + $class_loader->resolve_path('\\phpbb\\dir2\\dir2'), + 'Class with name of dir within dir' ); } public function test_resolve_cached() { $cache_map = array( - 'class_loader_phpbb_' => array('phpbb_a_cached_name' => 'a/cached_name'), - 'class_loader_phpbb_ext_' => array('phpbb_ext_foo' => 'foo'), + 'class_loader___phpbb__' => array('\\phpbb\\a\\cached_name' => 'a/cached_name'), + 'class_loader___' => array('\\phpbb\\ext\\foo' => 'foo'), ); $cache = new phpbb_mock_cache($cache_map); $prefix = dirname(__FILE__) . '/'; - $class_loader = new phpbb_class_loader('phpbb_', $prefix . 'phpbb/', 'php', $cache); - $class_loader_ext = new phpbb_class_loader('phpbb_ext_', $prefix . 'phpbb/', 'php', $cache); + $class_loader = new \phpbb\class_loader('phpbb\\', $prefix . 'phpbb/', 'php', $cache); + $class_loader_ext = new \phpbb\class_loader('\\', $prefix . 'phpbb/', 'php', $cache); $prefix .= 'phpbb/'; $this->assertEquals( $prefix . 'dir/class_name.php', - $class_loader->resolve_path('phpbb_dir_class_name'), + $class_loader->resolve_path('\\phpbb\\dir\\class_name'), 'Class in a directory' ); - $this->assertFalse($class_loader->resolve_path('phpbb_ext_foo')); - $this->assertFalse($class_loader_ext->resolve_path('phpbb_a_cached_name')); + $this->assertFalse($class_loader->resolve_path('\\phpbb\\ext\\foo')); + $this->assertFalse($class_loader_ext->resolve_path('\\phpbb\\a\\cached_name')); $this->assertEquals( $prefix . 'a/cached_name.php', - $class_loader->resolve_path('phpbb_a_cached_name'), + $class_loader->resolve_path('\\phpbb\\a\\cached_name'), 'Cached class found' ); $this->assertEquals( $prefix . 'foo.php', - $class_loader_ext->resolve_path('phpbb_ext_foo'), + $class_loader_ext->resolve_path('\\phpbb\\ext\\foo'), 'Cached class found in alternative loader' ); - $cache_map['class_loader_phpbb_']['phpbb_dir_class_name'] = 'dir/class_name'; + $cache_map['class_loader___phpbb__']['\\phpbb\\dir\\class_name'] = 'dir/class_name'; $cache->check($this, $cache_map); } } diff --git a/tests/class_loader/phpbb/class_name.php b/tests/class_loader/phpbb/class_name.php index e941173cdd..64a3fa646e 100644 --- a/tests/class_loader/phpbb/class_name.php +++ b/tests/class_loader/phpbb/class_name.php @@ -1,6 +1,8 @@ <?php -class phpbb_class_name +namespace phpbb; + +class class_name { } diff --git a/tests/class_loader/phpbb/dir.php b/tests/class_loader/phpbb/dir.php deleted file mode 100644 index 1c8930d8e7..0000000000 --- a/tests/class_loader/phpbb/dir.php +++ /dev/null @@ -1,6 +0,0 @@ -<?php - -class phpbb_dir -{ -} - diff --git a/tests/class_loader/phpbb/dir/class_name.php b/tests/class_loader/phpbb/dir/class_name.php index 0675aa8fc5..1cd39a1181 100644 --- a/tests/class_loader/phpbb/dir/class_name.php +++ b/tests/class_loader/phpbb/dir/class_name.php @@ -1,6 +1,8 @@ <?php -class phpbb_dir_class_name +namespace phpbb\dir; + +class class_name { } diff --git a/tests/class_loader/phpbb/dir/subdir/class_name.php b/tests/class_loader/phpbb/dir/subdir/class_name.php index 7321a609cc..89affbc847 100644 --- a/tests/class_loader/phpbb/dir/subdir/class_name.php +++ b/tests/class_loader/phpbb/dir/subdir/class_name.php @@ -1,6 +1,8 @@ <?php -class phpbb_dir_subdir_class_name +namespace phpbb\dir\subdir; + +class class_name { } diff --git a/tests/class_loader/phpbb/dir2/dir2.php b/tests/class_loader/phpbb/dir2/dir2.php index 01cf4086ff..b273511fcd 100644 --- a/tests/class_loader/phpbb/dir2/dir2.php +++ b/tests/class_loader/phpbb/dir2/dir2.php @@ -1,6 +1,8 @@ <?php -class phpbb_dir2 +namespace phpbb; + +class dir2 { } diff --git a/tests/config/config_test.php b/tests/config/config_test.php index 5845cc4590..5373fcef5f 100644 --- a/tests/config/config_test.php +++ b/tests/config/config_test.php @@ -11,7 +11,7 @@ class phpbb_config_test extends phpbb_test_case { public function test_offset_exists() { - $config = new phpbb_config(array('foo' => 'bar')); + $config = new \phpbb\config\config(array('foo' => 'bar')); $this->assertTrue(isset($config['foo'])); $this->assertFalse(isset($config['foobar'])); @@ -19,19 +19,19 @@ class phpbb_config_test extends phpbb_test_case public function test_offset_get() { - $config = new phpbb_config(array('foo' => 'bar')); + $config = new \phpbb\config\config(array('foo' => 'bar')); $this->assertEquals('bar', $config['foo']); } public function test_offset_get_missing() { - $config = new phpbb_config(array()); + $config = new \phpbb\config\config(array()); $this->assertEquals('', $config['foo']); } public function test_offset_set() { - $config = new phpbb_config(array()); + $config = new \phpbb\config\config(array()); $config['foo'] = 'x'; $this->assertEquals('x', $config['foo']); } @@ -39,20 +39,20 @@ class phpbb_config_test extends phpbb_test_case public function test_offset_unset_fails() { $this->setExpectedTriggerError(E_USER_ERROR); - $config = new phpbb_config(array('foo' => 'x')); + $config = new \phpbb\config\config(array('foo' => 'x')); unset($config['foo']); } public function test_count() { - $config = new phpbb_config(array('foo' => 'bar')); + $config = new \phpbb\config\config(array('foo' => 'bar')); $this->assertEquals(1, count($config)); } public function test_iterate() { $vars = array('foo' => '23', 'bar' => '42'); - $config = new phpbb_config($vars); + $config = new \phpbb\config\config($vars); $count = 0; foreach ($config as $key => $value) @@ -68,42 +68,42 @@ class phpbb_config_test extends phpbb_test_case public function test_set_overwrite() { - $config = new phpbb_config(array('foo' => 'x')); + $config = new \phpbb\config\config(array('foo' => 'x')); $config->set('foo', 'bar'); $this->assertEquals('bar', $config['foo']); } public function test_set_new() { - $config = new phpbb_config(array()); + $config = new \phpbb\config\config(array()); $config->set('foo', 'bar'); $this->assertEquals('bar', $config['foo']); } public function test_set_atomic_overwrite() { - $config = new phpbb_config(array('foo' => 'bar')); + $config = new \phpbb\config\config(array('foo' => 'bar')); $this->assertTrue($config->set_atomic('foo', 'bar', '23')); $this->assertEquals('23', $config['foo']); } public function test_set_atomic_new() { - $config = new phpbb_config(array()); + $config = new \phpbb\config\config(array()); $this->assertTrue($config->set_atomic('foo', false, '23')); $this->assertEquals('23', $config['foo']); } public function test_set_atomic_failure() { - $config = new phpbb_config(array('foo' => 'bar')); + $config = new \phpbb\config\config(array('foo' => 'bar')); $this->assertFalse($config->set_atomic('foo', 'wrong', '23')); $this->assertEquals('bar', $config['foo']); } public function test_increment() { - $config = new phpbb_config(array('foo' => '23')); + $config = new \phpbb\config\config(array('foo' => '23')); $config->increment('foo', 3); $this->assertEquals(26, $config['foo']); $config->increment('foo', 1); @@ -112,7 +112,7 @@ class phpbb_config_test extends phpbb_test_case public function test_delete() { - $config = new phpbb_config(array('foo' => 'bar')); + $config = new \phpbb\config\config(array('foo' => 'bar')); $config->delete('foo'); $this->assertFalse(isset($config['foo'])); diff --git a/tests/config/db_test.php b/tests/config/db_test.php index 0b8f73d53a..dd1c88f707 100644 --- a/tests/config/db_test.php +++ b/tests/config/db_test.php @@ -24,7 +24,7 @@ class phpbb_config_db_test extends phpbb_database_test_case $this->cache = new phpbb_mock_cache; $this->db = $this->new_dbal(); - $this->config = new phpbb_config_db($this->db, $this->cache, 'phpbb_config'); + $this->config = new \phpbb\config\db($this->db, $this->cache, 'phpbb_config'); } public function test_load_config() @@ -36,7 +36,7 @@ class phpbb_config_db_test extends phpbb_database_test_case public function test_load_cached() { $cache = new phpbb_mock_cache(array('config' => array('x' => 'y'))); - $this->config = new phpbb_config_db($this->db, $cache, 'phpbb_config'); + $this->config = new \phpbb\config\db($this->db, $cache, 'phpbb_config'); $this->assertTrue(!isset($this->config['foo'])); $this->assertEquals('42', $this->config['bar']); @@ -49,7 +49,7 @@ class phpbb_config_db_test extends phpbb_database_test_case $this->config['foo'] = 'x'; // temporary set $this->assertEquals('x', $this->config['foo']); - $config2 = new phpbb_config_db($this->db, $this->cache, 'phpbb_config'); + $config2 = new \phpbb\config\db($this->db, $this->cache, 'phpbb_config'); $this->assertEquals('23', $config2['foo']); } @@ -59,7 +59,7 @@ class phpbb_config_db_test extends phpbb_database_test_case $this->assertEquals('17', $this->config['foo']); // re-read config and populate cache - $config2 = new phpbb_config_db($this->db, $this->cache, 'phpbb_config'); + $config2 = new \phpbb\config\db($this->db, $this->cache, 'phpbb_config'); $this->cache->checkVar($this, 'config', array('foo' => '17')); } @@ -68,7 +68,7 @@ class phpbb_config_db_test extends phpbb_database_test_case $this->config->set('bar', '17', false); // re-read config and populate cache - $config2 = new phpbb_config_db($this->db, $this->cache, 'phpbb_config'); + $config2 = new \phpbb\config\db($this->db, $this->cache, 'phpbb_config'); $this->cache->checkVar($this, 'config', array('foo' => '23')); } @@ -78,7 +78,7 @@ class phpbb_config_db_test extends phpbb_database_test_case $this->assertEquals('5', $this->config['foobar']); // re-read config and populate cache - $config2 = new phpbb_config_db($this->db, $this->cache, 'phpbb_config'); + $config2 = new \phpbb\config\db($this->db, $this->cache, 'phpbb_config'); $this->cache->checkVar($this, 'config', array('foo' => '23', 'foobar' => '5')); } @@ -88,7 +88,7 @@ class phpbb_config_db_test extends phpbb_database_test_case $this->assertEquals('5', $this->config['foobar']); // re-read config and populate cache - $config2 = new phpbb_config_db($this->db, $this->cache, 'phpbb_config'); + $config2 = new \phpbb\config\db($this->db, $this->cache, 'phpbb_config'); $this->cache->checkVar($this, 'config', array('foo' => '23')); } @@ -133,7 +133,7 @@ class phpbb_config_db_test extends phpbb_database_test_case // re-read config and populate cache $cache2 = new phpbb_mock_cache; - $config2 = new phpbb_config_db($this->db, $cache2, 'phpbb_config'); + $config2 = new \phpbb\config\db($this->db, $cache2, 'phpbb_config'); $cache2->checkVarUnset($this, 'foo'); $this->assertFalse(isset($config2['foo'])); } @@ -145,7 +145,7 @@ class phpbb_config_db_test extends phpbb_database_test_case $this->config->delete('bar'); $this->cache->checkVarUnset($this, 'bar'); $this->assertFalse(isset($this->config['bar'])); - + $this->config->set('bar', 'new bar', false); $this->assertEquals('new bar', $this->config['bar']); } @@ -157,7 +157,7 @@ class phpbb_config_db_test extends phpbb_database_test_case $this->config->delete('foo'); $this->cache->checkVarUnset($this, 'foo'); $this->assertFalse(isset($this->config['foo'])); - + $this->config->set('foo', 'new foo', true); $this->assertEquals('new foo', $this->config['foo']); } diff --git a/tests/config/db_text_test.php b/tests/config/db_text_test.php index 4818bba8c9..354c0efacf 100644 --- a/tests/config/db_text_test.php +++ b/tests/config/db_text_test.php @@ -22,7 +22,7 @@ class phpbb_config_db_text_test extends phpbb_database_test_case parent::setUp(); $this->db = $this->new_dbal(); - $this->config_text = new phpbb_config_db_text($this->db, 'phpbb_config_text'); + $this->config_text = new \phpbb\config\db_text($this->db, 'phpbb_config_text'); } public function test_get() diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index 6234aac9ad..b2bdcb3b49 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -267,21 +267,21 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $config['search_type'] = 'phpbb_mock_search'; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - set_config_count(null, null, null, new phpbb_config(array('num_posts' => 3, 'num_topics' => 1))); + set_config_count(null, null, null, new \phpbb\config\config(array('num_posts' => 3, 'num_topics' => 1))); // Create auth mock - $auth = $this->getMock('phpbb_auth'); + $auth = $this->getMock('\phpbb\auth\auth'); $auth->expects($this->any()) ->method('acl_get') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap(array( array('m_approve', 1, true), ))); - $user = $this->getMock('phpbb_user'); + $user = $this->getMock('\phpbb\user'); $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); - $phpbb_container->set('content.visibility', new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); + $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason); diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php index aa44fa4013..22f210c406 100644 --- a/tests/content_visibility/get_forums_visibility_sql_test.php +++ b/tests/content_visibility/get_forums_visibility_sql_test.php @@ -125,13 +125,13 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data $db = $this->new_dbal(); // Create auth mock - $auth = $this->getMock('phpbb_auth'); + $auth = $this->getMock('\phpbb\auth\auth'); $auth->expects($this->any()) ->method('acl_getf') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); - $user = $this->getMock('phpbb_user'); - $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $user = $this->getMock('\phpbb\user'); + $content_visibility = new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id FROM ' . $table . ' diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php index 0f019ffa50..9488a8c0b3 100644 --- a/tests/content_visibility/get_global_visibility_sql_test.php +++ b/tests/content_visibility/get_global_visibility_sql_test.php @@ -125,13 +125,13 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data $db = $this->new_dbal(); // Create auth mock - $auth = $this->getMock('phpbb_auth'); + $auth = $this->getMock('\phpbb\auth\auth'); $auth->expects($this->any()) ->method('acl_getf') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); - $user = $this->getMock('phpbb_user'); - $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $user = $this->getMock('\phpbb\user'); + $content_visibility = new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id FROM ' . $table . ' diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php index cc6c10c649..111e735650 100644 --- a/tests/content_visibility/get_visibility_sql_test.php +++ b/tests/content_visibility/get_visibility_sql_test.php @@ -72,13 +72,13 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te $db = $this->new_dbal(); // Create auth mock - $auth = $this->getMock('phpbb_auth'); + $auth = $this->getMock('\phpbb\auth\auth'); $auth->expects($this->any()) ->method('acl_get') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); - $user = $this->getMock('phpbb_user'); - $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $user = $this->getMock('\phpbb\user'); + $content_visibility = new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id FROM ' . $table . ' diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index 81abf56c75..f81b83ff86 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -119,9 +119,9 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $auth = $this->getMock('phpbb_auth'); - $user = $this->getMock('phpbb_user'); - $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $auth = $this->getMock('\phpbb\auth\auth'); + $user = $this->getMock('\phpbb\user'); + $content_visibility = new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $content_visibility->set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest); diff --git a/tests/content_visibility/set_topic_visibility_test.php b/tests/content_visibility/set_topic_visibility_test.php index 6b5d884a2b..92b1253a15 100644 --- a/tests/content_visibility/set_topic_visibility_test.php +++ b/tests/content_visibility/set_topic_visibility_test.php @@ -83,9 +83,9 @@ class phpbb_content_visibility_set_topic_visibility_test extends phpbb_database_ $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $auth = $this->getMock('phpbb_auth'); - $user = $this->getMock('phpbb_user'); - $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $auth = $this->getMock('\phpbb\auth\auth'); + $user = $this->getMock('\phpbb\user'); + $content_visibility = new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $content_visibility->set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all); diff --git a/tests/controller/config/services.yml b/tests/controller/config/services.yml index f1bd047489..e4412af3d7 100644 --- a/tests/controller/config/services.yml +++ b/tests/controller/config/services.yml @@ -1,3 +1,3 @@ services: core_foo.controller: - class: phpbb_controller_foo + class: phpbb\controller\foo diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index dfc4f80469..10fced05a2 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -31,7 +31,7 @@ class phpbb_controller_controller_test extends phpbb_test_case public function test_provider() { - $provider = new phpbb_controller_provider; + $provider = new \phpbb\controller\provider; $routes = $provider ->import_paths_from_finder($this->extension_manager->get_finder()) ->find('./tests/controller/'); @@ -53,24 +53,24 @@ 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('phpbb_ext_foo_controller')) + if (!class_exists('foo\\controller')) { include(__DIR__.'/ext/foo/controller.php'); } - if (!class_exists('phpbb_controller_foo')) + if (!class_exists('phpbb\\controller\\foo')) { include(__DIR__.'/phpbb/controller/foo.php'); } - $resolver = new phpbb_controller_resolver(new phpbb_user, $container); + $resolver = new \phpbb\controller\resolver(new \phpbb\user, $container); $symfony_request = new Request(); $symfony_request->attributes->set('_controller', 'foo.controller:handle'); - $this->assertEquals($resolver->getController($symfony_request), array(new phpbb_ext_foo_controller, 'handle')); + $this->assertEquals($resolver->getController($symfony_request), array(new foo\controller, 'handle')); $symfony_request = new Request(); $symfony_request->attributes->set('_controller', 'core_foo.controller:bar'); - $this->assertEquals($resolver->getController($symfony_request), array(new phpbb_controller_foo, 'bar')); + $this->assertEquals($resolver->getController($symfony_request), array(new phpbb\controller\foo, 'bar')); } } diff --git a/tests/controller/ext/foo/config/services.yml b/tests/controller/ext/foo/config/services.yml index ce0e18c610..9ed67d5bc2 100644 --- a/tests/controller/ext/foo/config/services.yml +++ b/tests/controller/ext/foo/config/services.yml @@ -1,3 +1,3 @@ services: foo.controller: - class: phpbb_ext_foo_controller + class: foo\controller diff --git a/tests/controller/ext/foo/controller.php b/tests/controller/ext/foo/controller.php index cfc5c20622..ce2233b3c9 100644 --- a/tests/controller/ext/foo/controller.php +++ b/tests/controller/ext/foo/controller.php @@ -1,8 +1,10 @@ <?php +namespace foo; + use Symfony\Component\HttpFoundation\Response; -class phpbb_ext_foo_controller +class controller { /** * Handle method diff --git a/tests/controller/helper_url_test.php b/tests/controller/helper_url_test.php index 2dd7269caa..33fc6c4f1b 100644 --- a/tests/controller/helper_url_test.php +++ b/tests/controller/helper_url_test.php @@ -48,19 +48,20 @@ class phpbb_controller_helper_url_test extends phpbb_test_case global $phpbb_dispatcher, $phpbb_root_path, $phpEx; $phpbb_dispatcher = new phpbb_mock_event_dispatcher; - $this->user = $this->getMock('phpbb_user'); - $phpbb_filesystem = new phpbb_filesystem( - new phpbb_symfony_request( + $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($phpbb_filesystem, $config, $this->user, new phpbb_template_context()); + $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(array('enable_mod_rewrite' => '0')); - $helper = new phpbb_controller_helper($this->template, $this->user, $config, '', 'php'); + $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); } @@ -100,18 +101,19 @@ class phpbb_controller_helper_url_test extends phpbb_test_case global $phpbb_dispatcher, $phpbb_root_path, $phpEx; $phpbb_dispatcher = new phpbb_mock_event_dispatcher; - $this->user = $this->getMock('phpbb_user'); - $phpbb_filesystem = new phpbb_filesystem( - new phpbb_symfony_request( + $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($phpbb_filesystem, $config, $this->user, new phpbb_template_context()); + $this->template = new \phpbb\template\twig\twig($phpbb_path_helper, $config, $this->user, new \phpbb\template\context()); - $config = new phpbb_config(array('enable_mod_rewrite' => '1')); - $helper = new phpbb_controller_helper($this->template, $this->user, $config, '', 'php'); + $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/controller/phpbb/controller/foo.php b/tests/controller/phpbb/controller/foo.php index 04576e16c4..98669f428f 100644 --- a/tests/controller/phpbb/controller/foo.php +++ b/tests/controller/phpbb/controller/foo.php @@ -1,8 +1,10 @@ <?php +namespace phpbb\controller; + use Symfony\Component\HttpFoundation\Response; -class phpbb_controller_foo +class foo { /** * Bar method diff --git a/tests/cron/ext/testext/cron/dummy_task.php b/tests/cron/ext/testext/cron/dummy_task.php index 3e81db1895..8cdb6b09d5 100644 --- a/tests/cron/ext/testext/cron/dummy_task.php +++ b/tests/cron/ext/testext/cron/dummy_task.php @@ -7,7 +7,7 @@ * */ -class phpbb_ext_testext_cron_dummy_task extends phpbb_cron_task_base +class phpbb_ext_testext_cron_dummy_task extends \phpbb\cron\task\base { static public $was_run = 0; diff --git a/tests/cron/includes/cron/task/core/dummy_task.php b/tests/cron/includes/cron/task/core/dummy_task.php index c94455603f..c34684701b 100644 --- a/tests/cron/includes/cron/task/core/dummy_task.php +++ b/tests/cron/includes/cron/task/core/dummy_task.php @@ -7,7 +7,7 @@ * */ -class phpbb_cron_task_core_dummy_task extends phpbb_cron_task_base +class phpbb_cron_task_core_dummy_task extends \phpbb\cron\task\base { static public $was_run = 0; diff --git a/tests/cron/includes/cron/task/core/second_dummy_task.php b/tests/cron/includes/cron/task/core/second_dummy_task.php index 77ef6f70ed..1b212ab05d 100644 --- a/tests/cron/includes/cron/task/core/second_dummy_task.php +++ b/tests/cron/includes/cron/task/core/second_dummy_task.php @@ -7,7 +7,7 @@ * */ -class phpbb_cron_task_core_second_dummy_task extends phpbb_cron_task_base +class phpbb_cron_task_core_second_dummy_task extends \phpbb\cron\task\base { static public $was_run = 0; diff --git a/tests/cron/manager_test.php b/tests/cron/manager_test.php index 3c541be2a6..713f44c1e2 100644 --- a/tests/cron/manager_test.php +++ b/tests/cron/manager_test.php @@ -29,7 +29,7 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase public function test_manager_finds_shipped_task_by_name() { $task = $this->manager->find_task($this->task_name); - $this->assertInstanceOf('phpbb_cron_task_wrapper', $task); + $this->assertInstanceOf('\phpbb\cron\task\wrapper', $task); $this->assertEquals($this->task_name, $task->get_name()); } @@ -42,7 +42,7 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase public function test_manager_finds_one_ready_task() { $task = $this->manager->find_one_ready_task(); - $this->assertInstanceOf('phpbb_cron_task_wrapper', $task); + $this->assertInstanceOf('\phpbb\cron\task\wrapper', $task); } public function test_manager_finds_only_ready_tasks() @@ -71,6 +71,6 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase { global $phpbb_root_path, $phpEx; - return new phpbb_cron_manager($tasks, $phpbb_root_path, $phpEx); + return new \phpbb\cron\manager($tasks, $phpbb_root_path, $phpEx); } } diff --git a/tests/cron/tasks/simple_not_runnable.php b/tests/cron/tasks/simple_not_runnable.php index 56d484eacd..4951b5b4b9 100644 --- a/tests/cron/tasks/simple_not_runnable.php +++ b/tests/cron/tasks/simple_not_runnable.php @@ -1,6 +1,6 @@ <?php -class phpbb_cron_task_core_simple_not_runnable extends phpbb_cron_task_base +class phpbb_cron_task_core_simple_not_runnable extends \phpbb\cron\task\base { public function get_name() { diff --git a/tests/cron/tasks/simple_ready.php b/tests/cron/tasks/simple_ready.php index 8aa0507406..245d9ba738 100644 --- a/tests/cron/tasks/simple_ready.php +++ b/tests/cron/tasks/simple_ready.php @@ -1,6 +1,6 @@ <?php -class phpbb_cron_task_core_simple_ready extends phpbb_cron_task_base +class phpbb_cron_task_core_simple_ready extends \phpbb\cron\task\base { public function get_name() { diff --git a/tests/cron/tasks/simple_should_not_run.php b/tests/cron/tasks/simple_should_not_run.php index 58f6df2616..7bd9df31b6 100644 --- a/tests/cron/tasks/simple_should_not_run.php +++ b/tests/cron/tasks/simple_should_not_run.php @@ -1,6 +1,6 @@ <?php -class phpbb_cron_task_core_simple_should_not_run extends phpbb_cron_task_base +class phpbb_cron_task_core_simple_should_not_run extends \phpbb\cron\task\base { public function get_name() { diff --git a/tests/datetime/from_format_test.php b/tests/datetime/from_format_test.php index 2d97672878..34f7f9ae44 100644 --- a/tests/datetime/from_format_test.php +++ b/tests/datetime/from_format_test.php @@ -35,7 +35,7 @@ class phpbb_datetime_from_format_test extends phpbb_test_case { global $user; - $user = new phpbb_user(); + $user = new \phpbb\user(); $user->timezone = new DateTimeZone($timezone); $user->lang['datetime'] = array( 'TODAY' => 'Today', diff --git a/tests/dbal/auto_increment_test.php b/tests/dbal/auto_increment_test.php index 077bfad933..2196292e83 100644 --- a/tests/dbal/auto_increment_test.php +++ b/tests/dbal/auto_increment_test.php @@ -26,7 +26,7 @@ class phpbb_dbal_auto_increment_test extends phpbb_database_test_case parent::setUp(); $this->db = $this->new_dbal(); - $this->tools = new phpbb_db_tools($this->db); + $this->tools = new \phpbb\db\tools($this->db); $this->table_data = array( 'COLUMNS' => array( diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index 7bdbc696e7..e25335165a 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -26,7 +26,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case parent::setUp(); $this->db = $this->new_dbal(); - $this->tools = new phpbb_db_tools($this->db); + $this->tools = new \phpbb\db\tools($this->db); $this->table_data = array( 'COLUMNS' => array( @@ -254,7 +254,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case public function test_peform_schema_changes_drop_tables() { - $db_tools = $this->getMock('phpbb_db_tools', array( + $db_tools = $this->getMock('\phpbb\db\tools', array( 'sql_table_exists', 'sql_table_drop', ), array(&$this->db)); @@ -280,7 +280,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case public function test_peform_schema_changes_drop_columns() { - $db_tools = $this->getMock('phpbb_db_tools', array( + $db_tools = $this->getMock('\phpbb\db\tools', array( 'sql_column_exists', 'sql_column_remove', ), array(&$this->db)); diff --git a/tests/dbal/migration/dummy.php b/tests/dbal/migration/dummy.php index 0ac6e733a1..041c529855 100644 --- a/tests/dbal/migration/dummy.php +++ b/tests/dbal/migration/dummy.php @@ -7,7 +7,7 @@ * */ -class phpbb_dbal_migration_dummy extends phpbb_db_migration +class phpbb_dbal_migration_dummy extends \phpbb\db\migration\migration { static public function depends_on() { diff --git a/tests/dbal/migration/fail.php b/tests/dbal/migration/fail.php index f88d8169f5..d90972720d 100644 --- a/tests/dbal/migration/fail.php +++ b/tests/dbal/migration/fail.php @@ -7,7 +7,7 @@ * */ -class phpbb_dbal_migration_fail extends phpbb_db_migration +class phpbb_dbal_migration_fail extends \phpbb\db\migration\migration { function update_schema() { diff --git a/tests/dbal/migration/if.php b/tests/dbal/migration/if.php index 83fe21bd21..bbbda60ea3 100644 --- a/tests/dbal/migration/if.php +++ b/tests/dbal/migration/if.php @@ -7,7 +7,7 @@ * */ -class phpbb_dbal_migration_if extends phpbb_db_migration +class phpbb_dbal_migration_if extends \phpbb\db\migration\migration { function update_schema() { diff --git a/tests/dbal/migration/installed.php b/tests/dbal/migration/installed.php index 01829f7a99..4b86896d9c 100644 --- a/tests/dbal/migration/installed.php +++ b/tests/dbal/migration/installed.php @@ -7,7 +7,7 @@ * */ -class phpbb_dbal_migration_installed extends phpbb_db_migration +class phpbb_dbal_migration_installed extends \phpbb\db\migration\migration { function effectively_installed() { diff --git a/tests/dbal/migration/recall.php b/tests/dbal/migration/recall.php index 6c2f04bf08..041d12ad27 100644 --- a/tests/dbal/migration/recall.php +++ b/tests/dbal/migration/recall.php @@ -7,7 +7,7 @@ * */ -class phpbb_dbal_migration_recall extends phpbb_db_migration +class phpbb_dbal_migration_recall extends \phpbb\db\migration\migration { function update_schema() { diff --git a/tests/dbal/migration/revert.php b/tests/dbal/migration/revert.php index ac01987cd4..1882b20492 100644 --- a/tests/dbal/migration/revert.php +++ b/tests/dbal/migration/revert.php @@ -7,7 +7,7 @@ * */ -class phpbb_dbal_migration_revert extends phpbb_db_migration +class phpbb_dbal_migration_revert extends \phpbb\db\migration\migration { function update_schema() { diff --git a/tests/dbal/migration/revert_with_dependency.php b/tests/dbal/migration/revert_with_dependency.php index ca2c070e8c..0b09fb784d 100644 --- a/tests/dbal/migration/revert_with_dependency.php +++ b/tests/dbal/migration/revert_with_dependency.php @@ -7,7 +7,7 @@ * */ -class phpbb_dbal_migration_revert_with_dependency extends phpbb_db_migration +class phpbb_dbal_migration_revert_with_dependency extends \phpbb\db\migration\migration { static public function depends_on() { diff --git a/tests/dbal/migration/unfulfillable.php b/tests/dbal/migration/unfulfillable.php index 6d375e6880..a1cdef9a23 100644 --- a/tests/dbal/migration/unfulfillable.php +++ b/tests/dbal/migration/unfulfillable.php @@ -7,7 +7,7 @@ * */ -class phpbb_dbal_migration_unfulfillable extends phpbb_db_migration +class phpbb_dbal_migration_unfulfillable extends \phpbb\db\migration\migration { static public function depends_on() { diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index d722439b3f..c6b4c289d3 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -33,15 +33,15 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case parent::setUp(); $this->db = $this->new_dbal(); - $this->db_tools = new phpbb_db_tools($this->db); + $this->db_tools = new \phpbb\db\tools($this->db); - $this->config = new phpbb_config_db($this->db, new phpbb_mock_cache, 'phpbb_config'); + $this->config = new \phpbb\config\db($this->db, new phpbb_mock_cache, 'phpbb_config'); $tools = array( - new phpbb_db_migration_tool_config($this->config), + new \phpbb\db\migration\tool\config($this->config), ); - $this->migrator = new phpbb_db_migrator( + $this->migrator = new \phpbb\db\migrator( $this->config, $this->db, $this->db_tools, @@ -55,17 +55,11 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case $container = new phpbb_mock_container_builder(); $container->set('migrator', $migrator); - $this->extension_manager = new phpbb_extension_manager( + $this->extension_manager = new \phpbb\extension\manager( $container, $this->db, $this->config, - new phpbb_filesystem( - new phpbb_symfony_request( - new phpbb_mock_request() - ), - dirname(__FILE__) . '/../../phpBB/', - 'php' - ), + new phpbb\filesystem(), 'phpbb_ext', dirname(__FILE__) . '/../../phpBB/', 'php', @@ -238,7 +232,7 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case $this->migrator->update(); } } - catch (phpbb_db_migration_exception $e) {} + catch (\phpbb\db\migration\exception $e) {} // Failure should have caused an automatic roll-back, so this should not exist. $this->assertFalse(isset($this->config['foobar3'])); diff --git a/tests/dbal/migrator_tool_config_test.php b/tests/dbal/migrator_tool_config_test.php index b82d1ef48d..a8d8966839 100644 --- a/tests/dbal/migrator_tool_config_test.php +++ b/tests/dbal/migrator_tool_config_test.php @@ -11,9 +11,9 @@ class phpbb_dbal_migrator_tool_config_test extends phpbb_test_case { public function setup() { - $this->config = new phpbb_config(array()); + $this->config = new \phpbb\config\config(array()); - $this->tool = new phpbb_db_migration_tool_config($this->config); + $this->tool = new \phpbb\db\migration\tool\config($this->config); parent::setup(); } diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php index 828fb76c65..3c23891348 100644 --- a/tests/dbal/migrator_tool_module_test.php +++ b/tests/dbal/migrator_tool_module_test.php @@ -27,15 +27,15 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case $skip_add_log = true; $db = $this->db = $this->new_dbal(); - $this->cache = new phpbb_cache_service(new phpbb_cache_driver_null(), new phpbb_config(array()), $this->db, $phpbb_root_path, $phpEx); - $user = $this->user = new phpbb_user(); + $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\null(), new \phpbb\config\config(array()), $this->db, $phpbb_root_path, $phpEx); + $user = $this->user = new \phpbb\user(); $cache = new phpbb_mock_cache; $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $auth = $this->getMock('phpbb_auth'); - $phpbb_log = new phpbb_log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); + $auth = $this->getMock('\phpbb\auth\auth'); + $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); - $this->tool = new phpbb_db_migration_tool_module($this->db, $this->cache, $this->user, $phpbb_root_path, $phpEx, 'phpbb_modules'); + $this->tool = new \phpbb\db\migration\tool\module($this->db, $this->cache, $this->user, $phpbb_root_path, $phpEx, 'phpbb_modules'); } public function exists_data() diff --git a/tests/dbal/migrator_tool_permission_test.php b/tests/dbal/migrator_tool_permission_test.php index 79d9db66da..1090b4726a 100644 --- a/tests/dbal/migrator_tool_permission_test.php +++ b/tests/dbal/migrator_tool_permission_test.php @@ -24,10 +24,10 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case parent::setup(); $db = $this->db = $this->new_dbal(); - $cache = $this->cache = new phpbb_cache_service(new phpbb_cache_driver_null(), new phpbb_config(array()), $this->db, $phpbb_root_path, $phpEx); - $this->auth = new phpbb_auth(); + $cache = $this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\null(), new \phpbb\config\config(array()), $this->db, $phpbb_root_path, $phpEx); + $this->auth = new \phpbb\auth\auth(); - $this->tool = new phpbb_db_migration_tool_permission($this->db, $this->cache, $this->auth, $phpbb_root_path, $phpEx); + $this->tool = new \phpbb\db\migration\tool\permission($this->db, $this->cache, $this->auth, $phpbb_root_path, $phpEx); } public function exists_data() diff --git a/tests/dbal/sql_insert_buffer_test.php b/tests/dbal/sql_insert_buffer_test.php index 45339a6b50..a70eea4f7e 100644 --- a/tests/dbal/sql_insert_buffer_test.php +++ b/tests/dbal/sql_insert_buffer_test.php @@ -17,7 +17,7 @@ class phpbb_dbal_sql_insert_buffer_test extends phpbb_database_test_case parent::setUp(); $this->db = $this->new_dbal(); - $this->buffer = new phpbb_db_sql_insert_buffer($this->db, 'phpbb_config', 2); + $this->buffer = new \phpbb\db\sql_insert_buffer($this->db, 'phpbb_config', 2); $this->assert_config_count(2); } diff --git a/tests/dbal/write_test.php b/tests/dbal/write_test.php index 987161a831..c069d9a796 100644 --- a/tests/dbal/write_test.php +++ b/tests/dbal/write_test.php @@ -64,7 +64,7 @@ class phpbb_dbal_write_test extends phpbb_database_test_case FROM phpbb_config'; $result = $db->sql_query($sql); $rows = $db->sql_fetchrowset($result); - + $this->assertEquals(1, sizeof($rows)); $this->assertEquals('config2', $rows[0]['config_name']); diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index c570f19ebd..a3a1ad3597 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -7,66 +7,72 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/functions_container.php'; - -class phpbb_di_container_test extends phpbb_test_case +namespace { - public function test_phpbb_create_container() - { - $phpbb_root_path = __DIR__ . '/../../phpBB/'; - $extensions = array( - new phpbb_di_extension_config(__DIR__ . '/fixtures/config.php'), - new phpbb_di_extension_core($phpbb_root_path . 'config'), - ); - $container = phpbb_create_container($extensions, $phpbb_root_path, 'php'); + require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + require_once dirname(__FILE__) . '/../../phpBB/includes/functions_container.php'; + + class phpbb_di_container_test extends phpbb_test_case + { + public function test_phpbb_create_container() + { + $phpbb_root_path = __DIR__ . '/../../phpBB/'; + $extensions = array( + new \phpbb\di\extension\config(__DIR__ . '/fixtures/config.php'), + new \phpbb\di\extension\core($phpbb_root_path . 'config'), + ); + $container = phpbb_create_container($extensions, $phpbb_root_path, 'php'); - $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); - } + $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); + } - public function test_phpbb_create_install_container() - { - $phpbb_root_path = __DIR__ . '/../../phpBB/'; - $extensions = array( - new phpbb_di_extension_config(__DIR__ . '/fixtures/config.php'), - new phpbb_di_extension_core($phpbb_root_path . 'config'), - ); - $container = phpbb_create_install_container($phpbb_root_path, 'php'); + public function test_phpbb_create_install_container() + { + $phpbb_root_path = __DIR__ . '/../../phpBB/'; + $extensions = array( + new \phpbb\di\extension\config(__DIR__ . '/fixtures/config.php'), + new \phpbb\di\extension\core($phpbb_root_path . 'config'), + ); + $container = phpbb_create_install_container($phpbb_root_path, 'php'); - $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); - $this->assertTrue($container->isFrozen()); - } + $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); + $this->assertTrue($container->isFrozen()); + } - public function test_phpbb_create_compiled_container() - { - $phpbb_root_path = __DIR__ . '/../../phpBB/'; - $config_file = __DIR__ . '/fixtures/config.php'; - $extensions = array( - new phpbb_di_extension_config(__DIR__ . '/fixtures/config.php'), - new phpbb_di_extension_core($phpbb_root_path . 'config'), - ); - $container = phpbb_create_compiled_container($config_file, $extensions, array(), $phpbb_root_path, 'php'); + public function test_phpbb_create_compiled_container() + { + $phpbb_root_path = __DIR__ . '/../../phpBB/'; + $config_file = __DIR__ . '/fixtures/config.php'; + $extensions = array( + new \phpbb\di\extension\config(__DIR__ . '/fixtures/config.php'), + new \phpbb\di\extension\core($phpbb_root_path . 'config'), + ); + $container = phpbb_create_compiled_container($config_file, $extensions, array(), $phpbb_root_path, 'php'); - $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); - $this->assertTrue($container->isFrozen()); - } + $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container); + $this->assertTrue($container->isFrozen()); + } + } } -class phpbb_db_driver_container_mock extends phpbb_db_driver +namespace phpbb\db\driver { - public function sql_connect() - { - } + class container_mock extends \phpbb\db\driver\driver + { + public function sql_connect() + { + } - public function sql_query() - { - } + public function sql_query() + { + } - public function sql_fetchrow() - { - } + public function sql_fetchrow() + { + } - public function sql_freeresult() - { - } + public function sql_freeresult() + { + } + } } diff --git a/tests/di/fixtures/config.php b/tests/di/fixtures/config.php index 5033d2dc9f..04e20f63d8 100644 --- a/tests/di/fixtures/config.php +++ b/tests/di/fixtures/config.php @@ -8,4 +8,4 @@ $dbname = 'phpbb'; $dbuser = 'root'; $dbpasswd = ''; $table_prefix = 'phpbb_'; -$acm_type = 'phpbb_cache_driver_null'; +$acm_type = '\phpbb\cache\driver\null'; diff --git a/tests/error_collector_test.php b/tests/error_collector_test.php index fceb8aa3d8..0804c64f6f 100644 --- a/tests/error_collector_test.php +++ b/tests/error_collector_test.php @@ -13,7 +13,7 @@ class phpbb_error_collector_test extends phpbb_test_case { public function test_collection() { - $collector = new phpbb_error_collector; + $collector = new \phpbb\error_collector; $collector->install(); // Cause a warning diff --git a/tests/event/dispatcher_test.php b/tests/event/dispatcher_test.php index 9b9203e06a..a76df90809 100644 --- a/tests/event/dispatcher_test.php +++ b/tests/event/dispatcher_test.php @@ -11,9 +11,9 @@ class phpbb_event_dispatcher_test extends phpbb_test_case { public function test_trigger_event() { - $dispatcher = new phpbb_event_dispatcher(new phpbb_mock_container_builder()); + $dispatcher = new \phpbb\event\dispatcher(new phpbb_mock_container_builder()); - $dispatcher->addListener('core.test_event', function (phpbb_event_data $event) { + $dispatcher->addListener('core.test_event', function (\phpbb\event\data $event) { $event['foo'] = $event['foo'] . '2'; $event['bar'] = $event['bar'] . '2'; }); diff --git a/tests/extension/ext/bar/ext.php b/tests/extension/ext/bar/ext.php index 5585edf9ac..22ff5e8077 100644 --- a/tests/extension/ext/bar/ext.php +++ b/tests/extension/ext/bar/ext.php @@ -1,6 +1,8 @@ <?php -class phpbb_ext_bar_ext extends phpbb_extension_base +namespace bar; + +class ext extends \phpbb\extension\base { static public $state; diff --git a/tests/extension/ext/bar/my/hidden_class.php b/tests/extension/ext/bar/my/hidden_class.php index 0261d7c59a..504c1873dc 100644 --- a/tests/extension/ext/bar/my/hidden_class.php +++ b/tests/extension/ext/bar/my/hidden_class.php @@ -1,5 +1,7 @@ <?php -class phpbb_ext_bar_my_hidden_class +namespace bar\my; + +class hidden_class { } diff --git a/tests/extension/ext/barfoo/acp/a_info.php b/tests/extension/ext/barfoo/acp/a_info.php index cd7e4e574b..ea07189f7a 100644 --- a/tests/extension/ext/barfoo/acp/a_info.php +++ b/tests/extension/ext/barfoo/acp/a_info.php @@ -1,11 +1,13 @@ <?php -class phpbb_ext_barfoo_acp_a_info +namespace barfoo\acp; + +class a_info { public function module() { return array( - 'filename' => 'phpbb_ext_barfoo_acp_a_module', + 'filename' => 'barfoo\\acp\\a_module', 'title' => 'Barfoo', 'version' => '3.1.0-dev', 'modes' => array( diff --git a/tests/extension/ext/barfoo/acp/a_module.php b/tests/extension/ext/barfoo/acp/a_module.php index 5bedb49645..0ae8775013 100644 --- a/tests/extension/ext/barfoo/acp/a_module.php +++ b/tests/extension/ext/barfoo/acp/a_module.php @@ -1,5 +1,7 @@ <?php -class phpbb_ext_barfoo_acp_a_module +namespace barfoo\acp; + +class a_module { } diff --git a/tests/extension/ext/barfoo/ext.php b/tests/extension/ext/barfoo/ext.php index 2e11ece8d1..1b7bb7ca5e 100644 --- a/tests/extension/ext/barfoo/ext.php +++ b/tests/extension/ext/barfoo/ext.php @@ -1,5 +1,7 @@ <?php -class phpbb_ext_barfoo_ext extends phpbb_extension_base +namespace barfoo; + +class ext extends \phpbb\extension\base { } diff --git a/tests/extension/ext/foo/a_class.php b/tests/extension/ext/foo/a_class.php index b7be1ad654..9db45a697f 100644 --- a/tests/extension/ext/foo/a_class.php +++ b/tests/extension/ext/foo/a_class.php @@ -1,5 +1,7 @@ <?php -class phpbb_ext_foo_a_class +namespace foo; + +class a_class { } diff --git a/tests/extension/ext/foo/acp/a_info.php b/tests/extension/ext/foo/acp/a_info.php index 3e9bbffaca..3b7d8cdd42 100644 --- a/tests/extension/ext/foo/acp/a_info.php +++ b/tests/extension/ext/foo/acp/a_info.php @@ -1,11 +1,13 @@ <?php -class phpbb_ext_foo_acp_a_info +namespace foo\acp; + +class a_info { public function module() { return array( - 'filename' => 'phpbb_ext_foo_acp_a_module', + 'filename' => 'foo\\acp\\a_module', 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array( diff --git a/tests/extension/ext/foo/acp/a_module.php b/tests/extension/ext/foo/acp/a_module.php index 093b4b1ad7..7aa2351ab3 100644 --- a/tests/extension/ext/foo/acp/a_module.php +++ b/tests/extension/ext/foo/acp/a_module.php @@ -1,5 +1,7 @@ <?php -class phpbb_ext_foo_acp_a_module +namespace foo\acp; + +class a_module { } diff --git a/tests/extension/ext/foo/acp/fail_info.php b/tests/extension/ext/foo/acp/fail_info.php index 99aa09551e..01d29fc5eb 100644 --- a/tests/extension/ext/foo/acp/fail_info.php +++ b/tests/extension/ext/foo/acp/fail_info.php @@ -1,14 +1,17 @@ <?php + +namespace foo\acp; + /* * Due to the mismatch between the class name and the file name, this module * file shouldn't be found by the extension finder */ -class phpbb_ext_foo_acp_foo_info +class foo_info { public function module() { return array( - 'filename' => 'phpbb_ext_foo_acp_fail_module', + 'filename' => 'foo\acp\fail_module', 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array( diff --git a/tests/extension/ext/foo/acp/fail_module.php b/tests/extension/ext/foo/acp/fail_module.php index a200d92d2f..8070929d3c 100644 --- a/tests/extension/ext/foo/acp/fail_module.php +++ b/tests/extension/ext/foo/acp/fail_module.php @@ -1,8 +1,11 @@ <?php + +namespace foo\acp; + /* * Due to the mismatch between the class name and the file name of the module * info file, this module's info file shouldn't be found */ -class phpbb_ext_foo_acp_fail_module +class fail_module { } diff --git a/tests/extension/ext/foo/b_class.php b/tests/extension/ext/foo/b_class.php index 4645266122..bb2a77c05e 100644 --- a/tests/extension/ext/foo/b_class.php +++ b/tests/extension/ext/foo/b_class.php @@ -1,5 +1,7 @@ <?php -class phpbb_ext_foo_b_class +namespace foo; + +class b_class { } diff --git a/tests/extension/ext/foo/ext.php b/tests/extension/ext/foo/ext.php index 60b3ad1f16..ac6098f2f1 100644 --- a/tests/extension/ext/foo/ext.php +++ b/tests/extension/ext/foo/ext.php @@ -1,6 +1,8 @@ <?php -class phpbb_ext_foo_ext extends phpbb_extension_base +namespace foo; + +class ext extends \phpbb\extension\base { static public $disabled; diff --git a/tests/extension/ext/foo/mcp/a_info.php b/tests/extension/ext/foo/mcp/a_info.php index 84a36b9134..9a896ce808 100644 --- a/tests/extension/ext/foo/mcp/a_info.php +++ b/tests/extension/ext/foo/mcp/a_info.php @@ -1,11 +1,13 @@ <?php -class phpbb_ext_foo_mcp_a_info +namespace foo\mcp; + +class a_info { public function module() { return array( - 'filename' => 'phpbb_ext_foo_mcp_a_module', + 'filename' => 'foo\\mcp\\a_module', 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array( diff --git a/tests/extension/ext/foo/mcp/a_module.php b/tests/extension/ext/foo/mcp/a_module.php index 59d9f8cc6f..ca397e7004 100644 --- a/tests/extension/ext/foo/mcp/a_module.php +++ b/tests/extension/ext/foo/mcp/a_module.php @@ -1,5 +1,7 @@ <?php -class phpbb_ext_foo_mcp_a_module +namespace foo\mcp; + +class a_module { } diff --git a/tests/extension/ext/foo/sub/type/alternative.php b/tests/extension/ext/foo/sub/type/alternative.php index 2ea7353f4b..1eaf794609 100644 --- a/tests/extension/ext/foo/sub/type/alternative.php +++ b/tests/extension/ext/foo/sub/type/alternative.php @@ -1,5 +1,7 @@ <?php -class phpbb_ext_foo_sub_type_alternative +namespace foo\sub\type; + +class alternative { } diff --git a/tests/extension/ext/foo/type/alternative.php b/tests/extension/ext/foo/type/alternative.php index 404b66b965..8f753491ef 100644 --- a/tests/extension/ext/foo/type/alternative.php +++ b/tests/extension/ext/foo/type/alternative.php @@ -1,5 +1,7 @@ <?php -class phpbb_ext_foo_type_alternative +namespace foo\type; + +class alternative { } diff --git a/tests/extension/ext/foo/typewrong/error.php b/tests/extension/ext/foo/typewrong/error.php index ba22cfae9a..5020926043 100644 --- a/tests/extension/ext/foo/typewrong/error.php +++ b/tests/extension/ext/foo/typewrong/error.php @@ -1,5 +1,7 @@ <?php -class phpbb_ext_foo_typewrong_error +namespace foo\typewrong; + +class error { } diff --git a/tests/extension/ext/vendor/moo/ext.php b/tests/extension/ext/vendor/moo/ext.php index e0ac1a22cc..41ef570452 100644 --- a/tests/extension/ext/vendor/moo/ext.php +++ b/tests/extension/ext/vendor/moo/ext.php @@ -1,6 +1,8 @@ <?php -class phpbb_ext_vendor_moo_ext extends phpbb_extension_base +namespace vendor\moo; + +class ext extends \phpbb\extension\base { static public $purged; diff --git a/tests/extension/ext/vendor/moo/feature_class.php b/tests/extension/ext/vendor/moo/feature_class.php index c3bcc4451c..cb8bb3da56 100644 --- a/tests/extension/ext/vendor/moo/feature_class.php +++ b/tests/extension/ext/vendor/moo/feature_class.php @@ -1,5 +1,7 @@ <?php -class phpbb_ext_vendor_moo_feature_class +namespace vendor\moo; + +class feature_class { } diff --git a/tests/extension/finder_test.php b/tests/extension/finder_test.php index 3bf2c42573..8e6e71aaf8 100644 --- a/tests/extension/finder_test.php +++ b/tests/extension/finder_test.php @@ -43,10 +43,10 @@ class phpbb_extension_finder_test extends phpbb_test_case sort($classes); $this->assertEquals( array( - 'phpbb_default_implementation', - 'phpbb_ext_bar_my_hidden_class', - 'phpbb_ext_foo_a_class', - 'phpbb_ext_foo_b_class', + '\bar\my\hidden_class', + '\foo\a_class', + '\foo\b_class', + '\phpbb\default\implementation', ), $classes ); @@ -67,7 +67,7 @@ class phpbb_extension_finder_test extends phpbb_test_case public function test_prefix_get_directories() { $dirs = $this->finder - ->prefix('ty') + ->prefix('ty') ->get_directories(); sort($dirs); @@ -88,8 +88,8 @@ class phpbb_extension_finder_test extends phpbb_test_case sort($classes); $this->assertEquals( array( - 'phpbb_default_implementation', - 'phpbb_ext_bar_my_hidden_class', + '\bar\my\hidden_class', + '\phpbb\default\implementation', ), $classes ); @@ -105,9 +105,9 @@ class phpbb_extension_finder_test extends phpbb_test_case sort($classes); $this->assertEquals( array( - 'phpbb_default_implementation', - 'phpbb_ext_foo_sub_type_alternative', - 'phpbb_ext_foo_type_alternative', + '\foo\sub\type\alternative', + '\foo\type\alternative', + '\phpbb\default\implementation', ), $classes ); @@ -122,7 +122,7 @@ class phpbb_extension_finder_test extends phpbb_test_case sort($classes); $this->assertEquals( array( - 'phpbb_ext_foo_type_alternative', + '\foo\type\alternative', ), $classes ); @@ -137,7 +137,7 @@ class phpbb_extension_finder_test extends phpbb_test_case sort($classes); $this->assertEquals( array( - 'phpbb_ext_foo_sub_type_alternative', + '\foo\sub\type\alternative', ), $classes ); @@ -152,7 +152,7 @@ class phpbb_extension_finder_test extends phpbb_test_case sort($classes); $this->assertEquals( array( - 'phpbb_ext_foo_sub_type_alternative', + '\foo\sub\type\alternative', ), $classes ); @@ -168,8 +168,8 @@ class phpbb_extension_finder_test extends phpbb_test_case sort($classes); $this->assertEquals( array( - 'phpbb_ext_foo_type_alternative', - 'phpbb_ext_foo_type_dummy_empty', + '\foo\type\alternative', + '\foo\type\dummy\empty', ), $classes ); @@ -181,7 +181,7 @@ class phpbb_extension_finder_test extends phpbb_test_case public function test_get_classes_create_cache() { $cache = new phpbb_mock_cache; - $finder = new phpbb_extension_finder($this->extension_manager, new phpbb_filesystem(), 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( @@ -219,9 +219,9 @@ class phpbb_extension_finder_test extends phpbb_test_case 'is_dir' => false, ); - $finder = new phpbb_extension_finder( + $finder = new \phpbb\extension\finder( $this->extension_manager, - new phpbb_filesystem(), + 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 07ca9fb417..b127daf2ed 100644 --- a/tests/extension/manager_test.php +++ b/tests/extension/manager_test.php @@ -45,31 +45,31 @@ class phpbb_extension_manager_test extends phpbb_database_test_case public function test_enable() { - phpbb_ext_bar_ext::$state = 0; + bar\ext::$state = 0; $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled())); $this->extension_manager->enable('bar'); $this->assertEquals(array('bar', 'foo'), array_keys($this->extension_manager->all_enabled())); $this->assertEquals(array('bar', 'foo', 'vendor/moo'), array_keys($this->extension_manager->all_configured())); - $this->assertEquals(4, phpbb_ext_bar_ext::$state); + $this->assertEquals(4, bar\ext::$state); } public function test_disable() { - phpbb_ext_foo_ext::$disabled = false; + foo\ext::$disabled = false; $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled())); $this->extension_manager->disable('foo'); $this->assertEquals(array(), array_keys($this->extension_manager->all_enabled())); $this->assertEquals(array('foo', 'vendor/moo'), array_keys($this->extension_manager->all_configured())); - $this->assertTrue(phpbb_ext_foo_ext::$disabled); + $this->assertTrue(foo\ext::$disabled); } public function test_purge() { - phpbb_ext_vendor_moo_ext::$purged = false; + vendor\moo\ext::$purged = false; $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled())); $this->assertEquals(array('foo', 'vendor/moo'), array_keys($this->extension_manager->all_configured())); @@ -77,7 +77,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled())); $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_configured())); - $this->assertTrue(phpbb_ext_vendor_moo_ext::$purged); + $this->assertTrue(vendor\moo\ext::$purged); } public function test_enabled_no_cache() @@ -90,14 +90,14 @@ class phpbb_extension_manager_test extends phpbb_database_test_case protected function create_extension_manager($with_cache = true) { - $config = new phpbb_config(array()); + $config = new \phpbb\config\config(array()); $db = $this->new_dbal(); - $db_tools = new phpbb_db_tools($db); + $db_tools = new \phpbb\db\tools($db); $phpbb_root_path = __DIR__ . './../../phpBB/'; $php_ext = 'php'; $table_prefix = 'phpbb_'; - $migrator = new phpbb_db_migrator( + $migrator = new \phpbb\db\migrator( $config, $db, $db_tools, @@ -110,17 +110,11 @@ class phpbb_extension_manager_test extends phpbb_database_test_case $container = new phpbb_mock_container_builder(); $container->set('migrator', $migrator); - return new phpbb_extension_manager( + return new \phpbb\extension\manager( $container, $db, $config, - new phpbb_filesystem( - new phpbb_symfony_request( - new phpbb_mock_request() - ), - $phpbb_root_path, - $php_ext - ), + new \phpbb\filesystem(), 'phpbb_ext', dirname(__FILE__) . '/', $php_ext, diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index 3ee10c3a74..242ec38908 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -30,30 +30,31 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case parent::setUp(); $this->cache = new phpbb_mock_cache(); - $this->config = new phpbb_config(array( + $this->config = new \phpbb\config\config(array( 'version' => '3.1.0', )); $this->db = $this->new_dbal(); - $this->db_tools = new phpbb_db_tools($this->db); + $this->db_tools = new \phpbb\db\tools($this->db); $this->phpbb_root_path = dirname(__FILE__) . '/'; $this->phpEx = 'php'; - $this->user = new phpbb_user(); + $this->user = new \phpbb\user(); $this->table_prefix = 'phpbb_'; - $this->template = new phpbb_template_twig( - new phpbb_filesystem( - new phpbb_symfony_request( + $this->template = new \phpbb\template\twig\twig( + new \phpbb\path_helper( + new \phpbb\symfony_request( new phpbb_mock_request() ), + new \phpbb\filesystem(), $this->phpbb_root_path, $this->phpEx ), $this->config, $this->user, - new phpbb_template_context() + new \phpbb\template\context() ); - $this->migrator = new phpbb_db_migrator( + $this->migrator = new \phpbb\db\migrator( $this->config, $this->db, $this->db_tools, @@ -66,17 +67,11 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $container = new phpbb_mock_container_builder(); $container->set('migrator', $migrator); - $this->extension_manager = new phpbb_extension_manager( + $this->extension_manager = new \phpbb\extension\manager( $container, $this->db, $this->config, - new phpbb_filesystem( - new phpbb_symfony_request( - new phpbb_mock_request() - ), - $this->phpbb_root_path, - $this->phpEx - ), + new \phpbb\filesystem(), 'phpbb_ext', $this->phpbb_root_path, $this->phpEx, @@ -95,7 +90,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case { $manager->get_metadata(); } - catch(phpbb_extension_exception $e){} + catch(\phpbb\extension\exception $e){} $this->assertEquals((string) $e, 'The required file does not exist: ' . $this->phpbb_root_path . $this->extension_manager->get_extension_path($ext_name) . 'composer.json'); } @@ -111,7 +106,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case { $metadata = $manager->get_metadata(); } - catch(phpbb_extension_exception $e) + catch(\phpbb\extension\exception $e) { $this->fail($e); } @@ -134,7 +129,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->fail('Exception not triggered'); } - catch(phpbb_extension_exception $e) + catch(\phpbb\extension\exception $e) { $this->assertEquals((string) $e, 'Required meta field \'name\' has not been set.'); } @@ -145,7 +140,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->fail('Exception not triggered'); } - catch(phpbb_extension_exception $e) + catch(\phpbb\extension\exception $e) { $this->assertEquals((string) $e, 'Required meta field \'type\' has not been set.'); } @@ -156,7 +151,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->fail('Exception not triggered'); } - catch(phpbb_extension_exception $e) + catch(\phpbb\extension\exception $e) { $this->assertEquals((string) $e, 'Required meta field \'licence\' has not been set.'); } @@ -167,7 +162,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->fail('Exception not triggered'); } - catch(phpbb_extension_exception $e) + catch(\phpbb\extension\exception $e) { $this->assertEquals((string) $e, 'Required meta field \'version\' has not been set.'); } @@ -178,7 +173,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->fail('Exception not triggered'); } - catch(phpbb_extension_exception $e) + catch(\phpbb\extension\exception $e) { $this->assertEquals((string) $e, 'Required meta field \'authors\' has not been set.'); } @@ -195,7 +190,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->fail('Exception not triggered'); } - catch(phpbb_extension_exception $e) + catch(\phpbb\extension\exception $e) { $this->assertEquals((string) $e, 'Required meta field \'author name\' has not been set.'); } @@ -222,7 +217,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->fail('Exception not triggered'); } - catch(phpbb_extension_exception $e) + catch(\phpbb\extension\exception $e) { $this->assertEquals((string) $e, 'Meta field \'name\' is invalid.'); } @@ -233,7 +228,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->fail('Exception not triggered'); } - catch(phpbb_extension_exception $e) + catch(\phpbb\extension\exception $e) { $this->assertEquals((string) $e, 'Meta field \'type\' is invalid.'); } @@ -244,7 +239,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->fail('Exception not triggered'); } - catch(phpbb_extension_exception $e) + catch(\phpbb\extension\exception $e) { $this->assertEquals((string) $e, 'Meta field \'licence\' is invalid.'); } @@ -255,7 +250,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->fail('Exception not triggered'); } - catch(phpbb_extension_exception $e) + catch(\phpbb\extension\exception $e) { $this->assertEquals((string) $e, 'Meta field \'version\' is invalid.'); } @@ -279,7 +274,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case { $this->assertEquals(true, $manager->validate('enable')); } - catch(phpbb_extension_exception $e) + catch(\phpbb\extension\exception $e) { $this->fail($e); } @@ -304,7 +299,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->assertEquals(false, $manager->validate_require_php()); $this->assertEquals(false, $manager->validate_require_phpbb()); } - catch(phpbb_extension_exception $e) + catch(\phpbb\extension\exception $e) { $this->fail($e); } @@ -323,7 +318,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->assertEquals(true, $manager->validate_require_php()); $this->assertEquals(true, $manager->validate_require_phpbb()); } - catch(phpbb_extension_exception $e) + catch(\phpbb\extension\exception $e) { $this->fail($e); } @@ -342,7 +337,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->assertEquals(false, $manager->validate_require_php()); $this->assertEquals(false, $manager->validate_require_phpbb()); } - catch(phpbb_extension_exception $e) + catch(\phpbb\extension\exception $e) { $this->fail($e); } @@ -361,7 +356,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->assertEquals(false, $manager->validate_require_php()); $this->assertEquals(false, $manager->validate_require_phpbb()); } - catch(phpbb_extension_exception $e) + catch(\phpbb\extension\exception $e) { $this->fail($e); } @@ -380,7 +375,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->assertEquals(true, $manager->validate_require_php()); $this->assertEquals(true, $manager->validate_require_phpbb()); } - catch(phpbb_extension_exception $e) + catch(\phpbb\extension\exception $e) { $this->fail($e); } @@ -399,7 +394,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->assertEquals(true, $manager->validate_require_php()); $this->assertEquals(true, $manager->validate_require_phpbb()); } - catch(phpbb_extension_exception $e) + catch(\phpbb\extension\exception $e) { $this->fail($e); } @@ -418,7 +413,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->assertEquals(true, $manager->validate_require_php()); $this->assertEquals(true, $manager->validate_require_phpbb()); } - catch(phpbb_extension_exception $e) + catch(\phpbb\extension\exception $e) { $this->fail($e); } diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php index fe71747c5d..ef21c943c2 100644 --- a/tests/extension/modules_test.php +++ b/tests/extension/modules_test.php @@ -45,6 +45,8 @@ class phpbb_extension_modules_test extends phpbb_test_case { global $phpbb_root_path; +// $this->markTestIncomplete('Modules no speak namespace! Going to get rid of db modules altogether and fix this test after.'); + // Correctly set the root path for this test to this directory, so the classes can be found $phpbb_root_path = dirname(__FILE__) . '/'; @@ -52,8 +54,8 @@ class phpbb_extension_modules_test extends phpbb_test_case $this->acp_modules->module_class = 'acp'; $acp_modules = $this->acp_modules->get_module_infos(); $this->assertEquals(array( - 'phpbb_ext_foo_acp_a_module' => array( - 'filename' => 'phpbb_ext_foo_acp_a_module', + 'foo\\acp\\a_module' => array( + 'filename' => 'foo\\acp\\a_module', 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array( @@ -74,8 +76,8 @@ class phpbb_extension_modules_test extends phpbb_test_case $this->acp_modules->module_class = 'mcp'; $acp_modules = $this->acp_modules->get_module_infos(); $this->assertEquals(array( - 'phpbb_ext_foo_mcp_a_module' => array( - 'filename' => 'phpbb_ext_foo_mcp_a_module', + 'foo\\mcp\\a_module' => array( + 'filename' => 'foo\\mcp\\a_module', 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array( @@ -88,8 +90,8 @@ class phpbb_extension_modules_test extends phpbb_test_case $this->acp_modules->module_class = 'mcp'; $acp_modules = $this->acp_modules->get_module_infos('mcp_a_module'); $this->assertEquals(array( - 'phpbb_ext_foo_mcp_a_module' => array( - 'filename' => 'phpbb_ext_foo_mcp_a_module', + 'foo\\mcp\\a_module' => array( + 'filename' => 'foo\\mcp\\a_module', 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array( @@ -102,8 +104,8 @@ class phpbb_extension_modules_test extends phpbb_test_case $this->acp_modules->module_class = ''; $acp_modules = $this->acp_modules->get_module_infos('mcp_a_module', 'mcp'); $this->assertEquals(array( - 'phpbb_ext_foo_mcp_a_module' => array( - 'filename' => 'phpbb_ext_foo_mcp_a_module', + 'foo\\mcp\\a_module' => array( + 'filename' => 'foo\\mcp\\a_module', 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array( @@ -124,10 +126,10 @@ class phpbb_extension_modules_test extends phpbb_test_case // Get module info of specified extension module $this->acp_modules->module_class = 'acp'; - $acp_modules = $this->acp_modules->get_module_infos('phpbb_ext_foo_acp_a_module'); + $acp_modules = $this->acp_modules->get_module_infos('foo_acp_a_module'); $this->assertEquals(array( - 'phpbb_ext_foo_acp_a_module' => array ( - 'filename' => 'phpbb_ext_foo_acp_a_module', + 'foo\\acp\\a_module' => array ( + 'filename' => 'foo\\acp\\a_module', 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array ( @@ -150,8 +152,8 @@ class phpbb_extension_modules_test extends phpbb_test_case $this->acp_modules->module_class = 'acp'; $acp_modules = $this->acp_modules->get_module_infos('', false, true); $this->assertEquals(array( - 'phpbb_ext_foo_acp_a_module' => array( - 'filename' => 'phpbb_ext_foo_acp_a_module', + 'foo\\acp\\a_module' => array( + 'filename' => 'foo\\acp\\a_module', 'title' => 'Foobar', 'version' => '3.1.0-dev', 'modes' => array( @@ -166,8 +168,8 @@ class phpbb_extension_modules_test extends phpbb_test_case 'test' => array('title' => 'Test', 'auth' => '', 'cat' => array('ACP_GENERAL')), ), ), - 'phpbb_ext_barfoo_acp_a_module' => array( - 'filename' => 'phpbb_ext_barfoo_acp_a_module', + 'barfoo\\acp\\a_module' => array( + 'filename' => 'barfoo\\acp\\a_module', 'title' => 'Barfoo', 'version' => '3.1.0-dev', 'modes' => array( @@ -177,10 +179,10 @@ class phpbb_extension_modules_test extends phpbb_test_case ), $acp_modules); // Specific module set to disabled extension - $acp_modules = $this->acp_modules->get_module_infos('phpbb_ext_barfoo_acp_a_module', 'acp', true); + $acp_modules = $this->acp_modules->get_module_infos('barfoo_acp_a_module', 'acp', true); $this->assertEquals(array( - 'phpbb_ext_barfoo_acp_a_module' => array( - 'filename' => 'phpbb_ext_barfoo_acp_a_module', + 'barfoo\\acp\\a_module' => array( + 'filename' => 'barfoo\\acp\\a_module', 'title' => 'Barfoo', 'version' => '3.1.0-dev', 'modes' => array( diff --git a/tests/filesystem/clean_path_test.php b/tests/filesystem/clean_path_test.php index 38ccf1b603..fedadc103b 100644 --- a/tests/filesystem/clean_path_test.php +++ b/tests/filesystem/clean_path_test.php @@ -14,13 +14,7 @@ class phpbb_filesystem_clean_path_test extends phpbb_test_case public function setUp() { parent::setUp(); - $this->filesystem = new phpbb_filesystem( - new phpbb_symfony_request( - new phpbb_mock_request() - ), - dirname(__FILE__) . './../../phpBB/', - 'php' - ); + $this->filesystem = new \phpbb\filesystem(); } public function clean_path_data() diff --git a/tests/functional/acp_permissions_test.php b/tests/functional/acp_permissions_test.php index a3d272906f..e17f33dc96 100644 --- a/tests/functional/acp_permissions_test.php +++ b/tests/functional/acp_permissions_test.php @@ -91,12 +91,12 @@ class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case $crawler = self::request('GET', "adm/index.php?i=acp_permissions&icat=16&mode=$mode&${object_name}[0]=$object_id&type=$permission_type&sid=" . $this->sid); $this->assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text()); - // XXX globals for phpbb_auth, refactor it later + // XXX globals for \phpbb\auth\auth, refactor it later global $db, $cache; $db = $this->get_db(); $cache = new phpbb_mock_null_cache; - $auth = new phpbb_auth; + $auth = new \phpbb\auth\auth; // XXX hardcoded id $user_data = $auth->obtain_user_data(2); $auth->acl($user_data); @@ -114,7 +114,7 @@ class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case $this->assertContains($this->lang('AUTH_UPDATED'), $crawler->text()); // check acl again - $auth = new phpbb_auth; + $auth = new \phpbb\auth\auth; // XXX hardcoded id $user_data = $auth->obtain_user_data(2); $auth->acl($user_data); diff --git a/tests/functional/common_avatar_test.php b/tests/functional/common_avatar_test.php index c0f21d07c2..1fd8f2ed6f 100644 --- a/tests/functional/common_avatar_test.php +++ b/tests/functional/common_avatar_test.php @@ -32,7 +32,7 @@ abstract class phpbb_functional_common_avatar_test extends phpbb_functional_test $crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=avatar&sid=' . $this->sid); // Check the default entries we should have $this->assertContainsLang('ALLOW_GRAVATAR', $crawler->text()); - $this->assertContainsLang('ALLOW_REMOTE', $crawler->text()); + $this->assertContainsLang('ALLOW_REMOTE_UPLOAD', $crawler->text()); $this->assertContainsLang('ALLOW_AVATARS', $crawler->text()); $this->assertContainsLang('ALLOW_LOCAL', $crawler->text()); diff --git a/tests/functional/common_groups_test.php b/tests/functional/common_groups_test.php index 6c6572af62..950db24767 100644 --- a/tests/functional/common_groups_test.php +++ b/tests/functional/common_groups_test.php @@ -43,7 +43,7 @@ abstract class phpbb_functional_common_groups_test extends phpbb_functional_test $crawler = self::request('GET', 'adm/index.php?i=board&mode=avatar&sid=' . $this->sid); // Check the default entries we should have - $this->assertContains($this->lang('ALLOW_REMOTE'), $crawler->text()); + $this->assertContains($this->lang('ALLOW_REMOTE_UPLOAD'), $crawler->text()); $this->assertContains($this->lang('ALLOW_AVATARS'), $crawler->text()); $this->assertContains($this->lang('ALLOW_LOCAL'), $crawler->text()); diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index dc6d9c0f65..41bd48c204 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -78,7 +78,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c $this->phpbb_extension_manager->enable('foo/bar'); $crawler = self::request('GET', 'app.php/foo/baz', array(), false); $this->assert_response_html(500); - $this->assertContains('Missing value for argument #1: test in class phpbb_ext_foo_bar_controller:baz', $crawler->filter('body')->text()); + $this->assertContains('Missing value for argument #1: test in class foo\bar\controller\controller:baz', $crawler->filter('body')->text()); $this->phpbb_extension_manager->purge('foo/bar'); } diff --git a/tests/functional/extension_module_test.php b/tests/functional/extension_module_test.php index c31a892ce9..090cd38daf 100644 --- a/tests/functional/extension_module_test.php +++ b/tests/functional/extension_module_test.php @@ -69,7 +69,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case $modules->update_module_data($parent_data, true); $module_data = array( - 'module_basename' => 'phpbb_ext_foo_bar_acp_main_module', + 'module_basename' => 'foo\\bar\\acp\\main_module', 'module_enabled' => 1, 'module_display' => 1, 'parent_id' => $parent_data['module_id'], @@ -90,7 +90,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case { $this->login(); $this->admin_login(); - $crawler = self::request('GET', 'adm/index.php?i=phpbb_ext_foo_bar_acp_main_module&mode=mode&sid=' . $this->sid); + $crawler = self::request('GET', 'adm/index.php?i=foo%5cbar%5cacp%5cmain_module&mode=mode&sid=' . $this->sid); $this->assertContains("Bertie rulez!", $crawler->filter('#main')->text()); $this->phpbb_extension_manager->purge('foo/bar'); } diff --git a/tests/functional/fixtures/ext/foo/bar/acp/main_info.php b/tests/functional/fixtures/ext/foo/bar/acp/main_info.php index 21e38b09b5..2ad6d08503 100644 --- a/tests/functional/fixtures/ext/foo/bar/acp/main_info.php +++ b/tests/functional/fixtures/ext/foo/bar/acp/main_info.php @@ -8,6 +8,8 @@ * */ +namespace foo\bar\acp; + /** * @ignore */ @@ -16,12 +18,12 @@ if (!defined('IN_PHPBB')) exit; } -class phpbb_ext_foo_bar_acp_main_info +class main_info { function module() { return array( - 'filename' => 'phpbb_ext_foo_bar_acp_main_module', + 'filename' => 'foo\bar\acp\main_module', 'title' => 'ACP_FOOBAR_TITLE', 'version' => '1.0.0', 'modes' => array( diff --git a/tests/functional/fixtures/ext/foo/bar/acp/main_module.php b/tests/functional/fixtures/ext/foo/bar/acp/main_module.php index c4ab69fb38..c59b3c6820 100644 --- a/tests/functional/fixtures/ext/foo/bar/acp/main_module.php +++ b/tests/functional/fixtures/ext/foo/bar/acp/main_module.php @@ -8,6 +8,8 @@ * */ +namespace foo\bar\acp; + /** * @ignore */ @@ -16,7 +18,7 @@ if (!defined('IN_PHPBB')) exit; } -class phpbb_ext_foo_bar_acp_main_module +class main_module { var $u_action; diff --git a/tests/functional/fixtures/ext/foo/bar/config/services.yml b/tests/functional/fixtures/ext/foo/bar/config/services.yml index 33ced55af9..3bca4c6567 100644 --- a/tests/functional/fixtures/ext/foo/bar/config/services.yml +++ b/tests/functional/fixtures/ext/foo/bar/config/services.yml @@ -1,6 +1,6 @@ services: foo_bar.controller: - class: phpbb_ext_foo_bar_controller + class: foo\bar\controller\controller arguments: - @controller.helper - @template diff --git a/tests/functional/fixtures/ext/foo/bar/controller/controller.php b/tests/functional/fixtures/ext/foo/bar/controller/controller.php index 5a91b5f681..259d548299 100644 --- a/tests/functional/fixtures/ext/foo/bar/controller/controller.php +++ b/tests/functional/fixtures/ext/foo/bar/controller/controller.php @@ -1,11 +1,14 @@ <?php + +namespace foo\bar\controller; + use Symfony\Component\HttpFoundation\Response; -class phpbb_ext_foo_bar_controller +class controller { protected $template; - public function __construct(phpbb_controller_helper $helper, phpbb_template $template) + public function __construct(\phpbb\controller\helper $helper, \phpbb\template\template $template) { $this->template = $template; $this->helper = $helper; @@ -30,6 +33,6 @@ class phpbb_ext_foo_bar_controller public function exception() { - throw new phpbb_controller_exception('Exception thrown from foo/exception route'); + throw new \phpbb\controller\exception('Exception thrown from foo/exception route'); } } diff --git a/tests/functional/fixtures/ext/foo/bar/event/permission.php b/tests/functional/fixtures/ext/foo/bar/event/permission.php index 48688a586a..92e24074ad 100644 --- a/tests/functional/fixtures/ext/foo/bar/event/permission.php +++ b/tests/functional/fixtures/ext/foo/bar/event/permission.php @@ -8,6 +8,8 @@ * */ +namespace foo\bar\event; + /** * @ignore */ @@ -22,7 +24,7 @@ if (!defined('IN_PHPBB')) */ use Symfony\Component\EventDispatcher\EventSubscriberInterface; -class phpbb_ext_foo_bar_event_permission implements EventSubscriberInterface +class permission implements EventSubscriberInterface { static public function getSubscribedEvents() { diff --git a/tests/functional/fixtures/ext/foo/bar/event/user_setup.php b/tests/functional/fixtures/ext/foo/bar/event/user_setup.php index 3d2d0c5325..1409f97470 100644 --- a/tests/functional/fixtures/ext/foo/bar/event/user_setup.php +++ b/tests/functional/fixtures/ext/foo/bar/event/user_setup.php @@ -8,6 +8,8 @@ * */ +namespace foo\bar\event; + /** * @ignore */ @@ -22,7 +24,7 @@ if (!defined('IN_PHPBB')) */ use Symfony\Component\EventDispatcher\EventSubscriberInterface; -class phpbb_ext_foo_bar_event_user_setup implements EventSubscriberInterface +class user_setup implements EventSubscriberInterface { static public function getSubscribedEvents() { diff --git a/tests/functional/fixtures/ext/foo/bar/ext.php b/tests/functional/fixtures/ext/foo/bar/ext.php index 74359d51ab..1288edd5ec 100644 --- a/tests/functional/fixtures/ext/foo/bar/ext.php +++ b/tests/functional/fixtures/ext/foo/bar/ext.php @@ -1,6 +1,8 @@ <?php -class phpbb_ext_foo_bar_ext extends phpbb_extension_base +namespace foo\bar; + +class ext extends \phpbb\extension\base { } diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 7fd1e4fdcf..dd95704952 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -22,8 +22,8 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); $this->assertContains('This is a test topic posted by the testing framework.', $crawler->filter('html')->text()); - // Test creating a reply - $post2 = $this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', 'This is a test post posted by the testing framework.'); + // Test creating a reply with bbcode + $post2 = $this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', 'This is a test [b]post[/b] posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}"); $this->assertContains('This is a test post posted by the testing framework.', $crawler->filter('html')->text()); diff --git a/tests/functional/registration_test.php b/tests/functional/registration_test.php new file mode 100644 index 0000000000..5baf33c59e --- /dev/null +++ b/tests/functional/registration_test.php @@ -0,0 +1,52 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2013 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @group functional +*/ +class phpbb_functional_registration_test extends phpbb_functional_test_case +{ + public function test_disable_captcha_on_registration() + { + $this->login(); + $this->admin_login(); + + $crawler = self::request('GET', "adm/index.php?i=acp_board&mode=registration&sid={$this->sid}"); + $form = $crawler->selectButton('Submit')->form(); + $form['config[enable_confirm]']->setValue('0'); + $crawler = self::submit($form); + + $this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('#main .successbox')->text()); + } + + /** + * @depends test_disable_captcha_on_registration + */ + public function test_register_new_account() + { + $this->add_lang('ucp'); + + $crawler = self::request('GET', 'ucp.php?mode=register'); + $this->assertContainsLang('REGISTRATION', $crawler->filter('div.content h2')->text()); + + $form = $crawler->selectButton('I agree to these terms')->form(); + $crawler = self::submit($form); + + $form = $crawler->selectButton('Submit')->form(array( + 'username' => 'user-reg-test', + 'email' => 'user-reg-test@phpbb.com', + 'new_password' => 'testtest', + 'password_confirm' => 'testtest', + )); + $form['tz']->select('Europe/Berlin'); + $crawler = self::submit($form); + + $this->assertContainsLang('ACCOUNT_ADDED', $crawler->filter('#message')->text()); + } +} diff --git a/tests/functions/convert_30_dbms_to_31_test.php b/tests/functions/convert_30_dbms_to_31_test.php index d08bf87f15..4d210d7b29 100644 --- a/tests/functions/convert_30_dbms_to_31_test.php +++ b/tests/functions/convert_30_dbms_to_31_test.php @@ -31,7 +31,7 @@ class phpbb_convert_30_dbms_to_31_test extends phpbb_test_case */ public function test_convert_30_dbms_to_31($input) { - $expected = "phpbb_db_driver_$input"; + $expected = "phpbb\\db\\driver\\$input"; $output = phpbb_convert_30_dbms_to_31($input); diff --git a/tests/functions/obtain_online_test.php b/tests/functions/obtain_online_test.php index fe372431a9..624e05f77f 100644 --- a/tests/functions/obtain_online_test.php +++ b/tests/functions/obtain_online_test.php @@ -160,7 +160,7 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case $config['load_online_guests'] = $display_guests; $user = new phpbb_mock_lang(); $user->lang = $this->load_language(); - $auth = $this->getMock('phpbb_auth'); + $auth = $this->getMock('\phpbb\auth\auth'); $acl_get_map = array( array('u_viewonline', true), array('u_viewprofile', true), diff --git a/tests/functions_user/group_user_attributes_test.php b/tests/functions_user/group_user_attributes_test.php index 4336fd894e..f8d52a9a6a 100644 --- a/tests/functions_user/group_user_attributes_test.php +++ b/tests/functions_user/group_user_attributes_test.php @@ -131,17 +131,17 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes $cache = new phpbb_mock_cache; $db = $this->new_dbal(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $auth = $this->getMock('phpbb_auth'); + $auth = $this->getMock('\phpbb\auth\auth'); $auth->expects($this->any()) ->method('acl_clear_prefetch'); - $cache_driver = new phpbb_cache_driver_null(); + $cache_driver = new \phpbb\cache\driver\null(); $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $phpbb_container ->expects($this->any()) ->method('get') ->with('cache.driver') ->will($this->returnValue($cache_driver)); - $phpbb_log = new phpbb_log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); + $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); group_user_attributes('default', $group_id, array($user_id), false, 'group_name', $group_row); diff --git a/tests/groupposition/legend_test.php b/tests/groupposition/legend_test.php index 16e33b390c..ac54a86b8e 100644 --- a/tests/groupposition/legend_test.php +++ b/tests/groupposition/legend_test.php @@ -20,7 +20,7 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case return array( array(1, 0, ''), array(3, 2, ''), - array(4, 0, 'phpbb_groupposition_exception'), + array(4, 0, '\phpbb\groupposition\exception'), ); } @@ -33,7 +33,7 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new phpbb_user; + $user = new \phpbb\user; $user->lang = array(); if ($throws_exception) @@ -41,7 +41,7 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case $this->setExpectedException($throws_exception); } - $test_class = new phpbb_groupposition_legend($db, $user); + $test_class = new \phpbb\groupposition\legend($db, $user); $this->assertEquals($expected, $test_class->get_group_value($group_id)); } @@ -51,10 +51,10 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new phpbb_user; + $user = new \phpbb\user; $user->lang = array(); - $test_class = new phpbb_groupposition_legend($db, $user); + $test_class = new \phpbb\groupposition\legend($db, $user); $this->assertEquals(2, $test_class->get_group_count()); } @@ -91,10 +91,10 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new phpbb_user; + $user = new \phpbb\user; $user->lang = array(); - $test_class = new phpbb_groupposition_legend($db, $user); + $test_class = new \phpbb\groupposition\legend($db, $user); $this->assertEquals($expected_added, $test_class->add_group($group_id)); $result = $db->sql_query('SELECT group_id, group_legend @@ -179,10 +179,10 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new phpbb_user; + $user = new \phpbb\user; $user->lang = array(); - $test_class = new phpbb_groupposition_legend($db, $user); + $test_class = new \phpbb\groupposition\legend($db, $user); $this->assertEquals($expected_deleted, $test_class->delete_group($group_id, $skip_group)); $result = $db->sql_query('SELECT group_id, group_legend @@ -234,10 +234,10 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new phpbb_user; + $user = new \phpbb\user; $user->lang = array(); - $test_class = new phpbb_groupposition_legend($db, $user); + $test_class = new \phpbb\groupposition\legend($db, $user); $this->assertEquals($excepted_moved, $test_class->move_up($group_id)); $result = $db->sql_query('SELECT group_id, group_legend @@ -289,10 +289,10 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new phpbb_user; + $user = new \phpbb\user; $user->lang = array(); - $test_class = new phpbb_groupposition_legend($db, $user); + $test_class = new \phpbb\groupposition\legend($db, $user); $this->assertEquals($excepted_moved, $test_class->move_down($group_id)); $result = $db->sql_query('SELECT group_id, group_legend @@ -387,10 +387,10 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new phpbb_user; + $user = new \phpbb\user; $user->lang = array(); - $test_class = new phpbb_groupposition_legend($db, $user); + $test_class = new \phpbb\groupposition\legend($db, $user); $this->assertEquals($excepted_moved, $test_class->move($group_id, $increment)); $result = $db->sql_query('SELECT group_id, group_legend diff --git a/tests/groupposition/teampage_test.php b/tests/groupposition/teampage_test.php index db26cd09d5..ec89f56775 100644 --- a/tests/groupposition/teampage_test.php +++ b/tests/groupposition/teampage_test.php @@ -22,7 +22,7 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case return array( array(2, 3, ''), array(6, 8, ''), - array(10, 0, 'phpbb_groupposition_exception'), + array(10, 0, '\phpbb\groupposition\exception'), ); } @@ -35,7 +35,7 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new phpbb_user; + $user = new \phpbb\user; $user->lang = array(); if ($throws_exception) @@ -43,7 +43,7 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case $this->setExpectedException($throws_exception); } - $test_class = new phpbb_groupposition_teampage($db, $user, $cache); + $test_class = new \phpbb\groupposition\teampage($db, $user, $cache); $this->assertEquals($expected, $test_class->get_group_value($group_id)); } @@ -53,10 +53,10 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new phpbb_user; + $user = new \phpbb\user; $user->lang = array(); - $test_class = new phpbb_groupposition_teampage($db, $user, $cache); + $test_class = new \phpbb\groupposition\teampage($db, $user, $cache); $this->assertEquals(8, $test_class->get_group_count()); } @@ -137,10 +137,10 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new phpbb_user; + $user = new \phpbb\user; $user->lang = array(); - $test_class = new phpbb_groupposition_teampage($db, $user, $cache); + $test_class = new \phpbb\groupposition\teampage($db, $user, $cache); $this->assertEquals($expected_added, $test_class->add_group_teampage($group_id, $parent_id)); $result = $db->sql_query('SELECT teampage_position, group_id, teampage_parent, teampage_name @@ -180,10 +180,10 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new phpbb_user; + $user = new \phpbb\user; $user->lang = array(); - $test_class = new phpbb_groupposition_teampage($db, $user, $cache); + $test_class = new \phpbb\groupposition\teampage($db, $user, $cache); $this->assertEquals($expected_added, $test_class->add_category_teampage($group_name)); $result = $db->sql_query('SELECT teampage_position, group_id, teampage_parent, teampage_name @@ -247,10 +247,10 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new phpbb_user; + $user = new \phpbb\user; $user->lang = array(); - $test_class = new phpbb_groupposition_teampage($db, $user, $cache); + $test_class = new \phpbb\groupposition\teampage($db, $user, $cache); $this->assertEquals($expected_deleted, $test_class->delete_group($group_id, false)); $result = $db->sql_query('SELECT teampage_position, group_id, teampage_parent, teampage_name @@ -299,10 +299,10 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new phpbb_user; + $user = new \phpbb\user; $user->lang = array(); - $test_class = new phpbb_groupposition_teampage($db, $user, $cache); + $test_class = new \phpbb\groupposition\teampage($db, $user, $cache); $this->assertEquals($expected_deleted, $test_class->delete_teampage($teampage_id, false)); $result = $db->sql_query('SELECT teampage_position, group_id, teampage_parent, teampage_name @@ -462,10 +462,10 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new phpbb_user; + $user = new \phpbb\user; $user->lang = array(); - $test_class = new phpbb_groupposition_teampage($db, $user, $cache); + $test_class = new \phpbb\groupposition\teampage($db, $user, $cache); $this->assertEquals($excepted_moved, $test_class->move($group_id, $move_delta)); $result = $db->sql_query('SELECT teampage_position, group_id, teampage_parent, teampage_name @@ -625,10 +625,10 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case $cache = new phpbb_mock_cache; $db = $this->new_dbal(); - $user = new phpbb_user; + $user = new \phpbb\user; $user->lang = array(); - $test_class = new phpbb_groupposition_teampage($db, $user, $cache); + $test_class = new \phpbb\groupposition\teampage($db, $user, $cache); $this->assertEquals($excepted_moved, $test_class->move_teampage($teampage_id, $move_delta)); $result = $db->sql_query('SELECT teampage_position, group_id, teampage_parent, teampage_name diff --git a/tests/lock/db_test.php b/tests/lock/db_test.php index de7a23fd05..da689b7fa3 100644 --- a/tests/lock/db_test.php +++ b/tests/lock/db_test.php @@ -25,9 +25,9 @@ class phpbb_lock_db_test extends phpbb_database_test_case global $db, $config; $db = $this->db = $this->new_dbal(); - $config = $this->config = new phpbb_config(array('rand_seed' => '', 'rand_seed_last_update' => '0')); + $config = $this->config = new \phpbb\config\config(array('rand_seed' => '', 'rand_seed_last_update' => '0')); set_config(null, null, null, $this->config); - $this->lock = new phpbb_lock_db('test_lock', $this->config, $this->db); + $this->lock = new \phpbb\lock\db('test_lock', $this->config, $this->db); } public function test_new_lock() @@ -38,7 +38,7 @@ class phpbb_lock_db_test extends phpbb_database_test_case $this->assertTrue($this->lock->owns_lock()); $this->assertTrue(isset($this->config['test_lock']), 'Lock was created'); - $lock2 = new phpbb_lock_db('test_lock', $this->config, $this->db); + $lock2 = new \phpbb\lock\db('test_lock', $this->config, $this->db); $this->assertFalse($lock2->acquire()); $this->assertFalse($lock2->owns_lock()); @@ -49,7 +49,7 @@ class phpbb_lock_db_test extends phpbb_database_test_case public function test_expire_lock() { - $lock = new phpbb_lock_db('foo_lock', $this->config, $this->db); + $lock = new \phpbb\lock\db('foo_lock', $this->config, $this->db); $this->assertTrue($lock->acquire()); } @@ -82,7 +82,7 @@ class phpbb_lock_db_test extends phpbb_database_test_case $this->assertFalse($this->lock->owns_lock()); $this->assertEquals('0', $this->config['test_lock'], 'First lock is released'); - $lock2 = new phpbb_lock_db('test_lock', $this->config, $this->db); + $lock2 = new \phpbb\lock\db('test_lock', $this->config, $this->db); $this->assertTrue($lock2->acquire()); $this->assertTrue($lock2->owns_lock()); $this->assertFalse(empty($this->config['test_lock']), 'Second lock is acquired'); diff --git a/tests/lock/flock_test.php b/tests/lock/flock_test.php index 8f0b866ab3..5e5ac5aa78 100644 --- a/tests/lock/flock_test.php +++ b/tests/lock/flock_test.php @@ -13,7 +13,7 @@ class phpbb_lock_flock_test extends phpbb_test_case { $path = __DIR__ . '/../tmp/precious'; - $lock = new phpbb_lock_flock($path); + $lock = new \phpbb\lock\flock($path); $ok = $lock->acquire(); $this->assertTrue($ok); $lock->release(); @@ -23,7 +23,7 @@ class phpbb_lock_flock_test extends phpbb_test_case { $path = __DIR__ . '/../tmp/precious'; - $lock = new phpbb_lock_flock($path); + $lock = new \phpbb\lock\flock($path); $ok = $lock->acquire(); $this->assertTrue($ok); $this->assertTrue($lock->owns_lock()); @@ -48,11 +48,11 @@ class phpbb_lock_flock_test extends phpbb_test_case { $path = __DIR__ . '/../tmp/precious'; - $lock1 = new phpbb_lock_flock($path); + $lock1 = new \phpbb\lock\flock($path); $ok = $lock1->acquire(); $this->assertTrue($ok); - $lock2 = new phpbb_lock_flock($path); + $lock2 = new \phpbb\lock\flock($path); $ok = $lock2->acquire(); $this->assertFalse($ok); @@ -78,7 +78,7 @@ class phpbb_lock_flock_test extends phpbb_test_case // wait 0.5 s, acquire the lock, note how long it took sleep(1); - $lock = new phpbb_lock_flock($path); + $lock = new \phpbb\lock\flock($path); $start = time(); $ok = $lock->acquire(); $delta = time() - $start; @@ -105,7 +105,7 @@ class phpbb_lock_flock_test extends phpbb_test_case { // child // immediately acquire the lock and sleep for 2 s - $lock = new phpbb_lock_flock($path); + $lock = new \phpbb\lock\flock($path); $ok = $lock->acquire(); $this->assertTrue($ok); $this->assertTrue($lock->owns_lock()); diff --git a/tests/log/add_test.php b/tests/log/add_test.php index a5f93232f2..032546f002 100644 --- a/tests/log/add_test.php +++ b/tests/log/add_test.php @@ -23,10 +23,10 @@ class phpbb_log_add_test extends phpbb_database_test_case $db = $this->new_dbal(); $cache = new phpbb_mock_cache; $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $user = $this->getMock('phpbb_user'); - $auth = $this->getMock('phpbb_auth'); + $user = $this->getMock('\phpbb\user'); + $auth = $this->getMock('\phpbb\auth\auth'); - $log = new phpbb_log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); + $log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); $this->assertTrue($log->is_enabled(), 'Initialise failed'); @@ -52,10 +52,10 @@ class phpbb_log_add_test extends phpbb_database_test_case $db = $this->new_dbal(); $cache = new phpbb_mock_cache; $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $user = $this->getMock('phpbb_user'); - $auth = $this->getMock('phpbb_auth'); + $user = $this->getMock('\phpbb\user'); + $auth = $this->getMock('\phpbb\auth\auth'); - $log = new phpbb_log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); + $log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); $mode = 'critical'; $user_id = ANONYMOUS; diff --git a/tests/log/function_add_log_test.php b/tests/log/function_add_log_test.php index 7aa42be6df..e1bcd4acaf 100644 --- a/tests/log/function_add_log_test.php +++ b/tests/log/function_add_log_test.php @@ -157,10 +157,10 @@ class phpbb_log_function_add_log_test extends phpbb_database_test_case $db = $this->new_dbal(); $cache = new phpbb_mock_cache; $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $user = $this->getMock('phpbb_user'); - $auth = $this->getMock('phpbb_auth'); + $user = $this->getMock('\phpbb\user'); + $auth = $this->getMock('\phpbb\auth\auth'); - $phpbb_log = new phpbb_log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); + $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); $user->ip = 'user_ip'; if ($user_id) diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index 6827aaa1b6..017484e8a7 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -306,7 +306,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); // Create auth mock - $auth = $this->getMock('phpbb_auth'); + $auth = $this->getMock('\phpbb\auth\auth'); $acl_get_map = array( array('f_read', 23, true), array('m_', 23, true), @@ -333,7 +333,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 'LOG_INSTALL_INSTALLED' => 'installed: %s', ); - $phpbb_log = new phpbb_log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); + $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); $log = array(); $this->assertEquals($expected_returned, view_log($mode, $log, $log_count, $limit, $offset, $forum_id, $topic_id, $user_id, $limit_days, $sort_by, $keywords)); diff --git a/tests/mock/auth_provider.php b/tests/mock/auth_provider.php index a576ef6b67..734e682ee9 100644 --- a/tests/mock/auth_provider.php +++ b/tests/mock/auth_provider.php @@ -10,7 +10,7 @@ /** * Mock auth provider class with basic functions to help test sessions. */ -class phpbb_mock_auth_provider extends phpbb_auth_provider_base +class phpbb_mock_auth_provider extends \phpbb\auth\provider\base { public function login($username, $password) { diff --git a/tests/mock/cache.php b/tests/mock/cache.php index 440592665a..83bbb8ef30 100644 --- a/tests/mock/cache.php +++ b/tests/mock/cache.php @@ -7,7 +7,7 @@ * */ -class phpbb_mock_cache implements phpbb_cache_driver_interface +class phpbb_mock_cache implements \phpbb\cache\driver\driver_interface { protected $data; @@ -140,7 +140,7 @@ class phpbb_mock_cache implements phpbb_cache_driver_interface /** * {@inheritDoc} */ - public function sql_save(phpbb_db_driver $db, $query, $query_result, $ttl) + public function sql_save(\phpbb\db\driver\driver $db, $query, $query_result, $ttl) { return $query_result; } diff --git a/tests/mock/extension_manager.php b/tests/mock/extension_manager.php index 0d1b6940ca..7049cbdc50 100644 --- a/tests/mock/extension_manager.php +++ b/tests/mock/extension_manager.php @@ -7,19 +7,13 @@ * */ -class phpbb_mock_extension_manager extends phpbb_extension_manager +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->extensions = $extensions; - $this->filesystem = new phpbb_filesystem( - new phpbb_symfony_request( - new phpbb_mock_request() - ), - $this->phpbb_root_path, - $this->php_ext - ); + $this->filesystem = new \phpbb\filesystem(); } } diff --git a/tests/mock/metadata_manager.php b/tests/mock/metadata_manager.php index a7fbf0681c..b6489acfa4 100644 --- a/tests/mock/metadata_manager.php +++ b/tests/mock/metadata_manager.php @@ -7,7 +7,7 @@ * */ -class phpbb_mock_metadata_manager extends phpbb_extension_metadata_manager +class phpbb_mock_metadata_manager extends \phpbb\extension\metadata_manager { public function set_metadata($metadata) { diff --git a/tests/mock/notifications_auth.php b/tests/mock/notifications_auth.php index d960acb81a..2d387d8c00 100644 --- a/tests/mock/notifications_auth.php +++ b/tests/mock/notifications_auth.php @@ -7,7 +7,7 @@ * */ -class phpbb_mock_notifications_auth extends phpbb_auth +class phpbb_mock_notifications_auth extends \phpbb\auth\auth { function acl_get_list($user_id = false, $opts = false, $forum_id = false) { diff --git a/tests/mock/request.php b/tests/mock/request.php index d671621460..60ba725abd 100644 --- a/tests/mock/request.php +++ b/tests/mock/request.php @@ -7,33 +7,33 @@ * */ -class phpbb_mock_request implements phpbb_request_interface +class phpbb_mock_request implements \phpbb\request\request_interface { protected $data; public function __construct($get = array(), $post = array(), $cookie = array(), $server = array(), $request = false, $files = array()) { - $this->data[phpbb_request_interface::GET] = $get; - $this->data[phpbb_request_interface::POST] = $post; - $this->data[phpbb_request_interface::COOKIE] = $cookie; - $this->data[phpbb_request_interface::REQUEST] = ($request === false) ? $post + $get : $request; - $this->data[phpbb_request_interface::SERVER] = $server; - $this->data[phpbb_request_interface::FILES] = $files; + $this->data[\phpbb\request\request_interface::GET] = $get; + $this->data[\phpbb\request\request_interface::POST] = $post; + $this->data[\phpbb\request\request_interface::COOKIE] = $cookie; + $this->data[\phpbb\request\request_interface::REQUEST] = ($request === false) ? $post + $get : $request; + $this->data[\phpbb\request\request_interface::SERVER] = $server; + $this->data[\phpbb\request\request_interface::FILES] = $files; } - public function overwrite($var_name, $value, $super_global = phpbb_request_interface::REQUEST) + public function overwrite($var_name, $value, $super_global = \phpbb\request\request_interface::REQUEST) { $this->data[$super_global][$var_name] = $value; } - public function variable($var_name, $default, $multibyte = false, $super_global = phpbb_request_interface::REQUEST) + public function variable($var_name, $default, $multibyte = false, $super_global = \phpbb\request\request_interface::REQUEST) { return isset($this->data[$super_global][$var_name]) ? $this->data[$super_global][$var_name] : $default; } public function server($var_name, $default = '') { - $super_global = phpbb_request_interface::SERVER; + $super_global = \phpbb\request\request_interface::SERVER; return isset($this->data[$super_global][$var_name]) ? $this->data[$super_global][$var_name] : $default; } @@ -45,16 +45,16 @@ class phpbb_mock_request implements phpbb_request_interface public function file($form_name) { - $super_global = phpbb_request_interface::FILES; + $super_global = \phpbb\request\request_interface::FILES; return isset($this->data[$super_global][$form_name]) ? $this->data[$super_global][$form_name] : array(); } public function is_set_post($name) { - return $this->is_set($name, phpbb_request_interface::POST); + return $this->is_set($name, \phpbb\request\request_interface::POST); } - public function is_set($var, $super_global = phpbb_request_interface::REQUEST) + public function is_set($var, $super_global = \phpbb\request\request_interface::REQUEST) { return isset($this->data[$super_global][$var]); } @@ -69,12 +69,12 @@ class phpbb_mock_request implements phpbb_request_interface return false; } - public function variable_names($super_global = phpbb_request_interface::REQUEST) + public function variable_names($super_global = \phpbb\request\request_interface::REQUEST) { return array_keys($this->data[$super_global]); } - public function get_super_global($super_global = phpbb_request_interface::REQUEST) + public function get_super_global($super_global = \phpbb\request\request_interface::REQUEST) { return $this->data[$super_global]; } @@ -84,10 +84,10 @@ class phpbb_mock_request implements phpbb_request_interface public function set_header($header_name, $value) { $var_name = 'HTTP_' . str_replace('-', '_', strtoupper($header_name)); - $this->data[phpbb_request_interface::SERVER][$var_name] = $value; + $this->data[\phpbb\request\request_interface::SERVER][$var_name] = $value; } - public function merge($super_global = phpbb_request_interface::REQUEST, $values) + public function merge($super_global = \phpbb\request\request_interface::REQUEST, $values) { $this->data[$super_global] = array_merge($this->data[$super_global], $values); } diff --git a/tests/mock/session_testable.php b/tests/mock/session_testable.php index 283f9af192..d81ae3163e 100644 --- a/tests/mock/session_testable.php +++ b/tests/mock/session_testable.php @@ -16,7 +16,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; * test it without warnings about sent headers. This class only stores cookie * data for later verification. */ -class phpbb_mock_session_testable extends phpbb_session +class phpbb_mock_session_testable extends \phpbb\session { private $_cookies = array(); diff --git a/tests/mock/sql_insert_buffer.php b/tests/mock/sql_insert_buffer.php index ba09aa8d7f..aa7c54dddd 100644 --- a/tests/mock/sql_insert_buffer.php +++ b/tests/mock/sql_insert_buffer.php @@ -7,7 +7,7 @@ * */ -class phpbb_mock_sql_insert_buffer extends phpbb_db_sql_insert_buffer +class phpbb_mock_sql_insert_buffer extends \phpbb\db\sql_insert_buffer { public function flush() { diff --git a/tests/notification/base.php b/tests/notification/base.php index 8de162a1fb..549545f01b 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -46,17 +46,17 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case global $db, $config, $user, $auth, $cache, $phpbb_container; $db = $this->db = $this->new_dbal(); - $config = $this->config = new phpbb_config(array( + $config = $this->config = new \phpbb\config\config(array( 'allow_privmsg' => true, 'allow_bookmarks' => true, 'allow_topic_notify' => true, 'allow_forum_notify' => true, )); - $user = $this->user = new phpbb_user(); - $this->user_loader = new phpbb_user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users'); + $user = $this->user = new \phpbb\user(); + $this->user_loader = new \phpbb\user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users'); $auth = $this->auth = new phpbb_mock_notifications_auth(); - $cache = $this->cache = new phpbb_cache_service( - new phpbb_cache_driver_null(), + $cache = $this->cache = new \phpbb\cache\service( + new \phpbb\cache\driver\null(), $this->config, $this->db, $phpbb_root_path, @@ -87,7 +87,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $types = array(); foreach ($this->get_notification_types() as $type) { - $class = $this->build_type('phpbb_notification_type_' . $type); + $class = $this->build_type('phpbb\notification\type\\' . $type); $types[$type] = $class; $this->container->set('notification.type.' . $type, $class); diff --git a/tests/notification/convert_test.php b/tests/notification/convert_test.php index c038020385..ed1fa9b1bf 100644 --- a/tests/notification/convert_test.php +++ b/tests/notification/convert_test.php @@ -25,10 +25,10 @@ class phpbb_notification_convert_test extends phpbb_database_test_case $this->db = $this->new_dbal(); - $this->migration = new phpbb_db_migration_data_310_notification_options_reconvert( - new phpbb_config(array()), + $this->migration = new \phpbb\db\migration\data\v310\notification_options_reconvert( + new \phpbb\config\config(array()), $this->db, - new phpbb_db_tools($this->db), + new \phpbb\db\tools($this->db), $phpbb_root_path, $phpEx, 'phpbb_' diff --git a/tests/notification/ext/test/notification/type/test.php b/tests/notification/ext/test/notification/type/test.php index 0d0c584e0d..cdb921ca3b 100644 --- a/tests/notification/ext/test/notification/type/test.php +++ b/tests/notification/ext/test/notification/type/test.php @@ -7,6 +7,8 @@ * */ +namespace phpbb\notification\type; + /** * @ignore */ @@ -15,7 +17,7 @@ if (!defined('IN_PHPBB')) exit; } -class phpbb_notification_type_test extends phpbb_notification_type_base +class test extends \phpbb\notification\type\base { public function get_type() { diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php index 368e4ae973..b812fff8f8 100644 --- a/tests/notification/group_request_test.php +++ b/tests/notification/group_request_test.php @@ -37,17 +37,17 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas set_config(false, false, false, $this->config); - $this->container->set('groupposition.legend', new phpbb_groupposition_legend( + $this->container->set('groupposition.legend', new \phpbb\groupposition\legend( $this->db, $this->user )); - $this->container->set('groupposition.teampage', new phpbb_groupposition_teampage( + $this->container->set('groupposition.teampage', new \phpbb\groupposition\teampage( $this->db, $this->user, $this->cache->get_driver() )); $phpbb_dispatcher = new phpbb_mock_event_dispatcher; - $phpbb_log = new phpbb_log_null(); + $phpbb_log = new \phpbb\log\null(); // Now on to the actual test diff --git a/tests/notification/manager_helper.php b/tests/notification/manager_helper.php index 7a794f922f..731dd00b7a 100644 --- a/tests/notification/manager_helper.php +++ b/tests/notification/manager_helper.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) * Notifications service class * @package notifications */ -class phpbb_notification_manager_helper extends phpbb_notification_manager +class phpbb_notification_manager_helper extends \phpbb\notification\manager { public function set_var($name, $value) { @@ -40,7 +40,7 @@ class phpbb_notification_manager_helper extends phpbb_notification_manager */ public function get_item_type_class($item_type, $data = array()) { - $item_type = 'phpbb_notification_type_' . $item_type; + $item_type = 'phpbb\notification\type\\' . $item_type; $item = new $item_type($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notification_types_table, $this->notifications_table, $this->user_notifications_table); @@ -56,7 +56,7 @@ class phpbb_notification_manager_helper extends phpbb_notification_manager */ public function get_method_class($method_name) { - $method_name = 'phpbb_notification_method_' . $method_name; + $method_name = 'phpbb\notification\method\\' . $method_name; $method = new $method_name($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notification_types_table, $this->notifications_table, $this->user_notifications_table); diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 4e564ce23c..8597c626a4 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -53,7 +53,7 @@ class phpbb_notification_submit_post_base extends phpbb_database_test_case $db = $this->db; // Auth - $auth = $this->getMock('phpbb_auth'); + $auth = $this->getMock('\phpbb\auth\auth'); $auth->expects($this->any()) ->method('acl_get') ->with($this->stringContains('_'), @@ -65,12 +65,12 @@ class phpbb_notification_submit_post_base extends phpbb_database_test_case ))); // Config - $config = new phpbb_config(array('num_topics' => 1,'num_posts' => 1,)); + $config = new \phpbb\config\config(array('num_topics' => 1,'num_posts' => 1,)); set_config(null, null, null, $config); set_config_count(null, null, null, $config); - $cache = new phpbb_cache_service( - new phpbb_cache_driver_null(), + $cache = new \phpbb\cache\service( + new \phpbb\cache\driver\null(), $config, $db, $phpbb_root_path, @@ -81,7 +81,7 @@ class phpbb_notification_submit_post_base extends phpbb_database_test_case $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); // User - $user = $this->getMock('phpbb_user'); + $user = $this->getMock('\phpbb\user'); $user->ip = ''; $user->data = array( 'user_id' => 2, @@ -91,21 +91,21 @@ class phpbb_notification_submit_post_base extends phpbb_database_test_case ); // Request - $type_cast_helper = $this->getMock('phpbb_request_type_cast_helper_interface'); - $request = $this->getMock('phpbb_request'); + $type_cast_helper = $this->getMock('\phpbb\request\type_cast_helper_interface'); + $request = $this->getMock('\phpbb\request\request'); // Container $phpbb_container = new phpbb_mock_container_builder(); - $phpbb_container->set('content.visibility', new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); + $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE)); - $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 Types $notification_types = array('quote', 'bookmark', 'post', 'post_in_queue', 'topic', 'approve_topic', 'approve_post'); $notification_types_array = array(); foreach ($notification_types as $type) { - $class_name = 'phpbb_notification_type_' . $type; + $class_name = '\phpbb\notification\type\\' . $type; $class = new $class_name( $user_loader, $db, $cache->get_driver(), $user, $auth, $config, $phpbb_root_path, $phpEx, @@ -117,7 +117,7 @@ class phpbb_notification_submit_post_base extends phpbb_database_test_case } // Notification Manager - $phpbb_notifications = new phpbb_notification_manager($notification_types_array, array(), + $phpbb_notifications = new \phpbb\notification\manager($notification_types_array, array(), $phpbb_container, $user_loader, $db, $cache, $user, $phpbb_root_path, $phpEx, NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE); diff --git a/tests/pagination/generate_template_test.php b/tests/pagination/generate_template_test.php new file mode 100644 index 0000000000..587a948583 --- /dev/null +++ b/tests/pagination/generate_template_test.php @@ -0,0 +1,111 @@ +<?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'; +require_once dirname(__FILE__) . '/../template/template_test_case.php'; + +class phpbb_pagination_generate_template_test extends phpbb_template_template_test_case +{ + protected $test_path = 'tests/pagination'; + + public function phpbb_generate_template_pagination_data() + { + return array( + array( + 'page.php', + 'start', + 95, + 10, + 10, + 'pagination + :previous::page.php + :else:1:page.php + :current:2:page.php?start=10 + :else:3:page.php?start=20 + :else:4:page.php?start=30 + :else:5:page.php?start=40 + :ellipsis:9:page.php?start=80 + :else:10:page.php?start=90 + :next::page.php?start=20 + :u_prev:page.php + :u_next:page.php?start=20', + ), + array( + 'page.php', + 'start', + 95, + 10, + 20, + 'pagination + :previous::page.php?start=10 + :else:1:page.php + :else:2:page.php?start=10 + :current:3:page.php?start=20 + :else:4:page.php?start=30 + :else:5:page.php?start=40 + :else:6:page.php?start=50 + :ellipsis:9:page.php?start=80 + :else:10:page.php?start=90 + :next::page.php?start=30 + :u_prev:page.php?start=10 + :u_next:page.php?start=30', + ), + array( + 'test/page/%d', + '/page/%d', + 95, + 10, + 10, + 'pagination + :previous::test + :else:1:test + :current:2:test/page/2 + :else:3:test/page/3 + :else:4:test/page/4 + :else:5:test/page/5 + :ellipsis:9:test/page/9 + :else:10:test/page/10 + :next::test/page/3 + :u_prev:test + :u_next:test/page/3', + ), + array( + 'test/page/%d', + '/page/%d', + 95, + 10, + 20, + 'pagination + :previous::test/page/2 + :else:1:test + :else:2:test/page/2 + :current:3:test/page/3 + :else:4:test/page/4 + :else:5:test/page/5 + :else:6:test/page/6 + :ellipsis:9:test/page/9 + :else:10:test/page/10 + :next::test/page/4 + :u_prev:test/page/2 + :u_next:test/page/4', + ), + ); + } + + /** + * @dataProvider phpbb_generate_template_pagination_data + */ + public function test_phpbb_generate_template_pagination($base_url, $start_name, $num_items, $per_page, $start_item, $expect) + { + phpbb_generate_template_pagination($this->template, $base_url, 'pagination', $start_name, $num_items, $per_page, $start_item); + $this->template->set_filenames(array('test' => 'pagination.html')); + + $this->assertEquals(str_replace("\t", '', $expect), $this->display('test')); + } +} diff --git a/tests/pagination/templates/pagination.html b/tests/pagination/templates/pagination.html new file mode 100644 index 0000000000..7f2a329804 --- /dev/null +++ b/tests/pagination/templates/pagination.html @@ -0,0 +1,12 @@ +pagination +<!-- BEGIN pagination --> +<!-- IF pagination.S_IS_PREV -->:previous:{pagination.PAGE_NUMBER}:{pagination.PAGE_URL} +<!-- ELSEIF pagination.S_IS_CURRENT -->:current:{pagination.PAGE_NUMBER}:{pagination.PAGE_URL} +<!-- ELSEIF pagination.S_IS_ELLIPSIS -->:ellipsis:{pagination.PAGE_NUMBER}:{pagination.PAGE_URL} +<!-- ELSEIF pagination.S_IS_NEXT -->:next:{pagination.PAGE_NUMBER}:{pagination.PAGE_URL} +<!-- ELSE -->:else:{pagination.PAGE_NUMBER}:{pagination.PAGE_URL} +<!-- ENDIF --> +<!-- END pagination --> +<!-- IF U_PREVIOUS_PAGE -->:u_prev:{U_PREVIOUS_PAGE}<!-- ENDIF --> + +<!-- IF U_NEXT_PAGE -->:u_next:{U_NEXT_PAGE}<!-- ENDIF --> diff --git a/tests/filesystem/web_root_path_test.php b/tests/path_helper/web_root_path_test.php index ae59d4f709..938b58892b 100644 --- a/tests/filesystem/web_root_path_test.php +++ b/tests/path_helper/web_root_path_test.php @@ -7,9 +7,9 @@ * */ -class phpbb_filesystem_web_root_path_test extends phpbb_test_case +class phpbb_path_helper_web_root_path_test extends phpbb_test_case { - protected $filesystem; + protected $path_helper; protected $phpbb_root_path = ''; public function setUp() @@ -18,10 +18,11 @@ class phpbb_filesystem_web_root_path_test extends phpbb_test_case $this->set_phpbb_root_path(); - $this->filesystem = new phpbb_filesystem( - new phpbb_symfony_request( + $this->path_helper = new \phpbb\path_helper( + new \phpbb\symfony_request( new phpbb_mock_request() ), + new \phpbb\filesystem(), $this->phpbb_root_path, 'php' ); @@ -43,7 +44,7 @@ class phpbb_filesystem_web_root_path_test extends phpbb_test_case public function test_get_web_root_path() { // Symfony Request = null, so always should return phpbb_root_path - $this->assertEquals($this->phpbb_root_path, $this->filesystem->get_web_root_path()); + $this->assertEquals($this->phpbb_root_path, $this->path_helper->get_web_root_path()); } public function basic_update_web_root_path_data() @@ -71,7 +72,7 @@ class phpbb_filesystem_web_root_path_test extends phpbb_test_case */ public function test_basic_update_web_root_path($input, $expected) { - $this->assertEquals($expected, $this->filesystem->update_web_root_path($input, $symfony_request)); + $this->assertEquals($expected, $this->path_helper->update_web_root_path($input, $symfony_request)); } public function update_web_root_path_data() @@ -118,7 +119,7 @@ class phpbb_filesystem_web_root_path_test extends phpbb_test_case */ public function test_update_web_root_path($input, $expected, $getPathInfo, $getRequestUri = null, $getScriptName = null) { - $symfony_request = $this->getMock("phpbb_symfony_request", array(), array( + $symfony_request = $this->getMock("\phpbb\symfony_request", array(), array( new phpbb_mock_request(), )); $symfony_request->expects($this->any()) @@ -131,12 +132,13 @@ class phpbb_filesystem_web_root_path_test extends phpbb_test_case ->method('getScriptName') ->will($this->returnValue($getScriptName)); - $filesystem = new phpbb_filesystem( + $path_helper = new \phpbb\path_helper( $symfony_request, + new \phpbb\filesystem(), $this->phpbb_root_path, 'php' ); - $this->assertEquals($expected, $filesystem->update_web_root_path($input, $symfony_request)); + $this->assertEquals($expected, $path_helper->update_web_root_path($input, $symfony_request)); } } diff --git a/tests/request/deactivated_super_global_test.php b/tests/request/deactivated_super_global_test.php index 2e19928a5a..d28bd87eec 100644 --- a/tests/request/deactivated_super_global_test.php +++ b/tests/request/deactivated_super_global_test.php @@ -16,7 +16,7 @@ class phpbb_deactivated_super_global_test extends phpbb_test_case public function test_write_triggers_error() { $this->setExpectedTriggerError(E_USER_ERROR); - $obj = new phpbb_request_deactivated_super_global($this->getMock('phpbb_request_interface'), 'obj', phpbb_request_interface::POST); + $obj = new \phpbb\request\deactivated_super_global($this->getMock('\phpbb\request\request_interface'), 'obj', \phpbb\request\request_interface::POST); $obj->offsetSet(0, 0); } } diff --git a/tests/request/request_test.php b/tests/request/request_test.php index 52c21abd2a..a25792e051 100644 --- a/tests/request/request_test.php +++ b/tests/request/request_test.php @@ -33,8 +33,8 @@ class phpbb_request_test extends phpbb_test_case $_SERVER['HTTP_ACCEPT'] = 'application/json'; $_SERVER['HTTP_SOMEVAR'] = '<value>'; - $this->type_cast_helper = $this->getMock('phpbb_request_type_cast_helper_interface'); - $this->request = new phpbb_request($this->type_cast_helper); + $this->type_cast_helper = $this->getMock('\phpbb\request\type_cast_helper_interface'); + $this->request = new \phpbb\request\request($this->type_cast_helper); } public function test_toggle_super_globals() @@ -135,7 +135,7 @@ class phpbb_request_test extends phpbb_test_case { $this->request->enable_super_globals(); $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; - $this->request = new phpbb_request($this->type_cast_helper); + $this->request = new \phpbb\request\request($this->type_cast_helper); $this->assertTrue($this->request->is_ajax()); } @@ -146,7 +146,7 @@ class phpbb_request_test extends phpbb_test_case $this->request->enable_super_globals(); $_SERVER['HTTPS'] = 'on'; - $this->request = new phpbb_request($this->type_cast_helper); + $this->request = new \phpbb\request\request($this->type_cast_helper); $this->assertTrue($this->request->is_secure()); } diff --git a/tests/request/request_var_test.php b/tests/request/request_var_test.php index 0e85d4694b..d126fe1e8b 100644 --- a/tests/request/request_var_test.php +++ b/tests/request/request_var_test.php @@ -90,7 +90,7 @@ class phpbb_request_var_test extends phpbb_test_case { $this->unset_variables('var'); - // cannot set $_REQUEST directly because in phpbb_request implementation + // cannot set $_REQUEST directly because in \phpbb\request\request implementation // $_REQUEST = $_POST + $_GET $_POST['var'] = array( 0 => array( diff --git a/tests/request/type_cast_helper_test.php b/tests/request/type_cast_helper_test.php index f41db005af..98f4538c08 100644 --- a/tests/request/type_cast_helper_test.php +++ b/tests/request/type_cast_helper_test.php @@ -16,7 +16,7 @@ class phpbb_type_cast_helper_test extends phpbb_test_case protected function setUp() { - $this->type_cast_helper = new phpbb_request_type_cast_helper(); + $this->type_cast_helper = new \phpbb\request\type_cast_helper(); } public function test_addslashes_recursively() diff --git a/tests/search/mysql_test.php b/tests/search/mysql_test.php index 3ad15bd806..c08484c78d 100644 --- a/tests/search/mysql_test.php +++ b/tests/search/mysql_test.php @@ -34,7 +34,7 @@ class phpbb_search_mysql_test extends phpbb_search_common_test_case $this->db = $this->new_dbal(); $error = null; - $class = self::get_search_wrapper('phpbb_search_fulltext_mysql'); + $class = self::get_search_wrapper('\phpbb\search\fulltext_mysql'); $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user); } } diff --git a/tests/search/native_test.php b/tests/search/native_test.php index 4a2c210013..18c6df2445 100644 --- a/tests/search/native_test.php +++ b/tests/search/native_test.php @@ -30,7 +30,7 @@ class phpbb_search_native_test extends phpbb_search_test_case $this->db = $this->new_dbal(); $error = null; - $class = self::get_search_wrapper('phpbb_search_fulltext_native'); + $class = self::get_search_wrapper('\phpbb\search\fulltext_native'); $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user); } diff --git a/tests/search/postgres_test.php b/tests/search/postgres_test.php index 923af6f854..a59f5abc7d 100644 --- a/tests/search/postgres_test.php +++ b/tests/search/postgres_test.php @@ -34,7 +34,7 @@ class phpbb_search_postgres_test extends phpbb_search_common_test_case $this->db = $this->new_dbal(); $error = null; - $class = self::get_search_wrapper('phpbb_search_fulltext_postgres'); + $class = self::get_search_wrapper('\phpbb\search\fulltext_postgres'); $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user); } } diff --git a/tests/security/base.php b/tests/security/base.php index c7dbbb550a..26f267745c 100644 --- a/tests/security/base.php +++ b/tests/security/base.php @@ -55,13 +55,13 @@ abstract class phpbb_security_test_base extends phpbb_test_case $phpbb_filesystem = new phpbb_filesystem($symfony_request, $phpbb_root_path, $phpEx); // Set no user and trick a bit to circumvent errors - $user = new phpbb_user(); + $user = new \phpbb\user(); $user->lang = true; $user->browser = $server['HTTP_USER_AGENT']; $user->referer = ''; $user->forwarded_for = ''; $user->host = $server['HTTP_HOST']; - $user->page = phpbb_session::extract_current_page($phpbb_root_path); + $user->page = \phpbb\session::extract_current_page($phpbb_root_path); } protected function tearDown() diff --git a/tests/security/extract_current_page_test.php b/tests/security/extract_current_page_test.php index 2c69e7955b..a7560f0d15 100644 --- a/tests/security/extract_current_page_test.php +++ b/tests/security/extract_current_page_test.php @@ -72,7 +72,7 @@ class phpbb_security_extract_current_page_test extends phpbb_security_test_base ->method('getPathInfo') ->will($this->returnValue('/')); - $result = phpbb_session::extract_current_page('./'); + $result = \phpbb\session::extract_current_page('./'); $label = 'Running extract_current_page on ' . $query_string . ' with REQUEST_URI filled.'; $this->assertEquals($expected, $result['query_string'], $label); diff --git a/tests/security/hash_test.php b/tests/security/hash_test.php index 0c2580c19b..e226365ef3 100644 --- a/tests/security/hash_test.php +++ b/tests/security/hash_test.php @@ -17,5 +17,13 @@ class phpbb_security_hash_test extends phpbb_test_case $this->assertTrue(phpbb_check_hash('test', '$P$9isfrtKXWqrz8PvztXlL3.daw4U0zI1')); $this->assertFalse(phpbb_check_hash('foo', '$H$9isfrtKXWqrz8PvztXlL3.daw4U0zI1')); } + + public function test_check_hash_with_large_input() + { + // 16 MB password, should be rejected quite fast + $start_time = time(); + $this->assertFalse(phpbb_check_hash(str_repeat('a', 1024 * 1024 * 16), '$H$9isfrtKXWqrz8PvztXlL3.daw4U0zI1')); + $this->assertLessThanOrEqual(5, time() - $start_time); + } } diff --git a/tests/session/check_ban_test.php b/tests/session/check_ban_test.php index 8d6c9a866d..3f13b9f216 100644 --- a/tests/session/check_ban_test.php +++ b/tests/session/check_ban_test.php @@ -43,8 +43,8 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case // Change the global cache object for this test because // the mock cache object does not hit the database as is needed // for this test. - $cache = new phpbb_cache_service( - new phpbb_cache_driver_file(), + $cache = new \phpbb\cache\service( + new \phpbb\cache\driver\file(), $config, $this->db, $phpbb_root_path, diff --git a/tests/session/testable_facade.php b/tests/session/testable_facade.php index e9d16999ce..2600a46cc4 100644 --- a/tests/session/testable_facade.php +++ b/tests/session/testable_facade.php @@ -14,11 +14,11 @@ require_once dirname(__FILE__) . '/../../phpBB/phpbb/session.php'; * This class exists to expose session.php's functions in a more testable way. * * Since many functions in session.php have global variables inside the function, - * this exposes those functions through a testable facade that uses - * testable_factory's mock global variables to modify global variables used in + * this exposes those functions through a testable facade that uses + * testable_factory's mock global variables to modify global variables used in * the functions. * - * This is using the facade pattern to provide a testable "front" to the + * This is using the facade pattern to provide a testable "front" to the * functions in sessions.php. * */ @@ -43,8 +43,8 @@ class phpbb_session_testable_facade global $config, $request; $config['server_name'] = $server_name_config; $config['cookie_domain'] = $cookie_domain_config; - $request->overwrite('SERVER_NAME', $host, phpbb_request_interface::SERVER); - $request->overwrite('Host', $host, phpbb_request_interface::SERVER); + $request->overwrite('SERVER_NAME', $host, \phpbb\request\request_interface::SERVER); + $request->overwrite('Host', $host, \phpbb\request\request_interface::SERVER); // Note: There is a php_uname function used as a fallthrough // that this function doesn't override return $session->extract_current_hostname(); @@ -120,7 +120,7 @@ class phpbb_session_testable_facade $session->host = $host; $config['force_server_vars'] = $force_server_vars; $config['server_name'] = $server_name; - $request->overwrite('SERVER_PORT', $server_port, phpbb_request_interface::SERVER); + $request->overwrite('SERVER_PORT', $server_port, \phpbb\request\request_interface::SERVER); return $session->validate_referer($check_script_path); } } diff --git a/tests/session/testable_factory.php b/tests/session/testable_factory.php index 8733ce15ef..a58e208efc 100644 --- a/tests/session/testable_factory.php +++ b/tests/session/testable_factory.php @@ -63,10 +63,10 @@ class phpbb_session_testable_factory /** * Retrieve the configured session class instance * - * @param phpbb_db_driver $dbal The database connection to use for session data + * @param \phpbb\db\driver\driver $dbal The database connection to use for session data * @return phpbb_mock_session_testable A session instance */ - public function get_session(phpbb_db_driver $dbal) + public function get_session(\phpbb\db\driver\driver $dbal) { // set up all the global variables used by session global $SID, $_SID, $db, $config, $cache, $request, $phpbb_container; @@ -79,7 +79,7 @@ class phpbb_session_testable_factory ); request_var(null, null, null, null, $request); - $config = $this->config = new phpbb_config($this->get_config_data()); + $config = $this->config = new \phpbb\config\config($this->get_config_data()); set_config(null, null, null, $config); $db = $dbal; diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php index 58691a36da..41e00e86a7 100644 --- a/tests/template/template_events_test.php +++ b/tests/template/template_events_test.php @@ -110,20 +110,21 @@ Zeta test event in all', global $phpbb_root_path, $phpEx, $user; $defaults = $this->config_defaults(); - $config = new phpbb_config(array_merge($defaults, $new_config)); + $config = new \phpbb\config\config(array_merge($defaults, $new_config)); $this->template_path = dirname(__FILE__) . "/datasets/$dataset/styles/silver/template"; $this->extension_manager = new phpbb_mock_filesystem_extension_manager( dirname(__FILE__) . "/datasets/$dataset/" ); - $phpbb_filesystem = new phpbb_filesystem( - new phpbb_symfony_request( + $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($phpbb_filesystem, $config, $user, new phpbb_template_context, $this->extension_manager); + $this->template = new \phpbb\template\twig\twig($path_helper, $config, $user, new \phpbb\template\context, $this->extension_manager); $this->template->set_custom_style(((!empty($style_names)) ? $style_names : 'silver'), array($this->template_path)); } } diff --git a/tests/template/template_includecss_test.php b/tests/template/template_includecss_test.php index c00aa8e9bb..7424af0c93 100644 --- a/tests/template/template_includecss_test.php +++ b/tests/template/template_includecss_test.php @@ -18,8 +18,8 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te // Prepare correct result $scripts = array( - '<link href="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/child_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />', - '<link href="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/parent_templates/parent_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />', + '<link href="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/child_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />', + '<link href="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/parent_templates/parent_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />', ); // Run test diff --git a/tests/template/template_includejs_test.php b/tests/template/template_includejs_test.php index 2faeb5fcaa..ab0f4b9ca1 100644 --- a/tests/template/template_includejs_test.php +++ b/tests/template/template_includejs_test.php @@ -24,51 +24,51 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes */ array( array('TEST' => 1), - '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/parent_and_child.js?assets_version=1"></script>', + '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/parent_and_child.js?assets_version=1"></script>', ), array( array('TEST' => 2), - '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/parent_and_child.js?assets_version=0"></script>', + '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/parent_and_child.js?assets_version=0"></script>', ), array( array('TEST' => 3), - '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/parent_and_child.js?test=1&assets_version=0"></script>', + '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/parent_and_child.js?test=1&assets_version=0"></script>', ), array( array('TEST' => 4), - '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/parent_and_child.js?test=1&assets_version=0"></script>', + '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/parent_and_child.js?test=1&assets_version=0"></script>', ), array( array('TEST' => 6), - '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/parent_templates/parent_only.js?assets_version=1"></script>', + '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/parent_templates/parent_only.js?assets_version=1"></script>', ), array( array('TEST' => 7), - '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/child_only.js?assets_version=1"></script>', + '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/child_only.js?assets_version=1"></script>', ), array( array('TEST' => 8), - '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/subdir/parent_only.js?assets_version=1"></script>', + '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/subdir/parent_only.js?assets_version=1"></script>', ), array( array('TEST' => 9), - '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/subdir/subsubdir/parent_only.js?assets_version=1"></script>', + '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/subdir/subsubdir/parent_only.js?assets_version=1"></script>', ), array( array('TEST' => 10), - '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/subdir/parent_only.js?assets_version=1"></script>', + '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/subdir/parent_only.js?assets_version=1"></script>', ), array( array('TEST' => 11), - '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/child_only.js?test1=1&test2=2&assets_version=1#test3"></script>', + '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/child_only.js?test1=1&test2=2&assets_version=1#test3"></script>', ), array( array('TEST' => 12), - '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/parent_templates/parent_only.js?test1=1&test2=2&assets_version=1#test3"></script>', + '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/parent_templates/parent_only.js?test1=1&test2=2&assets_version=1#test3"></script>', ), array( array('TEST' => 14), - '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/parent_templates/parent_only.js?test1="&assets_version=1#test3"></script>', + '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/parent_templates/parent_only.js?test1="&assets_version=1#test3"></script>', ), array( array('TEST' => 15), @@ -84,7 +84,7 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes ), array( array('TEST' => 18), - '<script type="text/javascript" src="' . $this->phpbb_filesystem->get_web_root_path() . 'tests/template/templates/parent_and_child.js?test=1&test2=0&assets_version=1"></script>', + '<script type="text/javascript" src="' . $this->phpbb_path_helper->get_web_root_path() . 'tests/template/templates/parent_and_child.js?test=1&test2=0&assets_version=1"></script>', ), ); } diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 2cca20f4c2..39eb08ab79 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -158,7 +158,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), array('test_loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())), array(), - "xyz\nabc\n\$VALUE == 'abc'\n(\$VALUE == 'abc')\n!\$DOESNT_EXIST\n(!\$DOESNT_EXIST)\nabc\nbar\nbar\nabc\ntest!@#$%^&*()_-=+{}[]:;\",<.>/?[]|foobar|", + "xyz\nabc\n\$VALUE == 'abc'\n(\$VALUE == 'abc')\n((\$VALUE == 'abc'))\n!\$DOESNT_EXIST\n(!\$DOESNT_EXIST)\nabc\nbar\nbar\nabc\ntest!@#$%^&*()_-=+{}[]:;\",<.>/?[]|foobar|", ), array( 'define_advanced.html', diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index 8151e15b24..c75b1e5065 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -60,19 +60,20 @@ class phpbb_template_template_test_case extends phpbb_test_case global $phpbb_root_path, $phpEx; $defaults = $this->config_defaults(); - $config = new phpbb_config(array_merge($defaults, $new_config)); - $this->user = new phpbb_user; + $config = new \phpbb\config\config(array_merge($defaults, $new_config)); + $this->user = new \phpbb\user; - $phpbb_filesystem = new phpbb_filesystem( - new phpbb_symfony_request( + $path_helper = new \phpbb\path_helper( + new \phpbb\symfony_request( new phpbb_mock_request() ), + new \phpbb\filesystem(), $phpbb_root_path, $phpEx ); $this->template_path = $this->test_path . '/templates'; - $this->template = new phpbb_template_twig($phpbb_filesystem, $config, $this->user, new phpbb_template_context()); + $this->template = new \phpbb\template\twig\twig($path_helper, $config, $this->user, new \phpbb\template\context()); $this->template->set_custom_style('tests', $this->template_path); } diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php index c7bd03a3c7..e614c42d73 100644 --- a/tests/template/template_test_case_with_tree.php +++ b/tests/template/template_test_case_with_tree.php @@ -16,19 +16,20 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat global $phpbb_root_path, $phpEx, $user; $defaults = $this->config_defaults(); - $config = new phpbb_config(array_merge($defaults, $new_config)); + $config = new \phpbb\config\config(array_merge($defaults, $new_config)); - $this->phpbb_filesystem = new phpbb_filesystem( - new phpbb_symfony_request( + $this->phpbb_path_helper = new \phpbb\path_helper( + new \phpbb\symfony_request( new phpbb_mock_request() ), + new \phpbb\filesystem(), $phpbb_root_path, $phpEx ); $this->template_path = $this->test_path . '/templates'; $this->parent_template_path = $this->test_path . '/parent_templates'; - $this->template = new phpbb_template_twig($this->phpbb_filesystem, $config, $user, new phpbb_template_context()); + $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $config, $user, new phpbb\template\context()); $this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path)); } } diff --git a/tests/template/templates/define.html b/tests/template/templates/define.html index bc20c02ed1..e7ce7f7def 100644 --- a/tests/template/templates/define.html +++ b/tests/template/templates/define.html @@ -10,6 +10,9 @@ $VALUE == 'abc' <!-- IF ($VALUE == 'abc') --> ($VALUE == 'abc') <!-- ENDIF --> +<!-- IF (($VALUE == 'abc')) --> +(($VALUE == 'abc')) +<!-- ENDIF --> <!-- IF !$DOESNT_EXIST --> !$DOESNT_EXIST <!-- ENDIF --> diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index c72ea5f765..4c2e9ff600 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -82,7 +82,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test $db_config = $this->get_database_config(); // Firebird requires table and column names to be uppercase - if ($db_config['dbms'] == 'phpbb_db_driver_firebird') + if ($db_config['dbms'] == 'phpbb\db\driver\firebird') { $xml_data = file_get_contents($path); $xml_data = preg_replace_callback('/(?:(<table name="))([a-z_]+)(?:(">))/', 'phpbb_database_test_case::to_upper', $xml_data); diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index 9d2cfebd29..af9bd22662 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -108,7 +108,7 @@ class phpbb_database_test_connection_manager // These require different connection strings on the phpBB side than they do in PDO // so you must provide a DSN string for ODBC separately - if (!empty($this->config['custom_dsn']) && ($this->config['dbms'] == 'phpbb_db_driver_mssql' || $this->config['dbms'] == 'phpbb_db_driver_firebird')) + if (!empty($this->config['custom_dsn']) && ($this->config['dbms'] == 'phpbb\db\driver\mssql' || $this->config['dbms'] == 'phpbb\db\driver\firebird')) { $dsn = 'odbc:' . $this->config['custom_dsn']; } @@ -117,12 +117,12 @@ class phpbb_database_test_connection_manager { switch ($this->config['dbms']) { - case 'phpbb_db_driver_mssql': - case 'phpbb_db_driver_mssql_odbc': + case 'phpbb\db\driver\mssql': + case 'phpbb\db\driver\mssql_odbc': $this->pdo = new phpbb_database_connection_odbc_pdo_wrapper('mssql', 0, $dsn, $this->config['dbuser'], $this->config['dbpasswd']); break; - case 'phpbb_db_driver_firebird': + case 'phpbb\db\driver\firebird': if (!empty($this->config['custom_dsn'])) { $this->pdo = new phpbb_database_connection_odbc_pdo_wrapper('firebird', 0, $dsn, $this->config['dbuser'], $this->config['dbpasswd']); @@ -145,8 +145,8 @@ class phpbb_database_test_connection_manager switch ($this->config['dbms']) { - case 'phpbb_db_driver_mysql': - case 'phpbb_db_driver_mysqli': + case 'phpbb\db\driver\mysql': + case 'phpbb\db\driver\mysqli': $this->pdo->exec('SET NAMES utf8'); /* @@ -187,8 +187,8 @@ class phpbb_database_test_connection_manager { switch ($this->config['dbms']) { - case 'phpbb_db_driver_sqlite': - case 'phpbb_db_driver_firebird': + case 'phpbb\db\driver\sqlite': + case 'phpbb\db\driver\firebird': $this->connect(); // Drop all of the tables foreach ($this->get_tables() as $table) @@ -198,7 +198,7 @@ class phpbb_database_test_connection_manager $this->purge_extras(); break; - case 'phpbb_db_driver_oracle': + case 'phpbb\db\driver\oracle': $this->connect(); // Drop all of the tables foreach ($this->get_tables() as $table) @@ -208,7 +208,7 @@ class phpbb_database_test_connection_manager $this->purge_extras(); break; - case 'phpbb_db_driver_postgres': + case 'phpbb\db\driver\postgres': $this->connect(); // Drop all of the tables foreach ($this->get_tables() as $table) @@ -258,38 +258,38 @@ class phpbb_database_test_connection_manager switch ($this->config['dbms']) { - case 'phpbb_db_driver_mysql': - case 'phpbb_db_driver_mysqli': + case 'phpbb\db\driver\mysql': + case 'phpbb\db\driver\mysqli': $sql = 'SHOW TABLES'; break; - case 'phpbb_db_driver_sqlite': + case 'phpbb\db\driver\sqlite': $sql = 'SELECT name FROM sqlite_master WHERE type = "table"'; break; - case 'phpbb_db_driver_mssql': - case 'phpbb_db_driver_mssql_odbc': - case 'phpbb_db_driver_mssqlnative': + case 'phpbb\db\driver\mssql': + case 'phpbb\db\driver\mssql_odbc': + case 'phpbb\db\driver\mssqlnative': $sql = "SELECT name FROM sysobjects WHERE type='U'"; break; - case 'phpbb_db_driver_postgres': + case 'phpbb\db\driver\postgres': $sql = 'SELECT relname FROM pg_stat_user_tables'; break; - case 'phpbb_db_driver_firebird': + case 'phpbb\db\driver\firebird': $sql = 'SELECT rdb$relation_name FROM rdb$relations WHERE rdb$view_source is null AND rdb$system_flag = 0'; break; - case 'phpbb_db_driver_oracle': + case 'phpbb\db\driver\oracle': $sql = 'SELECT table_name FROM USER_TABLES'; break; @@ -325,7 +325,7 @@ class phpbb_database_test_connection_manager { $schema = $this->dbms['SCHEMA']; - if ($this->config['dbms'] == 'phpbb_db_driver_mysql') + if ($this->config['dbms'] == 'phpbb\db\driver\mysql') { $sth = $this->pdo->query('SELECT VERSION() AS version'); $row = $sth->fetch(PDO::FETCH_ASSOC); @@ -359,47 +359,47 @@ class phpbb_database_test_connection_manager protected function get_dbms_data($dbms) { $available_dbms = array( - 'phpbb_db_driver_firebird' => array( + 'phpbb\db\driver\firebird' => array( 'SCHEMA' => 'firebird', 'DELIM' => ';;', 'PDO' => 'firebird', ), - 'phpbb_db_driver_mysqli' => array( + 'phpbb\db\driver\mysqli' => array( 'SCHEMA' => 'mysql_41', 'DELIM' => ';', 'PDO' => 'mysql', ), - 'phpbb_db_driver_mysql' => array( + 'phpbb\db\driver\mysql' => array( 'SCHEMA' => 'mysql', 'DELIM' => ';', 'PDO' => 'mysql', ), - 'phpbb_db_driver_mssql' => array( + 'phpbb\db\driver\mssql' => array( 'SCHEMA' => 'mssql', 'DELIM' => 'GO', 'PDO' => 'odbc', ), - 'phpbb_db_driver_mssql_odbc'=> array( + 'phpbb\db\driver\mssql_odbc'=> array( 'SCHEMA' => 'mssql', 'DELIM' => 'GO', 'PDO' => 'odbc', ), - 'phpbb_db_driver_mssqlnative' => array( + 'phpbb\db\driver\mssqlnative' => array( 'SCHEMA' => 'mssql', 'DELIM' => 'GO', 'PDO' => 'sqlsrv', ), - 'phpbb_db_driver_oracle' => array( + 'phpbb\db\driver\oracle' => array( 'SCHEMA' => 'oracle', 'DELIM' => '/', 'PDO' => 'oci', ), - 'phpbb_db_driver_postgres' => array( + 'phpbb\db\driver\postgres' => array( 'SCHEMA' => 'postgres', 'DELIM' => ';', 'PDO' => 'pgsql', ), - 'phpbb_db_driver_sqlite' => array( + 'phpbb\db\driver\sqlite' => array( 'SCHEMA' => 'sqlite', 'DELIM' => ';', 'PDO' => 'sqlite2', @@ -428,7 +428,7 @@ class phpbb_database_test_connection_manager switch ($this->config['dbms']) { - case 'phpbb_db_driver_firebird': + case 'phpbb\db\driver\firebird': $sql = 'SELECT RDB$GENERATOR_NAME FROM RDB$GENERATORS WHERE RDB$SYSTEM_FLAG = 0'; @@ -440,7 +440,7 @@ class phpbb_database_test_connection_manager } break; - case 'phpbb_db_driver_oracle': + case 'phpbb\db\driver\oracle': $sql = 'SELECT sequence_name FROM USER_SEQUENCES'; $result = $this->pdo->query($sql); @@ -451,7 +451,7 @@ class phpbb_database_test_connection_manager } break; - case 'phpbb_db_driver_postgres': + case 'phpbb\db\driver\postgres': $sql = 'SELECT sequence_name FROM information_schema.sequences'; $result = $this->pdo->query($sql); @@ -509,7 +509,7 @@ class phpbb_database_test_connection_manager switch ($this->config['dbms']) { - case 'phpbb_db_driver_oracle': + case 'phpbb\db\driver\oracle': // Get all of the information about the sequences $sql = "SELECT t.table_name, tc.column_name, d.referenced_name as sequence_name, s.increment_by, s.min_value FROM USER_TRIGGERS t @@ -544,14 +544,14 @@ class phpbb_database_test_connection_manager * Since we have no objects attached to our sequencers (triggers aren't attached), this works fine. */ $queries[] = 'DROP SEQUENCE ' . $row['SEQUENCE_NAME']; - $queries[] = "CREATE SEQUENCE {$row['SEQUENCE_NAME']} - MINVALUE {$row['MIN_VALUE']} - INCREMENT BY {$row['INCREMENT_BY']} + $queries[] = "CREATE SEQUENCE {$row['SEQUENCE_NAME']} + MINVALUE {$row['MIN_VALUE']} + INCREMENT BY {$row['INCREMENT_BY']} START WITH $max_val"; } break; - case 'phpbb_db_driver_postgres': + case 'phpbb\db\driver\postgres': // Get the sequences attached to the tables $sql = 'SELECT column_name, table_name FROM information_schema.columns WHERE table_name IN (' . implode(', ', $table_names) . ") diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 41c47faedf..a0d186e0f2 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -150,7 +150,7 @@ class phpbb_functional_test_case extends phpbb_test_case { global $phpbb_root_path, $phpEx; // so we don't reopen an open connection - if (!($this->db instanceof phpbb_db_driver)) + if (!($this->db instanceof \phpbb\db\driver\driver)) { $dbms = self::$config['dbms']; $this->db = new $dbms(); @@ -163,7 +163,7 @@ class phpbb_functional_test_case extends phpbb_test_case { if (!$this->cache) { - $this->cache = new phpbb_cache_driver_file; + $this->cache = new \phpbb\cache\driver\file; } return $this->cache; @@ -182,11 +182,11 @@ class phpbb_functional_test_case extends phpbb_test_case { global $phpbb_root_path, $phpEx; - $config = new phpbb_config(array()); + $config = new \phpbb\config\config(array()); $db = $this->get_db(); - $db_tools = new phpbb_db_tools($db); + $db_tools = new \phpbb\db\tools($db); - $migrator = new phpbb_db_migrator( + $migrator = new \phpbb\db\migrator( $config, $db, $db_tools, @@ -199,17 +199,11 @@ class phpbb_functional_test_case extends phpbb_test_case $container = new phpbb_mock_container_builder(); $container->set('migrator', $migrator); - $extension_manager = new phpbb_extension_manager( + $extension_manager = new \phpbb\extension\manager( $container, $db, $config, - new phpbb_filesystem( - new phpbb_symfony_request( - new phpbb_mock_request() - ), - $phpbb_root_path, - $php_ext - ), + new phpbb\filesystem(), self::$config['table_prefix'] . 'ext', dirname(__FILE__) . '/', $php_ext, @@ -271,7 +265,7 @@ class phpbb_functional_test_case extends phpbb_test_case self::assertContains('Database configuration', $crawler->filter('#main')->text()); $form = $crawler->selectButton('submit')->form(array( // Installer uses 3.0-style dbms name - 'dbms' => str_replace('phpbb_db_driver_', '', self::$config['dbms']), + 'dbms' => str_replace('phpbb\db\driver\\', '', self::$config['dbms']), 'dbhost' => self::$config['dbhost'], 'dbport' => self::$config['dbport'], 'dbname' => self::$config['dbname'], @@ -477,7 +471,7 @@ class phpbb_functional_test_case extends phpbb_test_case // Required by unique_id global $config; - $config = new phpbb_config(array()); + $config = new \phpbb\config\config(array()); $config['rand_seed'] = ''; $config['rand_seed_last_update'] = time() + 600; @@ -490,7 +484,7 @@ class phpbb_functional_test_case extends phpbb_test_case } $cache = new phpbb_mock_null_cache; - $cache_driver = new phpbb_cache_driver_null(); + $cache_driver = new \phpbb\cache\driver\null(); $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $phpbb_container ->expects($this->any()) @@ -527,18 +521,18 @@ class phpbb_functional_test_case extends phpbb_test_case { global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $phpbb_root_path, $phpEx; - $config = new phpbb_config(array()); + $config = new \phpbb\config\config(array()); $config['coppa_enable'] = 0; $db = $this->get_db(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $user = $this->getMock('phpbb_user'); - $auth = $this->getMock('phpbb_auth'); + $user = $this->getMock('\phpbb\user'); + $auth = $this->getMock('\phpbb\auth\auth'); - $phpbb_log = new phpbb_log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); + $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); $cache = new phpbb_mock_null_cache; - $cache_driver = new phpbb_cache_driver_null(); + $cache_driver = new \phpbb\cache\driver\null(); $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('cache.driver', $cache_driver); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); @@ -566,18 +560,18 @@ class phpbb_functional_test_case extends phpbb_test_case { global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $phpbb_root_path, $phpEx; - $config = new phpbb_config(array()); + $config = new \phpbb\config\config(array()); $config['coppa_enable'] = 0; $db = $this->get_db(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); - $user = $this->getMock('phpbb_user'); - $auth = $this->getMock('phpbb_auth'); + $user = $this->getMock('\phpbb\user'); + $auth = $this->getMock('\phpbb\auth\auth'); - $phpbb_log = new phpbb_log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); + $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); $cache = new phpbb_mock_null_cache; - $cache_driver = new phpbb_cache_driver_null(); + $cache_driver = new \phpbb\cache\driver\null(); $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $phpbb_container ->expects($this->any()) diff --git a/tests/test_framework/phpbb_search_test_case.php b/tests/test_framework/phpbb_search_test_case.php index 418d352c17..b929e740ea 100644 --- a/tests/test_framework/phpbb_search_test_case.php +++ b/tests/test_framework/phpbb_search_test_case.php @@ -11,7 +11,7 @@ abstract class phpbb_search_test_case extends phpbb_database_test_case { static protected function get_search_wrapper($class) { - $wrapped = $class . '_wrapper'; + $wrapped = str_replace('\\', '_', $class) . '_wrapper'; if (!class_exists($wrapped)) { $code = " diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 3d9cd10f32..351a3a9594 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -107,7 +107,7 @@ class phpbb_test_case_helpers if (extension_loaded('sqlite') && version_compare(PHPUnit_Runner_Version::id(), '3.4.15', '>=')) { $config = array_merge($config, array( - 'dbms' => 'phpbb_db_driver_sqlite', + 'dbms' => 'phpbb\db\driver\sqlite', 'dbhost' => dirname(__FILE__) . '/../phpbb_unit_tests.sqlite2', // filename 'dbport' => '', 'dbname' => '', diff --git a/tests/tree/nestedset_forum_base.php b/tests/tree/nestedset_forum_base.php index 43680609f8..ce03c1fc21 100644 --- a/tests/tree/nestedset_forum_base.php +++ b/tests/tree/nestedset_forum_base.php @@ -52,11 +52,11 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case global $config; - $config = $this->config = new phpbb_config(array('nestedset_forum_lock' => 0)); + $config = $this->config = new \phpbb\config\config(array('nestedset_forum_lock' => 0)); set_config(null, null, null, $this->config); - $this->lock = new phpbb_lock_db('nestedset_forum_lock', $this->config, $this->db); - $this->set = new phpbb_tree_nestedset_forum($this->db, $this->lock, 'phpbb_forums'); + $this->lock = new \phpbb\lock\db('nestedset_forum_lock', $this->config, $this->db); + $this->set = new \phpbb\tree\nestedset_forum($this->db, $this->lock, 'phpbb_forums'); $this->set_up_forums(); } @@ -97,7 +97,7 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case } else { - $buffer = new phpbb_db_sql_insert_buffer($this->db, 'phpbb_forums'); + $buffer = new \phpbb\db\sql_insert_buffer($this->db, 'phpbb_forums'); $buffer->insert_all($forums); $buffer->flush(); diff --git a/tests/user/lang_test.php b/tests/user/lang_test.php index d7ff451a70..c7c858c59d 100644 --- a/tests/user/lang_test.php +++ b/tests/user/lang_test.php @@ -11,7 +11,7 @@ class phpbb_user_lang_test extends phpbb_test_case { public function test_user_lang_sprintf() { - $user = new phpbb_user; + $user = new \phpbb\user; $user->lang = array( 'FOO' => 'BAR', 'BARZ' => 'PENG', @@ -93,7 +93,7 @@ class phpbb_user_lang_test extends phpbb_test_case $this->assertEquals($user->lang('ARRY', 1, 's', 2), '1 post'); // ticket PHPBB3-10345 - different plural rules, not just 0/1/2+ - $user = new phpbb_user; + $user = new \phpbb\user; $user->lang = array( 'PLURAL_RULE' => 13, 'ARRY' => array( diff --git a/tests/user/user_loader_test.php b/tests/user/user_loader_test.php index 5cdb654b18..13c35030f9 100644 --- a/tests/user/user_loader_test.php +++ b/tests/user/user_loader_test.php @@ -24,7 +24,7 @@ class phpbb_user_loader_test extends phpbb_database_test_case parent::setUp(); $this->db = $this->new_dbal(); - $this->user_loader = new phpbb_user_loader($this->db, __DIR__ . '/../../phpBB/', 'php', 'phpbb_users'); + $this->user_loader = new \phpbb\user_loader($this->db, __DIR__ . '/../../phpBB/', 'php', 'phpbb_users'); } public function test_load_get() diff --git a/tests/wrapper/phpbb_php_ini_fake.php b/tests/wrapper/phpbb_php_ini_fake.php index 49bc5936e5..d9e96447e3 100644 --- a/tests/wrapper/phpbb_php_ini_fake.php +++ b/tests/wrapper/phpbb_php_ini_fake.php @@ -7,7 +7,7 @@ * */ -class phpbb_php_ini_fake extends phpbb_php_ini +class phpbb_php_ini_fake extends \phpbb\php\ini { function get($varname) { |