forked from zendframework/zendframework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Moved test autoload setup to tests/_autoload.php - Modified Session\ContainerTest and Session\SessionManagerTest to include _autoload.php if no autoloader is detected (happens when global state is destroyed).
- Loading branch information
1 parent
458136a
commit ea69331
Showing
4 changed files
with
77 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
/** | ||
* Setup autoloading | ||
*/ | ||
function ZendTest_Autoloader($class) | ||
{ | ||
$class = ltrim($class, '\\'); | ||
|
||
if (!preg_match('#^(Zend(Test)?|PHPUnit)(\\\\|_)#', $class)) { | ||
return false; | ||
} | ||
|
||
// $segments = explode('\\', $class); // preg_split('#\\\\|_#', $class);// | ||
$segments = preg_split('#[\\\\_]#', $class); // preg_split('#\\\\|_#', $class);// | ||
$ns = array_shift($segments); | ||
|
||
switch ($ns) { | ||
case 'Zend': | ||
$file = dirname(__DIR__) . '/library/Zend/'; | ||
break; | ||
case 'ZendTest': | ||
// temporary fix for ZendTest namespace until we can migrate files | ||
// into ZendTest dir | ||
$file = __DIR__ . '/Zend/'; | ||
break; | ||
default: | ||
$file = false; | ||
break; | ||
} | ||
|
||
if ($file) { | ||
$file .= implode('/', $segments) . '.php'; | ||
if (file_exists($file)) { | ||
return include_once $file; | ||
} | ||
} | ||
|
||
$segments = explode('_', $class); | ||
$ns = array_shift($segments); | ||
|
||
switch ($ns) { | ||
case 'PHPUnit': | ||
return include_once str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php'; | ||
case 'Zend': | ||
$file = dirname(__DIR__) . '/library/Zend/'; | ||
break; | ||
default: | ||
return false; | ||
} | ||
$file .= implode('/', $segments) . '.php'; | ||
if (file_exists($file)) { | ||
return include_once $file; | ||
} | ||
|
||
return false; | ||
} | ||
spl_autoload_register('ZendTest_Autoloader', true, true); | ||
|