Example #1
1
 protected function setUp()
 {
     define('BOOTSTRAP', true);
     define('AREA', 'A');
     define('CART_LANGUAGE', 'en');
     $this->requireCore('functions/fn.database.php');
     $this->requireMockFunction('fn_set_hook');
     $this->app = \Tygh\Tygh::createApplication();
     // // Session
     // // $this->app['session'] = new \Tygh\Web\Session($this->app);
     /**
      * Database driver
      */
     $driver = $this->getMockBuilder('\\Tygh\\Backend\\Database\\Pdo')->setMethods(array('escape', 'query', 'insertId', 'fetch', 'fetchRow', 'freeResult'))->getMock();
     $driver->method('escape')->will($this->returnCallback('addslashes'));
     $this->driver = $this->app['db.driver'] = $driver;
     /**
      * Database connection
      */
     $connection = $this->getMockBuilder('\\Tygh\\Database\\Connection')->setMethods(array('error', 'getTableFields'))->setConstructorArgs(array($driver))->getMock();
     $this->connection = $this->app['db'] = $connection;
     /**
      * Abstract model instance
      */
     $this->model = $this->getMockBuilder('\\Tygh\\Models\\Components\\AModel')->setMethods(array('getTableName', 'getPrimaryField', 'getDescriptionTableName', 'isNewRecord', 'getLangCodes'))->getMock();
     // rewrite method getTableName()
     $this->model->expects($this->any())->method('getTableName')->willReturn('fake_table');
     // rewrite method getPrimaryField()
     $this->model->expects($this->any())->method('getPrimaryField')->willReturn('fake_id');
     // rewrite method getLangCodes()
     $this->model->expects($this->any())->method('getLangCodes')->willReturn(array('en', 'ru'));
 }
Example #2
1
 protected function setUp()
 {
     define('BOOTSTRAP', true);
     define('AREA', 'A');
     define('CART_LANGUAGE', 'en');
     $this->requireCore('functions/fn.database.php');
     $this->requireCore('functions/fn.cms.php');
     $this->requireMockFunction('fn_set_hook');
     $this->requireMockFunction('fn_get_area_name');
     $this->requireMockFunction('fn_get_company_condition');
     $this->requireMockFunction('fn_get_schema');
     $this->requireMockFunction('fn_string_not_empty');
     $this->app = \Tygh\Tygh::createApplication();
     // Session (need for LastView)
     $this->app['session'] = new \Tygh\Web\Session($this->app);
     // Driver
     $driver = $this->getMockBuilder('\\Tygh\\Backend\\Database\\Pdo')->setMethods(array('escape', 'query', 'insertId'))->getMock();
     $driver->method('escape')->will($this->returnCallback('addslashes'));
     $this->app['db.driver'] = $driver;
     // Connection
     $this->app['db'] = $this->getMockBuilder('\\Tygh\\Database\\Connection')->setMethods(array('error'))->setConstructorArgs(array($driver))->getMock();
 }
Example #3
1
 /**
  * Init's applicaion // FIXME: Bad method...
  *
  * @param  array $params Params for initiate installer
  * @return bool  Always true
  */
 public function init($params = array())
 {
     if (defined('INSTALLER_INITED')) {
         return true;
     }
     $config = array();
     define('AREA', 'A');
     define('ACCOUNT_TYPE', 'admin');
     date_default_timezone_set('Europe/Moscow');
     $base_path = isset($params['base_path']) ? $params['base_path'] : realpath(dirname(__FILE__) . '/../../../');
     // Register autoloader
     $classLoader = (require $base_path . '/app/lib/vendor/autoload.php');
     $classLoader->add('Tygh', realpath($base_path . '/app'));
     class_alias('\\Tygh\\Tygh', 'Tygh');
     // Prepare environment and process request vars
     list($_REQUEST, $_SERVER) = Bootstrap::initEnv($_GET, $_POST, $_SERVER, $base_path);
     if (defined('CONSOLE')) {
         chdir(getcwd() . '/install');
     }
     // Get config data
     $config = (require DIR_ROOT . '/config.php');
     if (isset($_REQUEST['version'])) {
         die(PRODUCT_NAME . ': version <b>' . PRODUCT_VERSION . ' ' . PRODUCT_EDITION . (PRODUCT_STATUS != '' ? ' (' . PRODUCT_STATUS . ')' : '') . (PRODUCT_BUILD != '' ? ' ' . PRODUCT_BUILD : '') . '</b>');
     }
     // Callback: verifies if https works
     if (isset($_REQUEST['check_https'])) {
         die(defined('HTTPS') ? 'OK' : '');
     }
     // Load core functions
     $fn_list = array('fn.addons.php', 'fn.companies.php', 'fn.database.php', 'fn.fs.php', 'fn.cms.php', 'fn.cart.php', 'fn.common.php', 'fn.control.php', 'fn.init.php', 'fn.users.php', 'fn.images.php', 'fn.log.php');
     if (PRODUCT_EDITION == 'MULTIVENDOR' || PRODUCT_EDITION == 'ULTIMATE') {
         $fn_list[] = 'fn.' . strtolower(PRODUCT_EDITION) . '.php';
     }
     foreach ($fn_list as $file) {
         require $config['dir']['functions'] . $file;
     }
     $config['dir']['install_themes'] = is_dir($config['dir']['root'] . '/var/themes_repository') ? $config['dir']['root'] . '/var/themes_repository' : $config['dir']['root'] . '/themes';
     $config['dir']['install'] = $config['dir']['root'] . '/install/';
     $classLoader->add('', $config['dir']['install'] . 'app/');
     Registry::set('config', $config);
     $application = Tygh::createApplication();
     $application['class_loader'] = $classLoader;
     $session_id = session_id();
     if (empty($session_id)) {
         session_start();
     }
     fn_init_ajax();
     // Init storage
     Registry::set('runtime.storage', array('storage' => 'file'));
     if (!empty($params['sl'])) {
         $this->setCurrentLangCode($params['sl']);
     } elseif ($this->getFromStorage('sl')) {
         $this->setCurrentLangCode($this->getFromStorage('sl'));
     } else {
         $this->setCurrentLangCode(self::DEFAULT_LANGUAGE);
     }
     $this->_loadLanguageVariables();
     //define DEFAULT_LANGUAGE for correct addon installing
     if (!defined('DEFAULT_LANGUAGE')) {
         define('DEFAULT_LANGUAGE', self::DEFAULT_LANGUAGE);
     }
     define('INSTALLER_INITED', true);
     unset($config);
 }