aboutsummaryrefslogtreecommitdiffstats
path: root/tests/class_loader/class_loader_test.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/class_loader/class_loader_test.php')
-rw-r--r--tests/class_loader/class_loader_test.php103
1 files changed, 103 insertions, 0 deletions
diff --git a/tests/class_loader/class_loader_test.php b/tests/class_loader/class_loader_test.php
new file mode 100644
index 0000000000..76af4dde37
--- /dev/null
+++ b/tests/class_loader/class_loader_test.php
@@ -0,0 +1,103 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+class phpbb_class_loader_test extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ global $phpbb_class_loader;
+ $phpbb_class_loader->unregister();
+
+ global $phpbb_class_loader_ext;
+ $phpbb_class_loader_ext->unregister();
+ }
+
+ public function tearDown()
+ {
+ global $phpbb_class_loader_ext;
+ $phpbb_class_loader_ext->register();
+
+ global $phpbb_class_loader;
+ $phpbb_class_loader->register();
+ }
+
+ public function test_resolve_path()
+ {
+ $prefix = dirname(__FILE__) . '/';
+ $class_loader = new phpbb_class_loader('phpbb_', $prefix . 'includes/');
+
+ $prefix .= 'includes/';
+
+ $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'),
+ 'Top level class'
+ );
+ $this->assertEquals(
+ $prefix . 'dir/class_name.php',
+ $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 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)'
+ );
+ }
+
+ 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'),
+ );
+ $cache = new phpbb_mock_cache($cache_map);
+
+ $prefix = dirname(__FILE__) . '/';
+ $class_loader = new phpbb_class_loader('phpbb_', $prefix . 'includes/', '.php', $cache);
+ $class_loader_ext = new phpbb_class_loader('phpbb_ext_', $prefix . 'includes/', '.php', $cache);
+
+ $prefix .= 'includes/';
+
+ $this->assertEquals(
+ $prefix . 'dir/class_name.php',
+ $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->assertEquals(
+ $prefix . 'a/cached_name.php',
+ $class_loader->resolve_path('phpbb_a_cached_name'),
+ 'Cached class found'
+ );
+
+ $this->assertEquals(
+ $prefix . 'foo.php',
+ $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->check($this, $cache_map);
+ }
+}
k drive!' * - perl -pi -e 's!"Activate ethernet cards promiscuity check."!"Activate ↵Ahmad Samir2011-04-0472-72/+72 | | | | Ethernet cards promiscuity check."!' * - perl -pi -e 's!Posix!POSIX!'Ahmad Samir2011-04-0472-88/+88 | * - perl -pi -e 's!Hard drive!Hard disk drive!' (except install/steps_list.pm)Ahmad Samir2011-04-04216-439/+439 | * - perl -pi -e 's!need to reboot before the modification can take ↵Ahmad Samir2011-04-0473-145/+145 | | | | | | | place"!"need to reboot before the modification can take effect"!' - perl -pi -e 's!"You need to reboot for the partition table modifications to take place"!"You need to reboot for the partition table modifications to take effect"!' * - perl -pi -e 's!"All data on this partition should be backed-up"!"All data ↵Ahmad Samir2011-04-0472-72/+72 | | | | on this partition should be backed up"!' * - perl -pi -e 's!"Check bad blocks\?"!"Check for bad blocks\?"!'Ahmad Samir2011-04-0473-74/+74 | * - perl -pi -e 's!"Do you want to save /etc/fstab modifications"!"Do you want ↵Ahmad Samir2011-04-0472-72/+72 | | | | to save the /etc/fstab modifications?"!' * - perl -pi -e 's!mountpoint!mount point!'Ahmad Samir2011-04-0473-73/+73 | * - perl -pi -e 's!hard drive!hard disk drive!'Ahmad Samir2011-04-04223-3763/+3763 | * String changes: perl -pi -e 's!file system!filesystem!'Ahmad Samir2011-04-04147-877/+877 | * String changes: perl -pi -e 's!"Password should resist to basic ↵Ahmad Samir2011-04-0472-72/+72 | | | | attacks"!"Password should be resistant to basic attacks"!' * - string changes: perl -pi -e 's!Can not!Cannot!'Ahmad Samir2011-04-04153-395/+395 | * - string changes: perl -pi -e 's!/boot partition!separate /boot partition!'Ahmad Samir2011-04-0472-218/+218 | * update modules list needed for md raid456 and dm-raid 4/5/6 targetThomas Backlund2011-04-022-2/+5 | * update modules list needed for md raid456 and dm-raid 4/5/6 targetThomas Backlund2011-04-023-3/+4 | * - use 'cannot' instead of 'can not'Ahmad Samir2011-04-0231-80/+80 | | | | | - use 'LDAP' instead of 'Ldap' * - update the .po filesAhmad Samir2011-04-0270-53090/+48564 | * - modify a string in partitioning_wizard.pm to be more grammatically correctAhmad Samir2011-04-024-713/+632 | | | | | (spotted by Sigrid Carrera, on mageia-i18n ML) * update version for beta1 designAnne Nicolas2011-04-012-1/+6 | * update installer and advertising design for beta1Anne Nicolas2011-04-0124-0/+0 | * add a fixme not about using https for mirrors listOlivier Blin2011-03-311-0/+1 | * Fix pot fileDexter Morgan2011-03-30