diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index 4b852e2..d51bcc7 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -32,17 +32,26 @@ class ConfigTest extends PHPUnit_Framework_TestCase $this->assertNotEquals('Config', get_class(Config::getInstance())); } + /** + * @expectedException Exception + */ public function testArrayAsParam() { $arr = array( 'one' => 1, 'two' => 2, - 'three' => 3 + 'three' => 3, + 4 => 'four' ); Config::set(0, $arr); $new_arr = Config::get(0); $this->assertEquals('ConfigArray', get_class($new_arr)); + $this->assertEquals('four', $new_arr->offsetGet(4)); + $this->assertEquals(1, $new_arr->offsetGet('one')); + $this->assertNotEquals(1, $new_arr->offsetGet('two')); + + $new_arr->offsetGet(24); } } \ No newline at end of file diff --git a/tests/LoadTest.php b/tests/LoadTest.php index c03fd96..cb7dfc1 100644 --- a/tests/LoadTest.php +++ b/tests/LoadTest.php @@ -56,6 +56,20 @@ class LoadTest extends PHPUnit_Framework_TestCase $autoload = require(self::$file); $this->assertNotEmpty($autoload); + Load::autoload('Action'); + } + + public function testDebugAutoload() + { + Load::setAutoloadFrom(self::$file); + + $autoload = require(self::$file); + $this->assertNotEmpty($autoload); + + define('DEBUG', true); + Load::autoload('Func'); + Load::autoload('Captcha'); + } public function testAutoloadArrayExists() diff --git a/tests/util/AutoloadBuilderTest.php b/tests/util/AutoloadBuilderTest.php index ce61a7d..d852a81 100644 --- a/tests/util/AutoloadBuilderTest.php +++ b/tests/util/AutoloadBuilderTest.php @@ -10,6 +10,7 @@ * Unit tests for AutoloadBuilder class */ +require_once 'vfsStream/vfsStream.php'; require_once dirname(__FILE__) . '/../../util/AutoloadBuilder.php'; /** @@ -65,12 +66,40 @@ class AutoloadBuilderTest extends PHPUnit_Framework_TestCase $builder->build(); } + public function testBuild() + { + $builder = new AutoloadBuilder(self::$file, array(PATH . '/' . APP . '/src', PATH . '/' . APP . '/cache', PATH . '/lib')); + + $builder->build(); + + $this->assertFileExists(self::$file); + } public function testAutoloadFileExists() { $this->assertFileExists(self::$file); } + public function testAutoloadArray() + { + $this->assertFileExists(self::$file); + $array = require self::$file; + $this->assertInternalType('array', $array); + $this->assertNotEmpty($array); + } + + /** + * @expectedException PHPUnit_Framework_Error + */ + public function testAccessDenied() + { + chmod(self::$file, 0400); + $builder = new AutoloadBuilder(self::$file, array(PATH . '/' . APP . '/src', PATH . '/' . APP . '/cache', PATH . '/lib')); + + $builder->build(); + chmod(self::$file, 0777); + } + public static function tearDownAfterClass() { if (file_exists(self::$file)) {