コード例 #1
0
 /**
  * Standard set up method. Calls parent first.
  */
 public function setUp()
 {
     parent::setUp();
     $configFile = Registry::get("oxConfigFile");
     $configFile->setVar('sShopDir', realpath(__DIR__ . '/TestData'));
     Registry::set('oxConfigFile', $configFile);
     $this->environment = new Environment();
 }
コード例 #2
0
 /**
  * Tests OxReg::get() and OxReg::set()
  */
 public function testSetGetInstance()
 {
     $oTest = new stdClass();
     $oTest->testPublic = "testPublicVal";
     Registry::set("testCase", $oTest);
     $oTest2 = Registry::get("testCase");
     $this->assertEquals("testPublicVal", $oTest2->testPublic);
 }
コード例 #3
0
    protected function createModuleClassFile($extensionPath)
    {
        $modulesDirectory = Registry::get("oxConfigFile")->getVar("sShopDir");
        $moduleClassFilePath = "{$modulesDirectory}/modules/{$extensionPath}.php";
        if (!is_dir(dirname($moduleClassFilePath))) {
            if (!mkdir(dirname($moduleClassFilePath), 0755, true)) {
                return false;
            }
        }
        $class = basename($extensionPath);
        $classDefinition = <<<EOT
            <?php
            /** 
             * This file is generated by \\Unit\\Core\\ModuleChainsGeneratorTest::testCreateClassChain and it should have 
             * been deleted after the test run.
             */
            class {$class} extends {$class}_parent {}

EOT;
        if (!file_put_contents($moduleClassFilePath, $classDefinition)) {
            return false;
        }
        return $moduleClassFilePath;
    }
コード例 #4
0
 /**
  * Returns request url, which was executed to render current page view
  *
  * @param string $sParams     Parameters to object
  * @param bool   $blReturnUrl If return url
  *
  * @deprecated since v6.0.0 (2016-05-16); Use OxidEsales\EshopCommunity\Core\Request::getRequestUrl().
  *
  * @return string
  */
 function getRequestUrl($sParams = '', $blReturnUrl = false)
 {
     return Registry::get(Request::class)->getRequestUrl($sParams, $blReturnUrl);
 }
コード例 #5
0
ファイル: Config.php プロジェクト: Alpha-Sys/oxideshop_ce
 /**
  * Redirect to start page and display the error
  *
  * @param oxException $ex message to show on exit
  */
 protected function _handleCookieException($ex)
 {
     $this->_processSeoCall();
     //starting up the session
     $this->getSession()->start();
     // redirect to start page and display the error
     Registry::get("oxUtilsView")->addErrorToDisplay($ex);
     Registry::getUtils()->redirect($this->getShopHomeUrl() . 'cl=start', true, 302);
 }
コード例 #6
0
 /**
  * Get an instance of the config file.
  *
  * @throws DatabaseNotConfiguredException
  *
  * @return ConfigFile
  */
 protected function fetchConfigFile()
 {
     /**
      * Do the configuration of the database connection parameters
      */
     /** @var ConfigFile $configFile */
     $configFile = Registry::get('oxConfigFile');
     return $configFile;
 }
コード例 #7
0
 public function testGetDbThrowsDatabaseNotConfiguredException()
 {
     /** @var ConfigFile $configFileBackup Backup of the configFile as stored in Registry. This object must be restored */
     $configFileBackup = Registry::get('oxConfigFile');
     $configFile = $this->getBlankConfigFile();
     $configFile->setVar('dbHost', '<');
     Registry::set('oxConfigFile', $configFile);
     $this->setProtectedClassProperty(oxDb::getInstance(), 'db', null);
     $this->setExpectedException('OxidEsales\\EshopCommunity\\Core\\Exception\\DatabaseNotConfiguredException');
     try {
         oxDb::getDb();
     } catch (DatabaseNotConfiguredException $exception) {
         /** Restore original configFile object */
         Registry::set('oxConfigFile', $configFileBackup);
         throw $exception;
     }
 }
コード例 #8
0
 /**
  * Check for forced edition in config file. If edition is not specified,
  * determine it by ClassMap existence.
  *
  * @return string
  */
 protected function findEdition()
 {
     if (!class_exists('OxidEsales\\EshopCommunity\\Core\\Registry') || !Registry::instanceExists('oxConfigFile')) {
         $configFile = new ConfigFile(getShopBasePath() . "config.inc.php");
     }
     $configFile = isset($configFile) ? $configFile : Registry::get('oxConfigFile');
     $edition = $configFile->getVar('edition') ?: $this->findEditionByClassMap();
     $configFile->setVar('edition', $edition);
     return strtoupper($edition);
 }
コード例 #9
0
 public function testCharsetIsUtf8()
 {
     $character_set = 'utf8';
     $configFile = Registry::get('oxConfigFile');
     $this->resetDbProperty(oxDb::getInstance());
     $database = oxDb::getInstance();
     $database->setConfigFile($configFile);
     $databaseConnection = $database::getDb(oxDb::FETCH_MODE_ASSOC);
     $actualResult = $databaseConnection->getRow('SHOW VARIABLES LIKE \'character_set_client\'');
     $this->assertEquals($character_set, $actualResult['Value'], 'As shop is in utf-8 mode, character_set_client is ' . $character_set);
     $actualResult = $databaseConnection->getRow('SHOW VARIABLES LIKE \'character_set_results\'');
     $this->assertEquals($character_set, $actualResult['Value'], 'As shop is in utf-8 mode, character_set_results is ' . $character_set);
     $actualResult = $databaseConnection->getRow('SHOW VARIABLES LIKE \'character_set_connection\'');
     $this->assertEquals($character_set, $actualResult['Value'], 'As shop is in utf-8 mode, character_set_client is ' . $character_set);
 }
コード例 #10
0
 /**
  * Send an offline warning to the shop owner.
  * Currently an email is sent to the email address configured as 'sAdminEmail' in the eShop config file.
  *
  * This method forms part of the exception handling process. Any further exceptions must be caught.
  *
  * @param StandardException $exception
  *
  * @return bool Returns true, if the email was sent.
  */
 protected function sendOfflineWarning(StandardException $exception)
 {
     $result = false;
     /** @var  $emailAddress Email address to sent the message to */
     $emailAddress = Registry::get("OxConfigFile")->getVar('sAdminEmail');
     if ($emailAddress) {
         /** As we are inside the exception handling process, any further exceptions must be caught */
         try {
             $failedShop = isset($_REQUEST['shp']) ? addslashes($_REQUEST['shp']) : 'Base shop';
             $date = date(DATE_RFC822);
             // RFC 822 (example: Mon, 15 Aug 05 15:52:01 +0000)
             $script = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING'];
             $referrer = $_SERVER['HTTP_REFERER'];
             //sending a message to admin
             $emailSubject = 'Offline warning!';
             $emailBody = "\n                Database connection error in OXID eShop:\n                Date: {$date}\n                Shop: {$failedShop}\n\n                mysql error: " . $exception->getMessage() . "\n                mysql error no: " . $exception->getCode() . "\n\n                Script: {$script}\n                Referrer: {$referrer}";
             $mailer = new PHPMailer();
             $mailer->isMail();
             $mailer->setFrom($emailAddress);
             $mailer->addAddress($emailAddress);
             $mailer->Subject = $emailSubject;
             $mailer->Body = $emailBody;
             /** Set the priority of the message
              * For most clients expecting the Priority header:
              * 1 = High, 2 = Medium, 3 = Low
              * */
             $mailer->Priority = 1;
             /** MS Outlook custom header */
             $mailer->addCustomHeader("X-MSMail-Priority: Urgent");
             /** Set the Importance header: */
             $mailer->addCustomHeader("Importance: High");
             $result = $mailer->send();
         } catch (\Exception $exception) {
             $this->logException($exception);
         }
     }
     return $result;
 }
 /**
  * Get a PDO instance representing a connection to the database.
  * Use this static method to access the database without using the shop adapters.
  *
  * @return \PDO PDO instance.
  */
 protected static function getDatabaseHandler()
 {
     $configFile = Registry::get('oxConfigFile');
     $dsn = 'mysql:host=' . $configFile->getVar('dbHost') . ';dbname=' . $configFile->getVar('dbName');
     $username = $configFile->getVar('dbUser');
     $password = $configFile->getVar('dbPwd');
     $dbh = new \PDO($dsn, $username, $password);
     return $dbh;
 }