/**
  * Tear down the fixture.
  */
 protected function tearDown()
 {
     modDB::getInstance()->cleanup();
     oxDb::getDb()->execute('delete from oxseo where oxtype != "static"');
     oxDb::getDb()->execute('delete from oxobject2seodata');
     oxDb::getDb()->execute('delete from oxseohistory');
     $this->cleanUpTable('oxcategories');
     parent::tearDown();
 }
 /**
  * oxDebugDb class is not used in normal eshop execution,
  * thus we check only getWarning() method results
  */
 public function testGetWarnings()
 {
     modDB::$unitMOD = false;
     $oSubj = oxNew('oxDebugDb');
     $aOut = $oSubj->getWarnings();
     $this->assertEquals(4, count($aOut));
     $this->assertEquals(1, $aOut[0]['time']);
     $this->assertEquals('MESS', $aOut[0]['check']);
     $this->assertEquals('MESS', $aOut[1]['check']);
     $this->assertEquals('MESS_ALL', $aOut[2]['check']);
     $this->assertEquals('MESS_ALL', $aOut[3]['check']);
 }
Beispiel #3
0
 /**
  * Tear down the fixture.
  */
 protected function tearDown()
 {
     if ($this->getName() == 'testUpdateAndSeoIsOn') {
         $oDB = oxDb::getDb();
         $oDB->execute("delete from oxseo where oxtype != 'static'");
         $oDB->execute("delete from oxarticles where oxid='testa'");
         $oDB->execute("delete from oxartextends where oxid='testa'");
     }
     if ($this->getName() == "testMultilangObjectDeletion") {
         $this->_deleteTestLanguage();
     }
     parent::tearDown();
     modDB::getInstance()->cleanup();
 }
 /**
  * Testing oxShopControl::start()
  *
  * @return null
  */
 public function testStartIsAdmin()
 {
     $this->setRequestParameter('cl', null);
     $this->setRequestParameter('fnc', "testFnc");
     $this->getSession()->setVariable('actshop', null);
     oxTestModules::addFunction('oxUtils', 'redirect', '{ throw new Exception("Error in testStart()"); }');
     modDB::getInstance()->addClassFunction('getOne', create_function('$x', 'return 2;'));
     $oConfig = $this->getMock("oxConfig", array("getShopHomeUrl"));
     //$oConfig->expects( $this->never() )->method( 'getShopId' )->will( $this->returnValue( 999 ) );
     $oConfig->expects($this->never())->method('getShopHomeUrl');
     $oControl = $this->getMock("oxShopControl", array("getConfig", "_runOnce", "isAdmin", "_process"), array(), '', false);
     $oControl->expects($this->any())->method('getConfig')->will($this->returnValue($oConfig));
     $oControl->expects($this->once())->method('_runOnce');
     $oControl->expects($this->once())->method('isAdmin')->will($this->returnValue(true));
     $oControl->expects($this->once())->method('_process')->with($this->equalTo("login"), $this->equalTo("testFnc"));
     $oControl->start();
     //$this->assertEquals( $this->getConfig()->getBaseShopId(), $this->getSession()->getVariable( "actshop" ) );
 }
 public function testPrepareUriFiltersRootFilesAndReservedKeywords()
 {
     oxTestModules::publicize('oxSeoEncoder', '_prepareUri');
     oxTestModules::addFunction('oxSeoEncoder', '_trimUrl', '{return ltrim($aA[0], "u");}');
     $oDb = modDB::getInstance();
     $oDb->addClassFunction('GetOne', array($this, '__SaveToDbCreatesGoodMd5Callback'));
     $iShopId = $this->getConfig()->getBaseShopId();
     $oE = oxNew('oxseoencoder');
     $this->aSQL = array();
     $this->aRET = array(false);
     $this->assertEquals('admin-oxid/aa.html', $oE->p_prepareUri('admin/aa.html'), '');
     $oE = oxNew('oxseoencoder');
     $this->aSQL = array();
     $this->aRET = array(false);
     $this->assertEquals('index-php/aa/', $oE->p_prepareUri('index.php/aa'), '');
     $oE = oxNew('oxseoencoder');
     $this->aSQL = array();
     $this->aRET = array(false);
     $this->assertEquals('index-php/', $oE->p_prepareUri('index.php'), '');
     $oE = oxNew('oxseoencoder');
     $this->aSQL = array();
     $this->aRET = array(false);
     $this->assertEquals('/index-oxid/aa.html', $oE->p_prepareUri('/index/aa.html'), '');
     $oE = oxNew('oxseoencoder');
     $this->aSQL = array();
     $this->aRET = array(false);
     $this->assertEquals('/index-php/aa.html', $oE->p_prepareUri('/index.php/aa.html'), '');
     $oE = oxNew('oxseoencoder');
     $this->aSQL = array();
     $this->aRET = array(false);
     $this->assertEquals('/index-oxid/', $oE->p_prepareUri('/index/'), '');
     $oE = oxNew('oxseoencoder');
     $this->aSQL = array();
     $this->aRET = array(false);
     $this->assertEquals('/index-oxid/', $oE->p_prepareUri('/index'), '');
     $oE = oxNew('oxseoencoder');
     $this->aSQL = array();
     $this->aRET = array(false);
     $this->assertEquals('index-oxid/', $oE->p_prepareUri('--index'), '');
     $oE = oxNew('oxseoencoder');
     $oE->setSeparator('/');
     $this->aSQL = array();
     $this->aRET = array(false);
     $this->assertEquals('/index_oxid/aa.html', $oE->p_prepareUri('/index/aa.html'), '');
     $cl = oxTestModules::addFunction('oxSeoEncoder', 'clean_aReservedEntryKeys', '{oxSeoEncoder::$_aReservedEntryKeys = null;}');
     $oE = new $cl();
     $oE->clean_aReservedEntryKeys();
     $oE->setReservedWords(array('keyword1', 'keyword2'));
     $oE->setSeparator('+');
     $this->aSQL = array();
     $this->aRET = array(false);
     $this->assertEquals('/keyword1+oxid/keyword1+s+keyword2/aa+keyword1.html', $oE->p_prepareUri('/keyword1/keyword1-s.keyword2/aa-keyword1.html'), '');
     $this->assertEquals('/keyword2+oxid/', $oE->p_prepareUri('/keyword2'), '');
 }
 /**
  * Test get filter sql.
  *
  * @return null
  */
 public function testGetFilterSql()
 {
     $sCatId = $this->getTestConfig()->getShopEdition() == 'EE' ? '30e44ab85808a1f05.26160932' : '8a142c3e60a535f16.78077188';
     $oTest = $this->getProxyClass('oxArticleList');
     $sRes = '';
     $dbMock = $this->getDbObjectMock();
     $dbMock->expects($this->any())->method('getAll')->will($this->returnCallback(function ($s) {
         throw new Exception($s);
     }));
     oxDb::setDbObject($dbMock);
     try {
         $oTest->UNITgetFilterSql($sCatId, array("8a142c3ee0edb75d4.80743302" => "Zeiger", "8a142c3e9cd961518.80299776" => "originell"));
     } catch (Exception $e) {
         $sRes = $e->getMessage();
     }
     $this->setLanguage(0);
     modDB::getInstance()->cleanup();
     $sO2CView = getViewName('oxobject2category');
     $sO2AView = getViewName('oxobject2attribute');
     $sExpt = "select oc.oxobjectid as oxobjectid, count(*)as cnt from\n            (SELECT * FROM {$sO2CView} WHERE {$sO2CView}.oxcatnid='{$sCatId}' GROUP BY {$sO2CView}.oxobjectid, {$sO2CView}.oxcatnid) as oc\n            INNER JOIN {$sO2AView} as oa ON(oa.oxobjectid=oc.oxobjectid)\n            WHERE (oa.oxattrid='8a142c3ee0edb75d4.80743302' and oa.oxvalue='Zeiger')\n                or (oa.oxattrid='8a142c3e9cd961518.80299776'andoa.oxvalue='originell')\n            GROUPBY oa.oxobjectid\n            HAVING cnt=2";
     $sExpt = str_replace(array("\n", "\r", " ", "\t"), "", $sExpt);
     $sRes = str_replace(array("\n", "\r", " ", "\t"), "", $sRes);
     $this->assertEquals($sExpt, $sRes);
 }
 /**
  * Executed after test is down
  *
  */
 protected function tearDown()
 {
     //TS2012-06-06
     //deprecated method call
     //overrideGetShopBasePath(null);
     oxTestsStaticCleaner::clean('oxSeoEncoder', '_instance');
     oxTestsStaticCleaner::clean('oxSeoEncoderArticle', '_instance');
     oxTestsStaticCleaner::clean('oxSeoEncoderCategory', '_instance');
     oxTestsStaticCleaner::clean('oxVatSelector', '_instance');
     oxTestsStaticCleaner::clean('oxDiscountList', '_instance');
     oxTestsStaticCleaner::clean('oxUtilsObject', '_aInstanceCache');
     oxTestsStaticCleaner::clean('oxArticle', '_aLoadedParents');
     modInstances::cleanup();
     oxTestModules::cleanUp();
     modOxid::globalCleanup();
     modDB::getInstance()->cleanup();
     $this->getSession()->cleanup();
     $this->getConfig()->cleanup();
     $_SERVER = $this->_aBackup['_SERVER'];
     $_POST = $this->_aBackup['_POST'];
     $_GET = $this->_aBackup['_GET'];
     $_SESSION = $this->_aBackup['_SESSION'];
     $_COOKIE = $this->_aBackup['_COOKIE'];
     $this->_resetRegistry();
     oxUtilsObject::resetClassInstances();
     oxUtilsObject::resetModuleVars();
     parent::tearDown();
 }
 public function cleanup()
 {
     modConfig::getInstance()->remClassFunction('getDB');
     self::$unitMOD = null;
     parent::cleanup();
 }
 /**
  * Tear down the fixture.
  *
  * @return null
  */
 protected function tearDown()
 {
     modDB::getInstance()->cleanup();
     // deleting seo entries
     oxDb::getDb()->execute('delete from oxseo where oxtype != "static"');
     oxDb::getDb()->execute('delete from oxobject2seodata');
     oxDb::getDb()->execute('delete from oxseohistory');
     $this->cleanUpTable('oxcategories');
     $this->cleanUpTable('oxarticles');
     $this->cleanUpTable('oxrecommlists');
     oxDb::getDb()->execute('delete from oxarticles where oxid = "testart"');
     oxDb::getDb()->execute('delete from oxobject2category where oxobjectid = "testart"');
     //$this->getConfig()->setActiveView( null );
     parent::tearDown();
 }
 /**
  * Executed after test is down
  *
  */
 protected function tearDown()
 {
     $this->cleanUpDatabase();
     modDb::getInstance()->modAttach(modDb::getInstance()->getRealInstance());
     oxTestsStaticCleaner::clean('oxUtilsObject', '_aInstanceCache');
     oxTestsStaticCleaner::clean('oxArticle', '_aLoadedParents');
     modInstances::cleanup();
     oxTestModules::cleanUp();
     modOxid::globalCleanup();
     modDB::getInstance()->cleanup();
     $this->getSession()->cleanup();
     $this->getConfig()->cleanup();
     $_SERVER = $this->_aBackup['_SERVER'];
     $_POST = $this->_aBackup['_POST'];
     $_GET = $this->_aBackup['_GET'];
     $_SESSION = $this->_aBackup['_SESSION'];
     $_COOKIE = $this->_aBackup['_COOKIE'];
     $this->_resetRegistry();
     oxUtilsObject::resetClassInstances();
     oxUtilsObject::resetModuleVars();
     parent::tearDown();
 }
Beispiel #11
0
 public function testCheckAccessRights()
 {
     $mySession = oxRegistry::getSession();
     $backUpAuth = $mySession->getVariable("auth");
     $mySession->setVariable("auth", "oxdefaultadmin");
     $this->assertEquals(true, oxRegistry::getUtils()->checkAccessRights());
     //  self::$test_sql_used = null;
     modDB::getInstance()->addClassFunction('getOne', create_function('$sql', 'return 1;'));
     $mySession->setVariable("auth", "oxdefaultadmin");
     $this->assertEquals(true, oxRegistry::getUtils()->checkAccessRights());
     $mySession->setVariable("auth", "blafooUser");
     //self::$test_sql_used = null;
     modDB::getInstance()->addClassFunction('getOne', create_function('$sql', 'return 0;'));
     $this->assertEquals(false, oxRegistry::getUtils()->checkAccessRights());
     $mySession->setVariable("auth", $backUpAuth);
     modDB::getInstance()->cleanup();
 }
 protected function tearDown()
 {
     parent::tearDown();
     modDB::getInstance()->cleanup();
 }