assertTrue($this->bootstrap->getCacheOutput(), 'Caching should be true'); $this->assertTrue($this->bootstrap->getFullErrorReporting(), 'Error reporting should be true'); $this->assertTrue($this->bootstrap->getLogQueries(), 'Log queries should be true'); $this->assertFalse($this->bootstrap->getRequireController(), 'Controller should not be required'); // -- check against defaults $this->assertNotNull($this->bootstrap->getApplicationDirectory(), 'Application directory should not be null'); $this->assertNotEquals($this->bootstrap->getAsraUrl(), Asra_Constants_Lang::ASRA_URL, 'Asra URL should not be `asra_url` after changing'); $this->assertNotNull($this->bootstrap->getCacheDirectory(), 'Cache dir should not be `cache`'); $this->assertNotNull($this->bootstrap->getControllerDirectory(), 'Controller dir should not be `controller`'); $this->assertNotEquals($this->bootstrap->getDefaultMethod(), Asra_Constants_Lang::DEFAULT_METHOD, 'Default method should not be `index` after changing'); $this->assertNotNull($this->bootstrap->getLogDirectory(), 'Log dir should not be `log`'); $this->assertNotEquals($this->bootstrap->getTimezone(), Asra_Constants_Lang::TIMEZONE, 'Timezone is still default'); } /** * test suite set up */ public function setUp() { } /** * all tests performed, tear down */ public function tearDown() { } public function testAsraUrl() { $_GET['asra_url'] = 'json'; $this->bootstrap = new Asra_Core_Bootstrap(); $this->bootstrap->setApplicationDirectory(FILES . "apps/default_app"); $this->bootstrap->dispatch(); $this->assertNotNull($this->bootstrap->getUrl(), "URL should not be null"); } public function testDirApplication() { $this->setExpectedException('Asra_Core_Exception'); $this->bootstrap = new Asra_Core_Bootstrap(); $this->bootstrap->setApplicationDirectory(FILES . "app"); } //public function testDirCache() //{ // $_GET['asra_url'] = 'json/test'; // $this->setExpectedException('Asra_Core_Exception'); // $this->bootstrap = new Asra_Core_Bootstrap(); // $this->bootstrap->setApplicationDirectory(FILES . "apps/default_app"); // $this->bootstrap->setCacheDirectory(FILES . "apps/default_app/missing"); // $this->bootstrap->dispatch(); //} public function testDirController() { $_GET['asra_url'] = 'json/test'; $this->setExpectedException('Asra_Core_Exception'); $this->bootstrap = new Asra_Core_Bootstrap(); $this->bootstrap->setApplicationDirectory(FILES . "apps/default_app"); $this->bootstrap->setControllerDirectory(FILES . "apps/default_app/missing"); $this->bootstrap->dispatch(); } //public function testDirLog() //{ // $_GET['asra_url'] = 'json/test'; // $this->setExpectedException('Asra_Core_Exception'); // $this->bootstrap = new Asra_Core_Bootstrap(); // $this->bootstrap->setApplicationDirectory(FILES . "apps/default_app"); // $this->bootstrap->setLogDirectory(FILES . "apps/default_app/missing"); // $this->bootstrap->dispatch(); //} /** * assert that illegal ini settings throw errors */ public function testIllegalIniSetting() { $this->bootstrap = new Asra_Core_Bootstrap(); $this->setExpectedException('Asra_Core_Exception'); $config = $this->bootstrap->loadSettingsConfig(FILES . 'ini/settings_illegal.ini'); } /** * testing loading a database configuration file */ public function testLoadDbConfig() { $this->bootstrap = new Asra_Core_Bootstrap(); $config = $this->bootstrap->loadDbConfig(FILES . 'ini/valid_config.ini'); $this->assertType('array', $config); $this->assertNotNull($config); $connect = new Asra_Db_Connect($config, 'localhost'); $this->assertEquals('database_test', $connect->getDb()); } /** * assert that settings file can be loaded and settings are changed */ public function testLoadSettings() { $this->bootstrap = new Asra_Core_Bootstrap(); $config = $this->bootstrap->loadSettingsConfig(FILES . 'ini/settings_file.ini'); $this->assertType('object', $config); $this->assertNotNull($config); $this->__assertSettingsNotDefault(); $this->assertNotEquals($this->bootstrap->getApplicationDirectory(), Asra_Constants_Lang::APP, 'Application directory should not be `app`'); } /** * assert that a malformed ini file throws an exception */ public function testMalformedIni() { $this->bootstrap = new Asra_Core_Bootstrap(); //$this->setExpectedException('Asra_Core_Excepetion'); try { $config = $this->bootstrap->loadDbConfig(FILES . 'ini/malformed_config.ini'); } catch (Asra_Core_Exception $e) { return; } $this->fail('Expected exception not raised. Malformed ini files should throw exceptions'); } /** * assert missing files throw errors */ public function testMissingFileIni() { $this->bootstrap = new Asra_Core_Bootstrap(); $this->setExpectedException('Asra_Core_Exception'); $this->bootstrap->loadDbConfig("missing.ini"); } /** * assert bad file param throws error */ public function testMissingIniParam() { $this->bootstrap = new Asra_Core_Bootstrap(); $this->setExpectedException('InvalidArgumentException'); $this->bootstrap->loadDbConfig(''); } /** * asset sure new works */ public function testNewBootstrap() { $this->bootstrap = new Asra_Core_Bootstrap(); $this->assertNotNull($this->bootstrap); } /** * change settings and assert */ public function testSetSettings() { $this->bootstrap = new Asra_Core_Bootstrap(); // -- toggles $this->bootstrap->setCacheOutput(true) ->setFullErrorReporting(true) ->setLogQueries(true) ->setRequireController(false); // -- settings $this->bootstrap->setApplicationDirectory(FILES . 'apps/default_app') ->setAsraUrl('asraurl') ->setCacheDirectory(FILES . 'cache') ->setControllerDirectory(FILES . 'controllers') ->setDefaultMethod('default') ->setLogDirectory(FILES . 'log') ->setTimezone('Atlantic/Reykjavik'); $this->__assertSettingsNotDefault(); //$this->bootstrap->dispatch(); } }