public function setUp() { parent::setUp(); $model = new TestDocument(); $model->createDatabaseTable(true); Helper::dbFixture(SITEMAP_TABLE, []); \ACL::create(SitemapModel::PermissionName); Configure::write('Sitemap', ['Menu' => ['title' => self::Title, 'depth' => 3]]); Helper::setupUsers([['login' => self::AdminUser, 'rights' => [SitemapModel::PermissionName => true]], ['login' => self::GuestUser]]); $documents = [['name' => 'first', 'sitemap' => ['count' => 1]], ['name' => 'second'], ['name' => 'third', 'sitemap' => ['parent' => 1]]]; foreach ($documents as $key => $row) { $documents[$key] = new TestDocument($row); $documents[$key]->insert(); $sitemapModel = new SitemapModel(); $sitemapModel->name = $row['name']; $sitemapModel->full_url = $row['name']; $sitemapModel->linkToModel($documents[$key]); if (isset($row['sitemap'])) { foreach ($row['sitemap'] as $key => $value) { $sitemapModel->{$key} = $value; } } $sitemapModel->insert(); } }
public function testHelperConfigurable() { Configure::write(SitemapTemplateHelper::ConfigureKey, ''); $this->assertEquals(SitemapTemplateHelper::getViewPath(), SitemapTemplateHelper::getViewPath()); // Configure::write(SitemapTemplateHelper::ConfigureKey, self::getViewPath()); $this->assertEquals($this->getViewPath(), SitemapTemplateHelper::getViewPath()); }
public function testScriptLoaded() { Configure::write(RestartServer::ConfigureKey, __DIR__ . '/4restart_server.php'); // $api = new RestartServer(); $api->exec(); $this->assertTrue(self::$called); }
public function testOutputFolderConfigurable() { Configure::write(Writer::ConfigureKey, ''); $result = SYS_ROOT . Writer::AppFolderName; $this->assertEquals($result, Writer::getCacheFolderPath()); $fixture = 'hello'; Configure::write(Writer::ConfigureKey, $fixture); $this->assertEquals($fixture, Writer::getCacheFolderPath()); }
public function setUp() { parent::setUp(); $path = EXTASY_PATH . self::CacheFolder; // $fs = DAO_FileSystem::getInstance(); $fs->createPath($path); // Configure::write(Writer::ConfigureKey, $path); // $this->cleanStaticApplicationCacheFolder(); }
public static function restore() { $data = array('Audit' => array('notification_emails' => '', 'maximumLogLength' => 65536), 'Security' => array('salt' => '123', 'LoginAttempts' => array('PerSession' => 5, 'PerHost' => 10), 'DDosDetector' => ['MaxConnections' => 1000, 'Message' => '', 'Period' => '1 minute']), 'Schedule' => array('runningFlag' => '0'), 'Sitemap' => array('visible' => 'false'), 'email' => array('use_standart_mail_function' => 0, 'enable_ssl' => 0, 'smtp_server' => 0, 'smtp_port' => '', 'smtp_user' => '', 'smtp_password' => '', 'from_email' => '', 'from_name' => ''), 'Front-end' => array('enable_debug' => true, 'pack' => 0, 'technical_message' => '', 'need_cms_auth' => false)); self::restorePath('/System/', $data); $applicationImport = array('users' => array('captcha_provider' => 'none', 'registration_need_email' => 1, 'front-end' => ['account_confirmation' => 1, 'account_registration_success_email' => 0])); self::restorePath('/Applications/', $applicationImport); self::restoreImageColumnConfig(); $usersConfig = array('table' => \UserAccount::TableName, 'fields' => array('id' => '\\Extasy\\Columns\\Index', 'login' => '\\Extasy\\Users\\Columns\\Login', 'email' => '\\Extasy\\Users\\Columns\\Email', 'new_email' => '\\Extasy\\Columns\\Input', 'name' => '\\Extasy\\Columns\\Input', 'avatar' => array('class' => '\\Extasy\\Columns\\Image', 'base_dir' => 'users/', 'images' => ''), 'password' => '\\Extasy\\Columns\\Password', 'rights' => '\\GrantColumn', 'last_activity_date' => '\\Extasy\\Columns\\Datetime', 'confirmation_code' => '\\Extasy\\Users\\Columns\\ConfirmationCode', 'email_confirmation_code' => '\\Extasy\\Columns\\Input', 'time_access' => '\\Extasy\\Users\\Columns\\TimeAccess', 'social_networks' => '\\Extasy\\Users\\Columns\\SocialNetworks')); Configure::write(\UserAccount::ModelConfigureKey, $usersConfig); $data = array('cconfig' => array('user_control_path' => array())); self::restorePath('/Applications/', $data); \SystemRegisterSample::createCache(); }
/** * Sets default config values */ public static function setDefaults() { // Write default config Configure::write('Debug', false); Configure::write('Error.Handler', array('\\Faid\\Debug\\Debug', 'errorHandler')); Configure::write('Error.Level', E_ALL | E_WARNING | E_STRICT); Configure::write('Exception.Handler', array('\\Faid\\Debug\\Debug', 'exceptionHandler')); Configure::write('Exception.Renderer', '\\Faid\\Debug\\ExceptionRenderer'); Configure::write('Error.Renderer', '\\Faid\\Debug\\ErrorRenderer'); Configure::write('FatalError.Handler', null); // Link exception and error event handlers self::linkErrorHandlers(); // register handler for fatal errors self::registerShutdown(); // setup event listener for changing events self::setEventListeners(); }
public function testLastRecordsReturned() { $count = 2; $data = ['first', 'second', 'third']; foreach ($data as $row) { $job = new TestAction(); $job->hash = $row; $job->insert(); } Configure::write(Latests::ConfigureKey, $count); $api = new Latests(); $result = $api->exec(); // $this->assertTrue(is_array($result)); $this->assertEquals(2, sizeof($result)); // check order $this->assertEquals(3, $result[0]['id']); $this->assertEquals('third', $result[0]['hash']); $this->assertEquals(2, $result[1]['id']); $this->assertEquals('second', $result[1]['hash']); }
<?php use Faid\Configure\Configure; if ($_SERVER['argc'] > 0) { define('CLI_MODE', true); } require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/baseTest.php'; Configure::write('Debug', true); Configure::write('Error.Handler', function ($errno, $errstr, $errfile = '', $errline = '') { var_dump($errno); var_dump($errstr); var_dump($errfile); var_dump($errline); printf('%s[ %d ] %d: %s', $errfile, $errline, $errno, $errstr); die; }); Configure::write('Exception.Handler', function ($e) { var_dump($e); die; }); Configure::write('FatalError.Handler', function ($message, $file, $line) { $error = sprintf('FAID: Fatal error catched "%s" at : "%s:%d"', $message, $file, $line); print $error; die; });
<?php use Faid\Dispatcher\Dispatcher; use Extasy\Request; use Extasy\CMS; use Faid\Configure\Configure; $_SERVER['TESTS'] = true; // Установка времени (необходимо с PHP 5.3) date_default_timezone_set('Europe/Madrid'); require_once dirname(__FILE__) . '/../src/bootstrap.php'; Configure::write('Debug', true); // PHPUnit tries to backup global variables during testing // But PHP not allows to serialize closure functions, exception raises // So any global variable with closure inside will crash PHPUnit $dispatcher = null; include __DIR__ . '/../bootstrap_samples/test-environment.php'; $request = new Request(); $dispatcher = new Dispatcher($request); new CMS($dispatcher, 'tests'); // phpunit tries to serialize global variables // $dispatcher could contain closures, so this global variable will break PHPUnit $dispatcher = null;
<?php require_once dirname(__DIR__) . '/vendor/autoload.php'; \Faid\Configure\Configure::write('UParser.tmp_dir', dirname(__DIR__) . '/runtime/');
public static function setUp() { Configure::write('Error.Handler', array(self::ClassName, 'onError')); Configure::write('Exception.Handler', array(self::ClassName, 'onException')); Configure::write('FatalError.Handler', array(self::ClassName, 'onFatalError')); }
public function testAutoloadInstance() { Configure::write(SimpleCache::ConfigurePath, array('Engine' => '\\Faid\\tests\\Cache\\TestCacheEngine')); $result = SimpleCache::getInstance(); $this->assertTrue($result instanceof TestCacheEngine); }
// SITEMAP constants define('SITEMAP_TABLE', 'sitemap'); define('SITEMAP_SCRIPT_CHILD_TABLE', 'sitemap_scripts_child'); define('SITEMAP_HISTORY_TABLE', 'sitemap_history'); // Custom Config define('CCONFIG', 'cconfig'); define('CCONFIG_SCHEMA_TABLE', 'custom_config_schema'); define('CCONFIG_TABSHEETS_TABLE', 'custom_config_groups'); define('CCONFIG_CONTROL_TABLE', 'custom_config_items'); define('CCONFIG_CONTROLS_PATH', LIB_PATH . 'custom_config/controls/'); // define('USERS', 'users'); define('USERS_TABLE', 'users'); // Core packages require_once LIB_PATH . 'kernel/extasy.php'; // Trace::start(); // Configure::write('Schedule.AutoloadScriptPath', APPLICATION_PATH . 'scheduleRestart.php'); Configure::write('Exception.Handler', array('\\Extasy\\errors\\Handlers', 'onException')); Configure::write('Error.Handler', array('\\Extasy\\errors\\Handlers', 'onError')); Configure::write('FatalError.Handler', array('\\Extasy\\errors\\Handlers', 'onFatalError')); require_once LIB_PATH . 'ClassLocator.php'; require_once LIB_PATH . 'Autoloader.php'; \Extasy\Autoloader::startup(); Debug::enable(); \EventController::addRuntimeEventListener(\Extasy\Api\ApiOperation::EventName, function () { \Extasy\Audit\Api\ApiOperation::startUp(); \Extasy\Users\UsersModule::initAPI(); }); }
/** * @expectedException \Faid\Configure\ConfigureException */ public function testWithEmptyConfig() { Configure::write(FileCache::ConfigurePath, null); new FileCache(); }
public function testPrefixesSupported() { $key = 'test'; $fixtureA = 'Hello'; $fixtureB = 'World!'; $configA = $this->config; $configA['prefix'] = 'a'; $configB = $this->config; $configB['prefix'] = 'b'; // Configure::write(Memcache::ConfigurePath, $configA); $instance = new Memcache(); $instance->set($key, $fixtureA); Configure::write(Memcache::ConfigurePath, $configB); $instance = new Memcache(); $instance->set($key, $fixtureB); // Configure::write(Memcache::ConfigurePath, $configA); $instance = new Memcache(); $this->assertEquals($instance->get($key), $fixtureA); // Configure::write(Memcache::ConfigurePath, $configB); $instance = new Memcache(); $this->assertEquals($instance->get($key), $fixtureB); $this->AssertTrue($instance->isActual($key)); $instance->clear($key); $this->AssertFalse($instance->isActual($key)); Configure::write(Memcache::ConfigurePath, $configA); $instance = new Memcache(); $this->assertEquals($instance->get($key), $fixtureA); $this->AssertTrue($instance->isActual($key)); $instance->clear($key); $this->AssertFalse($instance->isActual($key)); }
public function testSetAndEditArrays() { $data = array('item1' => 1, 'item2' => 2, 'item3' => 3, 'level2' => array('subitem' => 3, 'sublevel' => array(1, 2, 3))); Configure::write('test', $data); $this->assertEquals($data['level2'], Configure::read('test.level2')); }
<?php use Faid\Configure\Configure; require_once 'vendor/autoload.php'; $db = array('host' => 'localhost', 'socket' => '/Applications/MAMP/tmp/mysql/mysql.sock', 'user' => 'extasy', 'password' => '', 'database' => 'extasy'); $cacheConfig = array('Engine' => '\\Faid\\Cache\\Engine\\FileCache', 'FileCache' => array('BaseDir' => __DIR__ . '/runtime/')); Configure::write('DB', $db); Configure::write('SimpleCache', $cacheConfig);
/** * @expectedException \Faid\NotFoundException */ public function testAutoStartWithEmptyConfig() { Configure::write(FileStorage::ConfigureKey . '.EnineConfigs', array()); Configure::write(FileStorage::ConfigureKey . '.default', NULL); FileStorage::checkInstance(); }
protected function setRunnerTimeout($value) { Configure::write(Runner::TimeoutConfigureKey, $value); }