@ -25,14 +25,21 @@ class LoadTest extends PHPUnit_Framework_TestCase
public static $file_contents ;
public static $autoload_array ;
public function run ( PHPUnit_Framework_TestResult $result = NULL )
{
$this -> setPreserveGlobalState ( false );
return parent :: run ( $result );
}
/**
* @ TODO : Load -> buildAutoload () should recieve AutoloadBuilder as a parameter
* @ TODO : Load -> buildAutoload () - uses two paths - PATH . '/' . APP . '/src' and PATH . '/lib' those are not checked . Can cause error .
*/
public function setUp ()
{
self :: $file_contents = '<?php return array("Db" => "/lib/core/model/Db.php", "RedisDebug" => "/lib/core/redis/RedisDebug.php"); ?>' ;
self :: $autoload_array = array ( 'Db' => '/lib/core/model/Db.php' , 'RedisDebug' => '/lib/core/redis/RedisDebug .php' );
self :: $file_contents = '<?php return array("Db" => "/lib/core/model/Db.php", "DbDriver" => "/lib/core/model/DbDriver .php"); ?>' ;
self :: $autoload_array = array ( 'Db' => '/lib/core/model/Db.php' , 'DbDriver' => '/lib/core/model/DbDriver .php' );
vfsStreamWrapper :: register ();
$this -> root = vfsStream :: create (
@ -45,9 +52,7 @@ class LoadTest extends PHPUnit_Framework_TestCase
),
'model' => array (
'Db.php' => '' ,
),
'redis' => array (
'RedisDebug.php' => ''
'DbDriver.php' => ''
),
'Registry.php' => '' ,
'Load.php' => '' ,
@ -97,25 +102,6 @@ class LoadTest extends PHPUnit_Framework_TestCase
$this -> assertEquals ( self :: $autoload_array , $autoload );
}
/**
* @ TODO : Load :: autoload () needs self :: $autoload = require ( self :: $file ); after self :: buildAutoload ();
*/
public function testDebugAutoload ()
{
$this -> setUp ();
Load :: setAutoloadFrom ( self :: $file );
$autoload = require ( self :: $file );
$this -> assertNotEmpty ( $autoload );
if ( ! defined ( 'DEBUG' )) {
define ( 'DEBUG' , true );
}
Load :: autoload ( 'Some' );
Load :: autoload ( 'RedisDebug' );
}
public function testAutoloadArrayExists ()
{
$this -> assertFileExists ( self :: $file );
@ -140,7 +126,26 @@ class LoadTest extends PHPUnit_Framework_TestCase
public function testAutoloadGetFilePath ()
{
$autoload = require ( self :: $file );
$this -> assertNotEmpty ( Load :: getFilePath ( 'RedisDebug' ));
$this -> assertNotEmpty ( Load :: getFilePath ( 'DbDriver' ));
}
/**
* @ TODO : Load :: autoload () needs self :: $autoload = require ( self :: $file ); after self :: buildAutoload ();
* @ runInSeparateProcess
*/
public function testDebugAutoload ()
{
$this -> setUp ();
Load :: setAutoloadFrom ( self :: $file );
$autoload = require ( self :: $file );
$this -> assertNotEmpty ( $autoload );
if ( ! defined ( 'DEBUG' )) {
define ( 'DEBUG' , true );
}
Load :: autoload ( 'Some' );
Load :: autoload ( 'DbDriver' );
}
/**
@ -153,6 +158,7 @@ class LoadTest extends PHPUnit_Framework_TestCase
$this -> assertNotEmpty ( Load :: getFilePath ( 'anton' ));
}
protected function newCallback ( $className )
{
switch ( $className ) {