From b95fdacdd378877d277e261465da73deb06e50da Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 10 Sep 2013 14:01:09 +0200 Subject: [ticket/11700] Move all recent code to namespaces PHPBB3-11700 --- tests/class_loader/class_loader_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/class_loader/class_loader_test.php') diff --git a/tests/class_loader/class_loader_test.php b/tests/class_loader/class_loader_test.php index 2b55c1ff8d..19f9280ec1 100644 --- a/tests/class_loader/class_loader_test.php +++ b/tests/class_loader/class_loader_test.php @@ -30,7 +30,7 @@ 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/'; @@ -71,8 +71,8 @@ class phpbb_class_loader_test extends PHPUnit_Framework_TestCase $cache = new phpbb_mock_cache($cache_map); $prefix = dirname(__FILE__) . '/'; - $class_loader = new phpbb_class_loader('phpbb_', $prefix . '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('phpbb_ext_', $prefix . 'phpbb/', 'php', $cache); $prefix .= 'phpbb/'; -- cgit v1.2.1 From 76dfe153fc14e595a5f76f9d2f9aaa7b15cdc994 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 10 Sep 2013 15:12:43 +0200 Subject: [ticket/11700] Fix class loader tests for namespaces PHPBB3-11700 --- tests/class_loader/class_loader_test.php | 38 ++++++++++++++------------------ 1 file changed, 16 insertions(+), 22 deletions(-) (limited to 'tests/class_loader/class_loader_test.php') diff --git a/tests/class_loader/class_loader_test.php b/tests/class_loader/class_loader_test.php index 19f9280ec1..eb50ac1ecd 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_phpbb__ext__' => 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('phpbb\\ext\\', $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); } } -- cgit v1.2.1 From c4b53490ad93566914cbc280910c67b75346a665 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 17 Sep 2013 16:15:44 +0200 Subject: [ticket/11700] Correctly load extensions with nonprefixed namespaces PHPBB3-11700 --- tests/class_loader/class_loader_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/class_loader/class_loader_test.php') diff --git a/tests/class_loader/class_loader_test.php b/tests/class_loader/class_loader_test.php index eb50ac1ecd..255b634bd6 100644 --- a/tests/class_loader/class_loader_test.php +++ b/tests/class_loader/class_loader_test.php @@ -60,13 +60,13 @@ class phpbb_class_loader_test extends PHPUnit_Framework_TestCase { $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___' => 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_ext = new \phpbb\class_loader('\\', $prefix . 'phpbb/', 'php', $cache); $prefix .= 'phpbb/'; -- cgit v1.2.1 From fe36375a36ec4f816eb07b41630b6c9fa7ff12c8 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Thu, 19 Sep 2013 18:29:08 +0200 Subject: [ticket/11700] Fix extension loading with namespaces class loader now expects all classes to be prefixed with a backslash when resolving paths PHPBB3-11700 --- tests/class_loader/class_loader_test.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'tests/class_loader/class_loader_test.php') diff --git a/tests/class_loader/class_loader_test.php b/tests/class_loader/class_loader_test.php index 255b634bd6..6e551f658a 100644 --- a/tests/class_loader/class_loader_test.php +++ b/tests/class_loader/class_loader_test.php @@ -36,22 +36,22 @@ class phpbb_class_loader_test extends PHPUnit_Framework_TestCase $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\\dir2'), + $class_loader->resolve_path('\\phpbb\\dir2\\dir2'), 'Class with name of dir within dir' ); } @@ -59,8 +59,8 @@ class phpbb_class_loader_test extends PHPUnit_Framework_TestCase public function test_resolve_cached() { $cache_map = array( - 'class_loader_phpbb__' => array('phpbb\\a\\cached_name' => 'a/cached_name'), - 'class_loader___' => 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); @@ -72,26 +72,26 @@ class phpbb_class_loader_test extends PHPUnit_Framework_TestCase $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); } } -- cgit v1.2.1