Ejemplo n.º 1
0
 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();
     }
 }
Ejemplo n.º 2
0
 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());
 }
Ejemplo n.º 3
0
 public function testScriptLoaded()
 {
     Configure::write(RestartServer::ConfigureKey, __DIR__ . '/4restart_server.php');
     //
     $api = new RestartServer();
     $api->exec();
     $this->assertTrue(self::$called);
 }
Ejemplo n.º 4
0
 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());
 }
Ejemplo n.º 5
0
 public function setUp()
 {
     parent::setUp();
     $path = EXTASY_PATH . self::CacheFolder;
     //
     $fs = DAO_FileSystem::getInstance();
     $fs->createPath($path);
     //
     Configure::write(Writer::ConfigureKey, $path);
     //
     $this->cleanStaticApplicationCacheFolder();
 }
Ejemplo n.º 6
0
 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();
 }
Ejemplo n.º 7
0
 /**
  * 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();
 }
Ejemplo n.º 8
0
 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']);
 }
Ejemplo n.º 9
0
<?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;
});
Ejemplo n.º 10
0
<?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;
Ejemplo n.º 11
0
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';
\Faid\Configure\Configure::write('UParser.tmp_dir', dirname(__DIR__) . '/runtime/');
Ejemplo n.º 12
0
 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'));
 }
Ejemplo n.º 13
0
 public function testAutoloadInstance()
 {
     Configure::write(SimpleCache::ConfigurePath, array('Engine' => '\\Faid\\tests\\Cache\\TestCacheEngine'));
     $result = SimpleCache::getInstance();
     $this->assertTrue($result instanceof TestCacheEngine);
 }
Ejemplo n.º 14
0
    // 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();
    });
}
Ejemplo n.º 15
0
 /**
  * @expectedException \Faid\Configure\ConfigureException
  */
 public function testWithEmptyConfig()
 {
     Configure::write(FileCache::ConfigurePath, null);
     new FileCache();
 }
Ejemplo n.º 16
0
 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));
 }
Ejemplo n.º 17
0
 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'));
 }
Ejemplo n.º 18
0
<?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);
Ejemplo n.º 19
0
 /**
  * @expectedException \Faid\NotFoundException
  */
 public function testAutoStartWithEmptyConfig()
 {
     Configure::write(FileStorage::ConfigureKey . '.EnineConfigs', array());
     Configure::write(FileStorage::ConfigureKey . '.default', NULL);
     FileStorage::checkInstance();
 }
Ejemplo n.º 20
0
 protected function setRunnerTimeout($value)
 {
     Configure::write(Runner::TimeoutConfigureKey, $value);
 }