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'); }
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); }
public function __construct() { parent::__construct(); foreach (glob(AkConfig::getDir('config') . '/locales/*.php') as $file) { $this->original_locales[$file] = file_get_contents($file); } }
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'); }
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); } }
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); } }
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; }
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'); } } }
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()); }
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(); }
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); }
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')); }
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; }
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'])); }
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; }
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'; }
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)); } }
public function tearDown() { AkFileSystem::file_delete($this->_base_config_path . DS . 'testing' . DS . 'testconfig1.php', array('base_path' => $this->_base_config_path)); AkFileSystem::file_delete($this->_base_config_path . DS . 'development' . DS . 'testconfig1.php', array('base_path' => $this->_base_config_path)); AkFileSystem::file_delete($this->_base_config_path . DS . 'production' . DS . 'testconfig1.php', array('base_path' => $this->_base_config_path)); AkFileSystem::rmdir_tree($this->_base_config_path . DS . 'testing'); AkFileSystem::rmdir_tree($this->_base_config_path . DS . 'development'); AkFileSystem::rmdir_tree($this->_base_config_path . DS . 'production'); AkFileSystem::file_delete(AkConfig::getDir('config') . DS . 'testconfig1.yml', array('base_path' => $this->_base_config_path)); AkFileSystem::rmdir_tree($this->_base_config_path); AkFileSystem::rmdir_tree(AkConfig::getDir('tmp') . DS . 'ak_config'); }
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(); }
/** * Attempts to render a static error page based on the * <tt>$this->getStatusCode</tt> thrown, or just return headers if no such file * exists. At first, it will try to render a localized static page. * For example, if a 500 error is being handled Rails and locale is :da, * it will first attempt to render the file at <tt>public/500.da.html</tt> * then attempt to render <tt>public/500.html</tt>. If none of them exist, * the body of the response will be left empty. */ public function rescueActionInPublic($Exception) { $status = $this->getStatusCode($Exception); $locale_path = AkConfig::getDir('public') . '/' . $status . '_' . Ak::lang() . '.html'; $path = AkConfig::getDir('public') . '/' . $status . '.html'; if (file_exists($locale_path)) { $this->render($status, file_get_contents($locale_path)); } elseif (file_exists($path)) { $this->render($status, file_get_contents($path)); } else { $this->render($status, ''); } }
/** * @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; }
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')); } }
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; }
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))); } }
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(); } }
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)); }
public function __construct() { parent::__construct(); $this->fixtures_base = AkConfig::getDir('fixtures') . DS . 'Image_TestCase'; if (!($this->offline_mode = !@file_get_contents('http://www.akelos.org/testing_resources/images/watermark.png'))) { $this->image_path = $this->fixtures_base . DS . 'akelos_framework_logo.png'; $this->photo_path = $this->fixtures_base . DS . 'cristobal.jpg'; $this->watermark = $this->fixtures_base . DS . 'watermark.png'; AkFileSystem::copy(AkConfig::getDir('fixtures') . '/old_logo.png', $this->image_path, array('base_path' => AK_FRAMEWORK_DIR)); $cristobal = @Ak::url_get_contents('http://www.akelos.org/testing_resources/images/cristobal.jpg', array('cache' => 100000)); if (!empty($cristobal)) { AkFileSystem::file_put_contents($this->photo_path, $cristobal, array('base_path' => AK_FRAMEWORK_DIR)); } $watermark = @Ak::url_get_contents('http://www.akelos.org/testing_resources/images/watermark.png', array('cache' => 100000)); if (!empty($watermark)) { AkFileSystem::file_put_contents($this->watermark, $watermark, array('base_path' => AK_FRAMEWORK_DIR)); } $this->_run_extra_tests = file_exists($this->photo_path); } }
public function test_should_establish_multiple_connections() { $db_file_existed = false; if (file_exists(AkConfig::getDir('config') . DS . 'database.yml')) { $db_file_existed = true; $db_settings = Ak::convert('yaml', 'array', AkConfig::getDir('config') . DS . 'database.yml'); } $db_settings['sqlite_databases'] = array('database_file' => AK_TMP_DIR . DS . 'testing_sqlite_database.sqlite', 'type' => 'sqlite'); file_put_contents(AkConfig::getDir('config') . DS . 'database.yml', Ak::convert('array', 'yaml', $db_settings)); @unlink(AK_TMP_DIR . DS . 'testing_sqlite_database.sqlite'); $this->installAndIncludeModels(array('TestOtherConnection')); Ak::import('test_other_connection'); $OtherConnection = new TestOtherConnection(array('name' => 'Delia')); $this->assertTrue($OtherConnection->save()); $this->installAndIncludeModels(array('DummyModel' => 'id,name')); $Dummy = new DummyModel(); $this->assertNotEqual($Dummy->getConnection(), $OtherConnection->getConnection()); unset($db_settings['sqlite_databases']); if ($db_file_existed) { file_put_contents(AkConfig::getDir('config') . DS . 'database.yml', Ak::convert('array', 'yaml', $db_settings)); } else { unlink(AkConfig::getDir('config') . DS . 'database.yml'); } }
private function _getdocPath($doc_name, $language) { $doc_name = AkInflector::underscore($language != 'en' ? Ak::untranslate($doc_name, $language) : $doc_name); return AkConfig::getDir('docs') . DS . (empty($this->docs_path) ? '' : trim($this->docs_path, DS) . DS) . $language . DS . $doc_name . '.textile'; }
static function toHelperFilename($name) { return AkConfig::getDir('app') . DS . 'helpers' . DS . AkInflector::underscore($name) . '_helper.php'; }