/** * @test * @expectedException \AppZap\PHPFramework\Mvc\ApplicationPartMissingException * @expectedExceptionCode 1410537933 */ public function cacheFolderNotWritable() { Configuration::reset(); Configuration::set('phpframework', 'cache.enable', TRUE); Configuration::set('phpframework', 'cache.folder', '/'); $cache = CacheFactory::getCache(); $this->assertTrue($cache->getStorage() instanceof FileStorage); }
/** * @param string $file */ protected static function parseFile($file) { $config = parse_ini_file($file, TRUE); foreach ($config as $section => $sectionConfiguration) { foreach ($sectionConfiguration as $key => $value) { Configuration::set($section, $key, $value); } } }
/** * @test */ public function maximumDev() { Configuration::set('phpframework', 'version', '2.0-dev'); $this->assertTrue(Version::maximum(2, 0)); $this->assertTrue(Version::maximum(2, 5)); $this->assertFalse(Version::maximum(1, 99)); Configuration::set('phpframework', 'version', '12.5-dev'); $this->assertTrue(Version::maximum(12, 5)); $this->assertTrue(Version::maximum(12, 99)); $this->assertFalse(Version::maximum(12, 0)); }
public function setUp() { $database = 'phpunit_tests'; $host = '127.0.0.1'; $password = ''; $user = '******'; Configuration::set('phpframework', 'db.mysql.database', $database); Configuration::set('phpframework', 'db.mysql.host', $host); Configuration::set('phpframework', 'db.mysql.password', $password); Configuration::set('phpframework', 'db.mysql.user', $user); $this->repository = ItemRepository::getInstance(); }
/** * @param $application * @throws ApplicationPartMissingException */ public static function initialize($application) { $projectRoot = self::getProjectRoot(); $applicationDirectoryPath = $projectRoot . $application; $applicationDirectory = realpath($applicationDirectoryPath); if (!is_dir($applicationDirectory)) { throw new ApplicationPartMissingException('Application folder ' . htmlspecialchars($applicationDirectoryPath) . ' not found', 1410538265); } $applicationDirectory .= '/'; Configuration::set('phpframework', 'db.migrator.directory', $applicationDirectory . '_sql/'); Configuration::set('phpframework', 'project_root', $projectRoot); Configuration::set('application', 'application', $application); Configuration::set('application', 'application_directory', $applicationDirectory); Configuration::set('application', 'routes_file', $applicationDirectory . 'routes.php'); Configuration::set('application', 'templates_directory', $applicationDirectory . 'templates/'); Configuration::set('phpframework', 'version', '1.4'); }
/** * @test */ public function setCharset() { Configuration::set('phpframework', 'db.charset', 'utf8'); $this->fixture->connect(); }
public function setUp() { Configuration::set('application', 'templates_directory', dirname(__FILE__) . '/../_templates'); Configuration::set('phpframework', 'cache.enable', TRUE); $this->reponse = new TwigView(); }
/** * @test * @expectedException \AppZap\PHPFramework\Persistence\DatabaseMigratorException * @expectedExceptionCode 1415089456 */ public function rollbackOnError() { Configuration::set('phpframework', 'db.migrator.directory', $this->basePath . '/_migrator/_error/'); try { (new DatabaseMigrator())->migrate(); } catch (\Exception $e) { $this->assertSame(1, count($this->db->query("SHOW TABLES LIKE 'migrator_test_error'"))); $this->assertSame(1, $this->db->count('migrator_test_error', ['title' => 'test1'])); $this->assertSame(1, $this->db->count('migrator_test_error')); throw $e; } }
/** * @test * @expectedException \AppZap\PHPFramework\Authentication\BaseSessionException * @expectedExceptionCode 1409732479 */ public function constructWithNotExistingSessionClass() { Configuration::set('phpframework', 'authentication.sessionclass', '\\AppZap\\PHPFramework\\Tests\\Unit\\Authentication\\NotExisting'); new AuthenticationService(); }
/** * @param string $filename */ protected function loadRoutesFile($filename) { $routes_file = dirname(__FILE__) . '/_routesfiles/' . $filename . '.php'; Configuration::set('application', 'routes_file', $routes_file); }
/** * @test */ public function getSectionDefaultValuesNamespace() { Configuration::reset(); Configuration::set('test', 'ns1.key1', 1); Configuration::set('test', 'ns2.key2', FALSE); Configuration::set('test', 'ns1.key3', 3); $configuration = Configuration::getSection('test', 'ns1', ['key1' => FALSE, 'key2' => 2]); $this->assertSame(1, $configuration['key1']); $this->assertSame(2, $configuration['key2']); $this->assertSame(3, $configuration['key3']); }