|
|
@ -10,6 +10,8 @@ |
|
|
|
* Unit tests for Load class |
|
|
|
*/ |
|
|
|
|
|
|
|
require dirname(__FILE__) . '/../Load.php'; |
|
|
|
|
|
|
|
class LoadTest extends PHPUnit_Framework_TestCase |
|
|
|
{ |
|
|
|
|
|
|
@ -23,19 +25,21 @@ class LoadTest extends PHPUnit_Framework_TestCase |
|
|
|
*/ |
|
|
|
public static function setUpBeforeClass() |
|
|
|
{ |
|
|
|
define('PATH', realpath(dirname(__FILE__) . '/../../..')); |
|
|
|
if (!defined('PATH')) { |
|
|
|
define('PATH', realpath(dirname(__FILE__) . '/../../..')); |
|
|
|
} |
|
|
|
|
|
|
|
// default application name
|
|
|
|
if (!defined('APP')) { |
|
|
|
define('APP', 'lib/core/tests/face'); |
|
|
|
} |
|
|
|
|
|
|
|
self::$file = PATH . '/'. APP. '/cache//autoload.php'; |
|
|
|
self::$file = PATH . '/' . APP . '/cache/autoload.php'; |
|
|
|
|
|
|
|
// value - if dir exists (to delete it if it was created), default true
|
|
|
|
self::$inc_dirs[PATH . '/' . APP . '/src'] = true; |
|
|
|
self::$inc_dirs[PATH . '/' . APP . '/src'] = true; |
|
|
|
self::$inc_dirs[PATH . '/' . APP . '/cache'] = true; |
|
|
|
self::$inc_dirs[PATH . '/lib'] = true; |
|
|
|
self::$inc_dirs[PATH . '/lib'] = true; |
|
|
|
|
|
|
|
foreach (self::$inc_dirs as $dir => &$is_exist) { |
|
|
|
if (!file_exists($dir)) { |
|
|
@ -45,11 +49,9 @@ class LoadTest extends PHPUnit_Framework_TestCase |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function testSetAutoLoadFrom() |
|
|
|
{ |
|
|
|
// autoload
|
|
|
|
require (PATH . '/lib/core/Load.php'); |
|
|
|
Load::setAutoloadFrom(self::$file); |
|
|
|
|
|
|
|
$autoload = require(self::$file); |
|
|
@ -67,7 +69,7 @@ class LoadTest extends PHPUnit_Framework_TestCase |
|
|
|
public function testFileForArray() |
|
|
|
{ |
|
|
|
$autoload = require(self::$file); |
|
|
|
$this->assertInternalType('array', $autoload); |
|
|
|
$this->assertInternalType('array', $autoload); |
|
|
|
} |
|
|
|
|
|
|
|
public function testAutoloadArrayNotEmpty() |
|
|
@ -91,13 +93,11 @@ class LoadTest extends PHPUnit_Framework_TestCase |
|
|
|
{ |
|
|
|
$autoload = require(self::$file); |
|
|
|
$this->assertNotEmpty($autoload['anton']); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static function tearDownAfterClass() |
|
|
|
{ |
|
|
|
if(file_exists(self::$file)) { |
|
|
|
if (file_exists(self::$file)) { |
|
|
|
unlink(self::$file); |
|
|
|
} |
|
|
|
|
|
|
|