Exemplo n.º 1
0
 public function setUp()
 {
     $this->PluginInstaller = new AkPluginInstaller();
     $this->PluginInstaller->app_app_dir = AkConfig::getDir('fixtures');
     copy($this->template_path, $this->target_path);
     $this->PluginInstaller->extension_points = array('PluginInstallerTargetClass' => 'plugin_installer_target_class.php');
 }
Exemplo n.º 2
0
 public function index()
 {
     $this->base_dir = AK_BASE_DIR;
     $this->akelos_dir = AK_FRAMEWORK_DIR;
     $this->tasks_dir = AK_TASKS_DIR;
     $this->has_configuration = file_exists(AkConfig::getDir('config') . DS . 'config.php');
     $this->has_routes = file_exists(AkConfig::getDir('config') . DS . 'routes.php');
     $this->has_database = file_exists(AkConfig::getDir('config') . DS . 'database.yml');
     $this->using_root_path = $this->Request->getPath() == '/';
     $this->new_install = !$this->has_configuration || !$this->has_routes || $this->using_root_path;
     $this->environment = AK_ENVIRONMENT;
     $this->memcached_on = AkMemcache::isServerUp();
     $this->constants = AkDebug::get_constants();
     $this->langs = Ak::langs();
     $this->database_settings = Ak::getSettings('database', false);
     $this->server_user = trim(AK_WIN ? `ECHO %USERNAME%` : `whoami`);
     $this->local_ips = AkConfig::getOption('local_ips', array('localhost', '127.0.0.1', '::1'));
     $paths = array(AK_APP_DIR . DS . 'locales');
     $this->invalid_permissions = array();
     foreach ($paths as $path) {
         if (is_dir($path) && !@file_put_contents($path . DS . '__test_file')) {
             $this->invalid_permissions[] = $path;
         } else {
             @unlink($path . DS . '__test_file');
         }
     }
 }
Exemplo n.º 3
0
 public function _run_from_file($file_name, $all_in_one_test = true)
 {
     $multiple_expected_php = $multiple_sintags = '';
     $tests = explode('===================================', file_get_contents(AkConfig::getDir('fixtures') . DS . $file_name));
     foreach ($tests as $test) {
         list($sintags, $php) = explode('-----------------------------------', $test);
         $sintags = trim($sintags);
         $expected_php = trim($php);
         if (empty($sintags)) {
             return;
         } else {
             $multiple_sintags .= $sintags;
             $multiple_expected_php .= $expected_php;
         }
         $AkSintags = new AkSintagsParser();
         $php = $AkSintags->parse($sintags);
         if ($php != $expected_php) {
             AkDebug::trace("GENERATED: \n" . $php);
             AkDebug::trace("EXPECTED: \n" . $expected_php);
             AkDebug::trace("SINTAGS: \n" . $sintags);
         }
         $this->assertEqual($php, $expected_php);
     }
     if ($all_in_one_test) {
         $AkSintags = new AkSintagsParser();
         $php = $AkSintags->parse($multiple_sintags);
         if ($php != $multiple_expected_php) {
             AkDebug::trace("GENERATED: \n" . $php);
             AkDebug::trace("EXPECTED: \n" . $expected_php);
             AkDebug::trace("SINTAGS: \n" . $sintags);
         }
         $this->assertEqual($php, $multiple_expected_php);
     }
 }
Exemplo n.º 4
0
 public function test_should_fill_the_table_with_yaml_data()
 {
     $unit_tester = new AkUnitTest();
     $unit_tester->installAndIncludeModels(array('TheModel' => 'id,name'));
     $TheModel =& $unit_tester->TheModel;
     $TheModel->create(array('name' => 'eins'));
     $TheModel->create(array('name' => 'zwei'));
     $TheModel->create(array('name' => 'drei'));
     $TheModel->create(array('name' => 'vier'));
     $this->assertEqual($TheModel->count(), 4);
     $this->assertTrue($AllRecords = $TheModel->find());
     $yaml = $TheModel->toYaml($AllRecords);
     $yaml_path = AkConfig::getDir('fixtures') . DS . 'the_models.yml';
     $this->assertFalse(file_exists($yaml_path));
     AkFileSystem::file_put_contents($yaml_path, $yaml);
     $unit_tester->installAndIncludeModels(array('TheModel' => 'id,name'));
     try {
         $TheModel->find();
     } catch (RecordNotFoundException $e) {
         $this->pass();
     }
     $this->assertEqual($TheModel->count(), 0);
     $unit_tester->installAndIncludeModels(array('TheModel' => 'id,name'), array('populate' => true));
     $this->assertEqual($TheModel->count(), 4);
     unlink($yaml_path);
 }
Exemplo n.º 5
0
 public function test_should_show_public_dot_404_dot_php()
 {
     $this->setMaximumRedirects(0);
     $this->get(AkConfig::getOption('testing_url') . '/action_pack/public/index.php?ak=invalid');
     $this->assertResponse(404);
     $this->assertText("Exception in InvalidController#index");
 }
Exemplo n.º 6
0
 public function test_should_connect_using_custom_namespace()
 {
     file_put_contents(AkConfig::getDir('config') . '/testing_object_database.yml', AkConfig::getDir('fixtures') . '/sample_config.yml');
     $this->db->settings_namespace = 'testing_object_database';
     $this->assertTrue($this->db->setupAdapter());
     unlink(AkConfig::getDir('config') . '/testing_object_database.yml');
 }
Exemplo n.º 7
0
 public function __construct()
 {
     parent::__construct();
     foreach (glob(AkConfig::getDir('config') . '/locales/*.php') as $file) {
         $this->original_locales[$file] = file_get_contents($file);
     }
 }
Exemplo n.º 8
0
 public function test_should_generate_controller_and_auxiliary_files()
 {
     $files = array(AkConfig::getDir('controllers') . DS . 'credit_card_controller.php', AkConfig::getDir('helpers') . DS . 'credit_card_helper.php', AkConfig::getDir('test') . DS . 'functional' . DS . 'controllers' . DS . 'credit_card_controller_test.php', AkConfig::getDir('test') . DS . 'unit' . DS . 'helpers' . DS . 'credit_card_helper_test.php', AkConfig::getDir('views') . DS . 'credit_card' . DS . 'open.html.tpl', AkConfig::getDir('views') . DS . 'credit_card' . DS . 'debit.html.tpl', AkConfig::getDir('views') . DS . 'credit_card' . DS . 'credit.html.tpl', AkConfig::getDir('views') . DS . 'credit_card' . DS . 'close.html.tpl');
     clearstatcache();
     foreach ($files as $file) {
         file_exists($file) && unlink($file);
         $this->assertFalse(file_exists($file));
     }
     AkFileSystem::file_put_contents(AkConfig::getDir('views') . DS . 'credit_card' . DS . 'credit.html.tpl', 'foo', array('base_path' => AK_FRAMEWORK_DIR));
     clearstatcache();
     $this->assertPattern('/collisions/', $this->runGeneratorCommand('controller CreditCard open debit credit close'));
     AkFileSystem::file_delete(AkConfig::getDir('views') . DS . 'credit_card' . DS . 'credit.html.tpl', array('base_path' => AK_FRAMEWORK_DIR));
     clearstatcache();
     foreach ($files as $file) {
         $this->assertFalse(file_exists($file));
     }
     $this->assertPattern('/ files have been created/', $this->runGeneratorCommand('controller CreditCard open debit credit close'));
     clearstatcache();
     foreach ($files as $file) {
         $this->assertTrue(file_exists($file));
         if (!file_exists($file)) {
             AkDebug::trace($file);
         }
         @unlink($file);
     }
 }
Exemplo n.º 9
0
 public function createTemplate($file_name, $content = 'Dummy')
 {
     $file_name = str_replace('/', DS, $file_name);
     $file_name = AkConfig::getDir('views') . DS . $file_name;
     $this->assertTrue((bool) AkFileSystem::file_put_contents($file_name, $content));
     $this->created_files[] = $file_name;
 }
Exemplo n.º 10
0
 public function test_get_methods_filtered()
 {
     $file = AkConfig::getDir('fixtures') . DS . 'reflection_test_class.php';
     $class = new AkReflectionClass(file_get_contents($file));
     $filteredMethods = $class->getMethods(array('tags' => array('WingsPluginInstallAs' => '.*')));
     $this->assertEqual(1, count($filteredMethods));
     $this->assertEqual('testFunction2', $filteredMethods[0]->getName());
 }
Exemplo n.º 11
0
 function __construct()
 {
     if (!($this->webserver_enabled = AkConfig::getOption('webserver_enabled', false))) {
         return;
     }
     $this->url = AkConfig::getOption('testing_url') . '/active_resource/public/index.php?ak=http_requests';
     parent::__construct();
 }
Exemplo n.º 12
0
 public function __construct()
 {
     AkConfig::setDir('suite', dirname(__FILE__));
     if (!ADMIN_PLUGIN_RUNNING_ON_APPLICATION_SCOPE) {
         $this->rebaseAppPaths(realpath(dirname(__FILE__) . str_repeat(DS . '..', 3) . DS . 'installer' . DS . 'admin_files'));
     }
     AkUnitTestSuite::cleanupTmpDir();
 }
Exemplo n.º 13
0
 public function __construct()
 {
     AkConfig::setDir('suite', dirname(__FILE__));
     $this->rebaseAppPaths();
     $this->db = new AkOdbAdapter();
     $this->db->connect(array('type' => 'mongo_db', 'database' => 'akelos_testing'));
     defined('AK_TESTING_MONGO_DB_IS_CONNECTED') || define('AK_TESTING_MONGO_DB_IS_CONNECTED', $this->db->isConnected());
 }
Exemplo n.º 14
0
 public function testPickLayoutIfActionameMatches()
 {
     $this->createViewTemplate('index.html');
     $this->createTemplate('layouts/application.tpl');
     $controller = $this->createControllerFor('index');
     $controller->setLayout('application', array('only' => 'index'));
     $this->expectRender(array('index.html', AkConfig::getDir('views') . DS . 'layouts/application.tpl'));
     $controller->defaultRender();
 }
Exemplo n.º 15
0
 public function test_setup()
 {
     $original_fixtures = AkConfig::getDir('fixtures');
     AkConfig::setDir('fixtures', AkConfig::getDir('suite') . DS . 'fixtures');
     $this->uninstallAndInstallMigration('AdminPlugin');
     $this->Extension = new Extension();
     $this->populateTables('extensions');
     AkConfig::setDir('fixtures', $original_fixtures);
 }
Exemplo n.º 16
0
 public function test_special1()
 {
     $filename = AkConfig::getDir('fixtures') . DS . 'reflection_doc_block_test_class.php';
     $file = new AkReflectionFile($filename);
     $this->assertEqual(1, count($file->getClasses()));
     $classes = $file->getClasses();
     $this->assertEqual('ReflectionDocBlockTestClass', $classes[0]->getName());
     $class = $classes[0];
     $this->assertEqual('BaseActiveRecord', $class->getTag('ExtensionPoint'));
 }
Exemplo n.º 17
0
 public function test_should_get_all_controllers_with_their_actions()
 {
     $available_controllers = (array) AkFileSystem::dir(AkConfig::getDir('controllers'), array('dirs' => false));
     $got = $this->menu_helper->_get_default_full_menu();
     foreach ($available_controllers as $controller_filename) {
         $controller_name = str_replace('_controller.php', '', $controller_filename);
         $this->assertTrue(isset($got[$controller_name]));
     }
     $this->assertTrue(in_array('authenticate', $got['authentication']));
 }
Exemplo n.º 18
0
 public function getFilePaths()
 {
     $this->_setDefaults();
     $views_path = AkConfig::getDir('views') . DS . $this->table_name;
     $files = array($this->controller_file_name => 'controller', AkConfig::getDir('views') . DS . 'layouts' . DS . $this->table_name . '.tpl' => 'layout');
     foreach (array('_form', 'add', 'edit', 'index', 'show') as $action) {
         $files[$views_path . DS . $action . '.html.tpl'] = $action;
     }
     return $files;
 }
Exemplo n.º 19
0
 public function &recognize($Map = null)
 {
     $this->_startSession();
     $this->_enableInternationalizationSupport();
     $this->mapRoutes($Map);
     $params = $this->getParams();
     $module_path = $module_class_peffix = '';
     if (!empty($params['module'])) {
         $module_path = trim(str_replace(array('/', '\\'), DS, Ak::sanitize_include($params['module'], 'high')), DS) . DS;
         $module_shared_model = AkConfig::getDir('controllers') . DS . trim($module_path, DS) . '_controller.php';
         $module_class_peffix = str_replace(' ', '_', AkInflector::titleize(str_replace(DS, ' ', trim($module_path, DS)))) . '_';
     }
     $controller_file_name = AkInflector::underscore($params['controller']) . '_controller.php';
     $controller_class_name = $module_class_peffix . AkInflector::camelize($params['controller']) . 'Controller';
     $controller_path = AkConfig::getDir('controllers') . DS . $module_path . $controller_file_name;
     if (!empty($module_path) && file_exists($module_shared_model)) {
         include_once $module_shared_model;
     }
     if (!is_file($controller_path) || !(include_once $controller_path)) {
         AK_LOG_EVENTS && Ak::getLogger()->error('Controller ' . $controller_path . ' not found.');
         if (AK_ENVIRONMENT == 'development') {
             trigger_error(Ak::t('Could not find the file /app/controllers/<i>%controller_file_name</i> for ' . 'the controller %controller_class_name', array('%controller_file_name' => $controller_file_name, '%controller_class_name' => $controller_class_name)), E_USER_ERROR);
         } elseif (@(include AkConfig::getDir('public') . DS . '404.php')) {
             $response = new AkTestResponse();
             $response->addHeader('Status', 404);
             return false;
             //exit;
         } else {
             //header("HTTP/1.1 404 Not Found");
             $response = new AkResponse();
             $response->addHeader('Status', 404);
             return false;
             //die('404 Not found');
         }
     }
     if (!class_exists($controller_class_name)) {
         AK_LOG_EVENTS && Ak::getLogger()->error('Controller ' . $controller_path . ' does not implement ' . $controller_class_name . ' class.');
         if (AK_ENVIRONMENT == 'development') {
             trigger_error(Ak::t('Controller <i>%controller_name</i> does not exist', array('%controller_name' => $controller_class_name)), E_USER_ERROR);
         } elseif (@(include AkConfig::getDir('public') . DS . '405.php')) {
             exit;
         } else {
             $response = new AkResponse();
             $response->addHeader('Status', 405);
             return false;
             //header("HTTP/1.1 405 Method Not Allowed");
             //die('405 Method Not Allowed');
         }
     }
     $Controller = new $controller_class_name(array('controller' => true));
     $Controller->setModulePath($module_path);
     isset($_SESSION) ? $Controller->session =& $_SESSION : null;
     return $Controller;
 }
Exemplo n.º 20
0
 public function _preloadPaths()
 {
     $this->api_name = AkInflector::camelize($this->api_name);
     $this->api_class_name = $this->api_name . 'Api';
     $this->assignVarToTemplate('api_class_name', $this->api_class_name);
     $this->service_class_name = $this->api_name . 'Service';
     $this->assignVarToTemplate('service_class_name', $this->service_class_name);
     $this->api_path = AkConfig::getDir('apis') . DS . AkInflector::underscore($this->api_class_name) . '.php';
     $this->underscored_service_name = AkInflector::underscore($this->api_name);
     $this->service_path = AkConfig::getDir('models') . DS . $this->underscored_service_name . '_service.php';
 }
Exemplo n.º 21
0
 public function generate()
 {
     $this->_preloadPaths();
     $this->class_name = AkInflector::camelize($this->class_name);
     $files = array('model' => AkInflector::toModelFilename($this->class_name), 'unit_test' => AkConfig::getDir('test') . DS . 'unit' . DS . $this->test_file_name);
     if (!$this->active_document) {
         $files['installer'] = AkConfig::getDir('app_installers') . DS . $this->underscored_model_name . '_installer.php';
     }
     foreach ($files as $template => $file_path) {
         $this->save($file_path, $this->render($template));
     }
 }
Exemplo n.º 22
0
 public function _linkWebServiceApi($api)
 {
     $api_path = AkInflector::underscore($api);
     if (substr($api_path, -4) != '_api') {
         $api_name_space = $api_path;
         $api_path = $api_path . '_api';
     } else {
         $api_name_space = substr($api_path, 0, -4);
     }
     $api_class_name = AkInflector::camelize($api_path);
     require_once AkConfig::getDir('apis') . DS . $api_path . '.php';
     $this->_apis[$api_name_space] = new $api_class_name();
 }
Exemplo n.º 23
0
 /**
  * @static
  * @param array $database_settings
  * @return AkDbAdapter
  */
 static function &getInstance($database_specifications = AK_DEFAULT_DATABASE_PROFILE, $auto_connect = true, $namespace = null)
 {
     $settings_hash = is_string($database_specifications) ? $database_specifications : AkDbAdapter::hash($database_specifications);
     $static_var_name = 'AkDbAdapter_getInstance_' . $settings_hash;
     if (!($Connection = Ak::getStaticVar($static_var_name))) {
         defined('AK_DATABASE_SETTINGS_NAMESPACE') || define('AK_DATABASE_SETTINGS_NAMESPACE', 'database');
         $namespace = empty($namespace) ? AK_DATABASE_SETTINGS_NAMESPACE : $namespace;
         if (empty($database_specifications)) {
             $database_specifications = Ak::getSettings($namespace, false, $settings_hash);
         } elseif (is_string($database_specifications)) {
             $environment_settings = Ak::getSettings($namespace, false, $database_specifications);
             if (!empty($environment_settings)) {
                 $database_specifications = $environment_settings;
             } elseif (strstr($database_specifications, '://')) {
                 $database_specifications = AkDbAdapter::getDbSettingsFromDsn($database_specifications);
                 $settings_hash = AK_ENVIRONMENT;
             } else {
                 global $database_settings;
                 if (isset($database_settings) && !file_exists(AkConfig::getDir('config') . DS . $namespace . '.yml')) {
                     trigger_error(Ak::t("You are still using the old config/config.php database configuration. Please upgrade to use the config/database.yml configuration."), E_USER_NOTICE);
                 }
                 if (!file_exists(AkConfig::getDir('config') . DS . $namespace . '.yml')) {
                     trigger_error(Ak::t("Could not find the database configuration file in %dbconfig.", array('%dbconfig' => AkConfig::getDir('config') . DS . $namespace . '.yml')), E_USER_ERROR);
                 } else {
                     trigger_error(Ak::t("Could not find the database profile '%profile_name' in config/%dbfile.yml.", array('%profile_name' => $database_specifications, '%dbfile' => $namespace)), E_USER_ERROR);
                 }
                 $return = false;
                 return $return;
             }
         } elseif (!empty($database_settings[$settings_hash])) {
             $database_specifications = $database_settings[$settings_hash];
         }
         if (empty($database_specifications)) {
             trigger_error(Ak::t('Could not find database settings for %namespace.yml/%settings_hash', array('%namespace' => $namespace, '%settings_hash' => $settings_hash)), E_USER_ERROR);
         }
         // Compatibility with RoR database.yml format
         $database_specifications['user'] = isset($database_specifications['user']) ? $database_specifications['user'] : (isset($database_specifications['username']) ? $database_specifications['username'] : '');
         $database_specifications['type'] = isset($database_specifications['type']) ? $database_specifications['type'] : $database_specifications['adapter'];
         $database_specifications['database_name'] = isset($database_specifications['database_name']) ? $database_specifications['database_name'] : (isset($database_specifications['database']) ? $database_specifications['database'] : '');
         $class_name = 'Ak' . AkInflector::camelize($database_specifications['type']) . 'DbAdapter';
         $adapter_class_file = AK_ACTIVE_RECORD_DIR . DS . 'adapters' . DS . AkInflector::underscore($database_specifications['type']) . '.php';
         if (!@(include_once $adapter_class_file)) {
             trigger_error(Ak::t('Could not find database adapter file on %path', array('%path' => $adapter_class_file)), E_USER_ERROR);
         }
         $Connection = new $class_name($database_specifications, $auto_connect);
         Ak::setStaticVar($static_var_name, $Connection);
     }
     return $Connection;
 }
Exemplo n.º 24
0
 public function generate()
 {
     $this->_preloadPaths();
     $this->save(AkConfig::getDir('app') . DS . $this->controller_path, $this->render('controller'));
     $this->save(AkConfig::getDir('helpers') . DS . $this->underscored_controller_name . "_helper.php", $this->render('helper'));
     $this->save(AkConfig::getDir('test') . DS . 'functional' . DS . $this->controller_test_path, $this->render('functional_test'));
     $this->save(AkConfig::getDir('test') . DS . 'unit' . DS . 'helpers' . DS . $this->underscored_controller_name . "_helper_test.php", $this->render('helper_test'));
     @AkFileSystem::make_dir(AkConfig::getDir('views') . DS . $this->module_path . AkInflector::underscore($this->controller_name), $this->getFileOptions());
     foreach ($this->actions as $action) {
         //$this->action = $action;
         $this->assignVarToTemplate('action', $action);
         $this->assignVarToTemplate('path', 'app' . DS . 'views' . DS . $this->module_path . AkInflector::underscore($this->controller_name) . DS . $action . '.html.tpl');
         $this->save(AkConfig::getDir('views') . DS . $this->module_path . AkInflector::underscore($this->controller_name) . DS . $action . '.html.tpl', $this->render('view'));
     }
 }
Exemplo n.º 25
0
 public function _get_default_full_menu()
 {
     $controllers_dir = AkConfig::getDir('controllers');
     $controller_file_names = array_map('array_pop', (array) AkFileSystem::dir($controllers_dir, array('files' => false)));
     sort($controller_file_names);
     $menu_options = array();
     foreach ($controller_file_names as $controller_file_name) {
         $controller_name = str_replace('.php', '', $controller_file_name);
         if (strstr($controller_file_name, '_controller.php') && file_exists($controllers_dir . DS . $controller_file_name)) {
             include_once $controllers_dir . DS . $controller_file_name;
             $controller_class_name = AkInflector::classify($controller_name);
             $menu_options[str_replace('_controller', '', $controller_name)] = $this->_get_this_class_methods($controller_class_name);
         }
     }
     return $menu_options;
 }
Exemplo n.º 26
0
 public function test_all_session_handlers()
 {
     $cacheHandlers = array('cache_lite' => 1);
     if (!Ak::db() instanceof AkSqliteDbAdapter) {
         $cacheHandlers['akadodbcache'] = 2;
     }
     if (AkConfig::getOption('memcached_enabled', false)) {
         $cacheHandlers['akmemcache'] = 3;
     }
     $unitTests = array('_Test_open', '_Test_read_write', '_Test_destroy', '_Test_gc');
     foreach ($cacheHandlers as $class => $type) {
         foreach ($unitTests as $test) {
             $this->{$test}($type, $class);
         }
     }
 }
Exemplo n.º 27
0
 function generate()
 {
     //Generate models if they don't exist
     $model_files = array('model' => $this->model_file_path, 'installer' => AkConfig::getDir('app') . DS . 'installers' . DS . $this->singular_name . '_installer.php', 'model_unit_test' => AK_TEST_DIR . DS . 'unit' . DS . 'app' . DS . 'models' . DS . $this->singular_name . '.php', 'model_fixture' => AK_TEST_DIR . DS . 'fixtures' . DS . 'app' . DS . 'models' . DS . $this->singular_name . '.php', 'installer_fixture' => AK_TEST_DIR . DS . 'fixtures' . DS . 'app' . DS . 'installers' . DS . $this->singular_name . '_installer.php');
     $this->_template_vars = (array) $this;
     foreach ($model_files as $template => $file_path) {
         if (!file_exists($file_path)) {
             $this->save($file_path, $this->render($template, !empty($this->sintags)));
         }
     }
     // We check for common testing files
     $common_testing_files = array('fixtures' . DS . 'config' . DS . 'config.php', 'fixtures' . DS . 'app' . DS . 'models' . DS . 'shared_model.php');
     foreach ($common_testing_files as $common_testing_file) {
         if (!file_exists(AK_TEST_DIR . DS . $common_testing_file)) {
             $this->save(AK_TEST_DIR . DS . $common_testing_file, file_get_contents(AK_FRAMEWORK_DIR . DS . 'test' . DS . $common_testing_file));
         }
     }
     if (file_exists($this->model_file_path)) {
         require_once $this->model_file_path;
         if (class_exists($this->model_name)) {
             $ModelInstance = new $this->model_name();
             $table_name = $ModelInstance->getTableName();
             if (!empty($table_name)) {
                 $this->content_columns = $ModelInstance->getContentColumns();
                 unset($this->content_columns['updated_at'], $this->content_columns['updated_on'], $this->content_columns['created_at'], $this->content_columns['created_on']);
             }
             $internationalized_columns = $ModelInstance->getInternationalizedColumns();
             foreach ($internationalized_columns as $column_name => $languages) {
                 foreach ($languages as $lang) {
                     $this->content_columns[$column_name] = $this->content_columns[$lang . '_' . $column_name];
                     $this->content_columns[$column_name]['name'] = $column_name;
                     unset($this->content_columns[$lang . '_' . $column_name]);
                 }
             }
         }
     }
     $this->_template_vars = (array) $this;
     foreach ($this->files as $template => $file_path) {
         if (!in_array($file_path, $this->_skip_files)) {
             $this->save($file_path, $this->render($template, !empty($this->sintags)));
         }
     }
     foreach ($this->user_actions as $action => $file_path) {
         $this->assignVarToTemplate('action', $action);
         $this->save($file_path, $this->render('view', !empty($this->sintags)));
     }
 }
Exemplo n.º 28
0
 public function addService($service)
 {
     $service_file = AkInflector::underscore($service);
     if (substr($service_file, -8) != '_service') {
         $service_file = $service_file . '_service';
     }
     $service_model = AkInflector::camelize($service_file);
     $service_name_space = substr($service_file, 0, -8);
     if (empty($this->_services[$service_name_space])) {
         require_once AkConfig::getDir('models') . DS . $service_file . '.php';
         if (!class_exists($service_model)) {
             trigger_error(Ak::t('Could not find class for the service %service at %models_dir', array('%service' => $service_model, '%models_dir' => AkConfig::getDir('models')), E_USER_ERROR));
             return false;
         }
         $this->_services[$service_name_space] = new $service_model();
     }
 }
Exemplo n.º 29
0
 public function test_all_caches()
 {
     $cacheHandlers = array('cache_lite' => 1, 'akadodbcache' => 2);
     $memcacheEnabled = AkConfig::getOption('memcached_enabled', false);
     AkUnitTestSuite::createTestingDatabaseIfNotAvailable();
     if ($memcacheEnabled) {
         $cacheHandlers['akmemcache'] = 3;
     }
     $unitTests = array('_testInit', '_getAndSaveTests', '_removeTests', '_cleanTests');
     foreach ($cacheHandlers as $class => $type) {
         foreach ($unitTests as $test) {
             unset($this->Cache);
             $this->Cache = new AkCache();
             $this->{$test}($type, $class);
         }
         $this->Cache->clean($this->group);
     }
 }
Exemplo n.º 30
0
 public function test_assert_xpath()
 {
     $test_app = new MockTestApplication();
     $test_app->_response = file_get_contents(AkConfig::getDir('fixtures') . DS . 'valid_xhtml.html');
     $test_app->assertValidXhtml();
     $this->assertTrue(empty($test_app->failures));
     $this->assertTrue(count($test_app->passes) == 1);
     $test_app->assertXPath('/html');
     $test_app->assertXPath('/html/body/form');
     $test_app->assertXPath("/html/body/form[@id='test']");
     $this->assertEqual(4, count($test_app->passes));
     $test_app = new MockTestApplication();
     $test_app->_response = file_get_contents(AkConfig::getDir('fixtures') . DS . 'valid_xhtml.html');
     $test_app->assertValidXhtml();
     $this->assertTrue(empty($test_app->failures));
     $this->assertTrue(count($test_app->passes) == 1);
     $test_app->assertNoXPath("/html/body/form[@id='test']/input[@id='submit']");
     $this->assertEqual(2, count($test_app->passes));
 }