Exemple #1
0
 /**
  * trancate
  *
  * @param  mixed $ini
  * @param  mixed $sql
  * @param  string $section
  * @param  string $key
  * @access public
  * @return void
  */
 public static function trancate($ini, $sql, $section = 'testing', $key = 'default')
 {
     $config = Gene_Config::load($ini)->{$section};
     $name = $config->setting->className;
     if ($name !== 'Gene_Db_Setting_Zend') {
         if ($config->database->default->adapter !== 'Pdo_Mysql') {
             $config = $config->database->toArray();
             $config['default']['adapter'] = 'Pdo_Mysql';
         }
     }
     $db = new Gene_Db_Setting_Zend($config);
     $adapter = $db->load()->getDbAdapter($key);
     $adapter->getConnection()->exec(file_get_contents($sql));
     self::$_adapter = $adapter;
 }
Exemple #2
0
 public function testCacheから読み込んだ設定ファイルからエンジン取得できる()
 {
     $appPath = GENE_TEST_ROOT;
     $cachePath = $appPath . '/var/cache';
     $configPath = $appPath . '/var/config/view.ini';
     $instance = Gene_Cache_File::getInstance(GENE_TEST_ROOT);
     $options = array('frontend' => array('master_files' => $configPath), 'backend' => array('cache_dir' => $cachePath));
     $cache = $instance->setOptions($options)->getCache('view');
     $config = Gene_Config::load($configPath, $cache);
     $instance = new Gene_View_Adapter($config);
     $view = $instance->getView();
     $this->assertTrue($instance instanceof Gene_View_Adapter);
     $this->assertTrue($view instanceof Zend_View);
 }
Exemple #3
0
 public function testデータベースアダプターを取得できる()
 {
     $iniPath = GENE_TEST_ROOT . '/var/config/database.ini';
     $config = Gene_Config::load($iniPath);
     $db = new Gene_Db_Setting_Zend($config->production);
     $adapter = $db->load()->getDbAdapter();
     $this->assertTrue($adapter instanceof Zend_Db_Adapter_Pdo_Mysql);
 }
Exemple #4
0
 public function testplugin生成時に複数の引数を設定できる()
 {
     $iniPath = GENE_TEST_ROOT . '/var/config/plugin.ini';
     $config = Gene_Config::load($iniPath);
     $plugin = new Gene_Application_Setting_Plugin($config);
     $plugins = $plugin->load()->getPlugin();
     $args = $plugins['foo']->getArgs();
     $this->assertEquals($args, $config->plugin->foo->args->toArray());
 }
Exemple #5
0
 public function testキャッシュがない場合はキャッシュを生成する()
 {
     $appPath = dirname(__FILE__);
     $cachePath = $appPath . '/var/cache/';
     $configPath = $appPath . '/var/config/';
     $instance = Gene_Cache_File::getInstance($appPath . '/');
     $options = array('frontend' => array('master_files' => $appPath . '/var/config/test.ini'), 'backend' => array('cache_dir' => $cachePath));
     $cache = $instance->setOptions($options)->getCache('test');
     $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
     $config = Gene_Config::load($appPath . '/var/config/test.ini', $cache);
     $this->assertTrue($config instanceof Zend_Config_Ini);
     $path = pathinfo(str_replace('/', '_', $configPath . 'test'), PATHINFO_FILENAME);
     $files = array('zend_cache---' . $path, 'zend_cache---internal-metadatas---' . $path);
     $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($cachePath . 'test'));
     $actual = array();
     foreach ($iterator as $val) {
         if ($val->isFile()) {
             $actual[] = $val->getFilename();
         }
     }
     sort($files);
     sort($actual);
     $this->assertEquals($actual, $files);
     $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
 }
Exemple #6
0
 public function test追加したルーティング先にディスパッチする()
 {
     $appPath = GENE_TEST_ROOT . '/var/config/routing.ini';
     $config = Gene_Config::load($appPath);
     $routing = new Gene_Application_Setting_Routing($config->routes);
     $modules = dirname(__FILE__) . '/var/modules/';
     $front = Zend_Controller_Front::getInstance();
     $router = $front->getRouter();
     $routes = $routing->add($router)->getRouter();
     $front->setDefaultModule('index')->addModuleDirectory($modules);
     $request = new Zend_Controller_Request_Http('http://localhost');
     $params = '/admin/list';
     $request->setRequestUri($params);
     $response = $front->returnResponse(true)->setParam('noViewRenderer', true)->dispatch($request);
     $body = $response->getBody();
     $this->assertEquals($body, 'Admin_IndexController::listAction');
     $response->clearAllHeaders()->clearBody();
 }
Exemple #7
0
 /**
  * Init database
  *
  * @access public
  * @return Gene_Bootstrap Fluent interface
  */
 public function _initDb()
 {
     $path = $this->_configPath . 'database.ini';
     $config = Gene_Config::load($path, $this->_cache);
     if (is_null($config)) {
         return $this;
     }
     $env = $this->getEnvironment();
     $class = $config->{$env}->setting->className;
     if (!class_exists($class, false)) {
         Zend_Loader::loadClass($class);
     }
     $setting = new $class($config->{$env});
     $adapter = $setting->load();
     $this->setParam('adapter', $adapter);
     return $this;
 }
Exemple #8
0
 public function testLayoutパスを取得できる()
 {
     $appPath = GENE_TEST_ROOT . '/var/config/layout.ini';
     $config = Gene_Config::load($appPath);
     $instance = new Gene_Application_Setting_Layout($config);
     $path = $instance->getPath();
     $expect = array('index' => dirname(__FILE__) . '/var/index/default.phtml', 'admin' => dirname(__FILE__) . '/var/admin/default.phtml');
     $this->assertEquals($path, $expect);
 }