-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
Copy pathTestAutoloader.php
62 lines (50 loc) · 1.34 KB
/
TestAutoloader.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
class TestAutoloader extends CTestCase
{
public function testAutoloaderForAnonymousCallableFilter()
{
Yii::$autoloaderFilters['smarty1'] = function($className)
{
if (strpos($className, 'Smarty') === 0) {
return true;
}
return false;
};
$this->assertTrue(Yii::autoload('SmartyFunctionMeta'));
$this->assertTrue(Yii::autoload('Smarty_Function_Meta'));
}
public function testAutoloaderForFunction()
{
function exampleFilter($className)
{
if (strpos($className, 'Zend') === 0) {
return true;
}
return false;
}
Yii::$autoloaderFilters['zend'] = 'exampleFilter';
$this->assertTrue(Yii::autoload('ZendFunctionMeta'));
$this->assertTrue(Yii::autoload('Zend_Function_Meta'));
}
public function testAutoloaderForStaticMethod()
{
eval('Class SmartyAutoloader {
public static function exampleFilter($className)
{
if (strpos($className, \'Smarty\') === 0) {
return true;
}
return false;
}
}');
Yii::$autoloaderFilters['smarty2'] = array('SmartyAutoloader', 'exampleFilter');
$this->assertTrue(Yii::autoload('SmartyFunctionMeta'));
$this->assertTrue(Yii::autoload('Smarty_Function_Meta'));
}
public function testAutoloaderWithoutFilter()
{
Yii::$enableIncludePath = false;
$this->assertFalse(Yii::autoload('SomeClass'));
$this->assertTrue(Yii::autoload('Yii'));
}
}