modified alutoload classes for tests isolation
This commit is contained in:
@ -67,14 +67,6 @@ class LoadTest extends PHPUnit_Framework_TestCase
|
||||
$this->getMock('AutoloadBuilder');
|
||||
}
|
||||
|
||||
if (!defined('PATH')) {
|
||||
//define('PATH', realpath(dirname(__FILE__) . '/../../../'));
|
||||
define('PATH', vfsStream::url('root'));
|
||||
}
|
||||
if (!defined('APP')) {
|
||||
define('APP', 'lib/core/tests/face');
|
||||
}
|
||||
|
||||
vfsStreamWrapper::setRoot($this->root);
|
||||
|
||||
self::$file = vfsStream::url('root/autoload.php');
|
||||
@ -82,8 +74,13 @@ class LoadTest extends PHPUnit_Framework_TestCase
|
||||
set_new_overload(array($this, 'newCallback'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testSetAutoLoadFromExistingFile()
|
||||
{
|
||||
$this->setConstants();
|
||||
$this->assertFileExists(self::$file);
|
||||
Load::setAutoloadFrom(self::$file);
|
||||
|
||||
$autoload = require(self::$file);
|
||||
@ -91,8 +88,12 @@ class LoadTest extends PHPUnit_Framework_TestCase
|
||||
Load::autoload('Db');
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testAutoloadFromNonExistingFile()
|
||||
{
|
||||
$this->setConstants();
|
||||
$this->assertTrue($this->root->removeChild('autoload.php'));
|
||||
$this->assertFileNotExists(self::$file);
|
||||
|
||||
@ -123,19 +124,36 @@ class LoadTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertArrayHasKey('Db', $autoload);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testAutoloadGetFilePath()
|
||||
{
|
||||
$autoload = require(self::$file);
|
||||
$this->setConstants();
|
||||
Load::setAutoloadFrom(self::$file);
|
||||
$this->assertNotEmpty(Load::getFilePath('DbDriver'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @TODO: Load::getFilePath - check for wrong index
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testAutoloadGetFilePathNullIndex()
|
||||
{
|
||||
$this->setConstants();
|
||||
Load::setAutoloadFrom(self::$file);
|
||||
$autoload = require(self::$file);
|
||||
$this->assertNotEmpty(Load::getFilePath('anton'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @TODO: Load::autoload() needs self::$autoload = require(self::$file); after self::buildAutoload();
|
||||
* @runInSeparateProcess
|
||||
*/
|
||||
public function testDebugAutoload()
|
||||
{
|
||||
$this->setUp();
|
||||
$this->setConstants();
|
||||
Load::setAutoloadFrom(self::$file);
|
||||
|
||||
$autoload = require(self::$file);
|
||||
@ -147,16 +165,6 @@ class LoadTest extends PHPUnit_Framework_TestCase
|
||||
Load::autoload('Some');
|
||||
Load::autoload('DbDriver');
|
||||
}
|
||||
|
||||
/**
|
||||
* @TODO: Load::getFilePath - check for wrong index
|
||||
* @expectedException PHPUnit_Framework_Error
|
||||
*/
|
||||
public function testAutoloadGetFilePathNullIndex()
|
||||
{
|
||||
$autoload = require(self::$file);
|
||||
$this->assertNotEmpty(Load::getFilePath('anton'));
|
||||
}
|
||||
|
||||
|
||||
protected function newCallback($className)
|
||||
@ -169,8 +177,23 @@ class LoadTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
|
||||
private function setConstants()
|
||||
{
|
||||
if (!defined('PATH')) {
|
||||
define('PATH', vfsStream::url('root'));
|
||||
}
|
||||
if (!defined('APP')) {
|
||||
define('APP', 'lib/core/tests/face');
|
||||
}
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
// if (defined('PATH')) {
|
||||
// echo PHP_EOL . __CLASS__ . ' ' . PATH . PHP_EOL;
|
||||
// } else {
|
||||
// echo PHP_EOL . __CLASS__ . ' ' . 'PATH NOT DEFINED' . PHP_EOL;
|
||||
// }
|
||||
unset_new_overload();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user