/** * Test case for oxMaintenance::execute() * * @return null */ public function testExecute() { $oList = $this->getMock('oxArticleList', array('updateUpcomingPrices')); $oList->expects($this->once())->method('updateUpcomingPrices')->with($this->equalTo(true)); oxTestModules::addModuleObject('oxarticlelist', $oList); $oMaintenance = oxNew("oxMaintenance"); $oMaintenance->execute(); }
/** * sysreq::Render() test case * * @return null */ public function testRender() { oxTestModules::addFunction('oxUtils', 'showMessageAndExit', '{ return "Access denied !"; }'); oxTestModules::addFunction('oxuser', 'loadAdminUser', '{ $this->oxuser__oxrights = new oxField( "justadmin" ); }'); // testing.. $oView = oxNew('systeminfo'); $this->assertEquals("Access denied !", $oView->render()); }
/** * Initialize the fixture. * * @return null */ protected function setUp() { parent::setUp(); $this->getConfig(); $this->getSession(); oxTestModules::addFunction('oxutils', 'setseoact', '{oxRegistry::getUtils()->_blSeoIsActive = $aA[0];}'); oxNew('oxutils')->setseoact(false); }
/** * @covers Helper_Modules::_getModulesAnalize */ public function testGetModulesAnalizeTwo() { modConfig::setParameter("start", true); oxTestModules::addFunction('moduleManager', 'getModuleContentClass', '{ return true; }'); oxTestModules::addFunction('moduleManagerAnalize', 'setAnalize', '{ return true; }'); $oTestObj = $this->getProxyClass('Helper_Modules'); $this->assertNull($oTestObj->UNITgetModulesAnalize()); }
/** * Testing Wrapping::getCardList() * * @return null */ public function testGetCardList() { oxTestModules::addFunction('oxwrapping', 'getWrappingList', '{ return "getCardList"; }'); $oViewConfig = $this->getMock("oxViewConfig", array("getShowGiftWrapping")); $oViewConfig->expects($this->once())->method('getShowGiftWrapping')->will($this->returnValue(true)); $oView = $this->getMock("Wrapping", array("getViewConfig"), array(), '', false); $oView->expects($this->once())->method('getViewConfig')->will($this->returnValue($oViewConfig)); $this->assertEquals("getCardList", $oView->getCardList()); }
/** * Article_Userdef::Render() test case * * @return null */ public function testRender() { $this->setRequestParameter("oxid", "testId"); oxTestModules::addFunction('oxarticle', 'isDerived', '{ return true; }'); // testing.. $oView = oxNew('Article_Userdef'); $this->assertEquals('article_userdef.tpl', $oView->render()); $this->assertTrue($oView->getViewDataElement('readonly')); }
/** * oxScLoginRegister::confirmRegistration() test case * * @return null */ public function testConfirmRegistration() { oxTestModules::addFunction("oxuser", "loadUserByUpdateId", "{return true;}"); oxTestModules::addFunction("oxuser", "setUpdateKey", "{return true;}"); oxTestModules::addFunction("oxuser", "save", "{return true;}"); $oView = $this->getMock("register", array("getUpdateId")); $oView->expects($this->once())->method('getUpdateId')->will($this->returnValue("testUpdateId")); $this->assertEquals('register?confirmstate=1', $oView->confirmRegistration()); }
/** * Testing oxwServiceMenu::getCompareItems() * * @return null */ public function testGetCompareItemsInJson() { $aItems = array("testId1" => "testVal1", "testId2" => "testVal2", "testId3" => "testVal3"); $aResult = '{"testId1":"testVal1","testId2":"testVal2","testId3":"testVal3"}'; $oCompare = $this->getMock("compare", array("getCompareItems")); $oCompare->expects($this->once())->method("getCompareItems")->will($this->returnValue($aItems)); oxTestModules::addModuleObject('compare', $oCompare); $oServiceMenu = oxNew('oxwServiceMenu'); $this->assertEquals($aResult, $oServiceMenu->getCompareItems(true)); }
/** * Testing oxwRecomm::getSimilarRecommLists() * * @return null */ public function testGetSimilarRecommLists() { $oRecommList = $this->getMock("oxrecommlist", array("getRecommListsByIds")); $oRecommList->expects($this->once())->method("getRecommListsByIds")->with($this->equalTo(array("articleId")))->will($this->returnValue("oxRecommListMock")); oxTestModules::addModuleObject('oxrecommlist', $oRecommList); $aParams["aArticleIds"] = array("articleId"); $oRecomm = oxNew('oxwRecommendation'); $oRecomm->setViewParameters($aParams); $this->assertEquals("oxRecommListMock", $oRecomm->getSimilarRecommLists(), "Should try to create RecommList object."); }
/** * User_Address::DelAddress() test case * * @return null */ public function testDelAddress() { oxTestModules::addFunction('oxaddress', 'delete', '{ return true; }'); $this->setRequestParameter("oxid", "testId"); $this->setRequestParameter("editval", array("oxaddress__oxid" => "testOxId")); // testing.. $oView = $this->getMock("User_Address", array("_allowAdminEdit")); $oView->expects($this->at(0))->method('_allowAdminEdit')->with($this->equalTo("testId"))->will($this->returnValue(true)); $oView->delAddress(); }
/** * Lets run the render method. */ public function testRender() { oxTestModules::addFunction('oxUtils', 'redirect', '{throw new Exception("REDIRECT");}'); $oView = new bz_barzahlen_thankyou(); try { $oView->render(); } catch (Exception $e) { $this->assertEquals("REDIRECT", $e->getMessage()); } }
/** * Manufacturer_Seo::Save() test case * * @return null */ public function testSave() { oxTestModules::addFunction('oxbase', 'load', '{ return true; }'); oxTestModules::addFunction('oxbase', 'save', '{ return true; }'); $this->setRequestParameter("oxid", "testId"); // testing.. $oView = $this->getMock("Manufacturer_Seo", array("getEditObjectId")); $oView->expects($this->atLeastOnce())->method('getEditObjectId')->will($this->returnValue(123)); $this->assertNull($oView->save()); }
public function testGetContentLoadByIdentLangChange() { $sShopId = $this->getTestConfig()->getShopEdition() == 'EE' ? '1' : 'oxbaseshop'; $aParams['ident'] = 'oxsecurityinfo'; $oSmarty = $this->getMock("smarty", array("fetch")); $oSmarty->expects($this->once())->method('fetch')->with($this->equalTo('ox:oxsecurityinfooxcontent1' . $sShopId))->will($this->returnValue('testvalue')); $message = "Content not found! check ident(" . $aParams['ident'] . ") !"; oxTestModules::addFunction('oxLang', 'getBaseLanguage', '{return 1;}'); $this->assertEquals('testvalue', smarty_function_oxcontent($aParams, $oSmarty), $message); }
/** * Tools::Render() test case * * @return null */ public function testRenderDemoshop() { oxTestModules::addFunction('oxUtils', 'showMessageAndExit', '{ return "Access denied !"; }'); $oConfig = $this->getMock("oxConfig", array("isDemoShop")); $oConfig->expects($this->once())->method('isDemoShop')->will($this->returnValue(true)); // testing.. $oView = $this->getMock("Tools", array("getConfig"), array(), '', false); $oView->expects($this->once())->method('getConfig')->will($this->returnValue($oConfig)); $this->assertEquals("Access denied !", $oView->render()); }
/** * DeliverySet_Users::Render() test case * * @return null */ public function testRender() { oxTestModules::addFunction("oxdeliveryset", "isDerived", "{return true;}"); $this->setRequestParameter("oxid", "testId"); // testing.. $oView = oxNew('DeliverySet_Users'); $this->assertEquals('deliveryset_users.tpl', $oView->render()); $aViewData = $oView->getViewData(); $this->assertTrue(isset($aViewData['readonly'])); }
/** * Attribute_List::Init() test case * * @return null */ public function testInit() { oxTestModules::addFunction("oxUtilsServer", "getOxCookie", "{return array(1);}"); oxTestModules::addFunction("oxUtils", "checkAccessRights", "{return true;}"); $oSess = $this->getMock('oxsession', array('checkSessionChallenge')); $oSess->expects($this->any())->method('checkSessionChallenge')->will($this->returnValue(true)); $oView = $this->getMock($this->getProxyClassName('Attribute_List'), array('getSession')); $oView->expects($this->any())->method('getSession')->will($this->returnValue($oSess)); $oView->init(); $this->assertEquals("oxattribute", $oView->getNonPublicVar("_sListClass")); }
public function testPageClose() { $oSession = $this->getMock('oxSession', array('freeze')); $oSession->expects($this->once())->method('freeze')->will($this->returnValue(null)); $oStart = $this->getMock('oxStart', array('getSession')); $oStart->expects($this->once())->method('getSession')->will($this->returnValue($oSession)); $oUtils = $this->getMock('oxUtils', array('commitFileCache')); $oUtils->expects($this->once())->method('commitFileCache')->will($this->returnValue(null)); oxTestModules::addModuleObject('oxUtils', $oUtils); $this->assertEquals(null, $oStart->pageClose()); }
/** * Category_List::Init() test case * * @return null */ public function testInit() { oxTestModules::addFunction("oxUtilsServer", "getOxCookie", "{return array(1);}"); oxTestModules::addFunction("oxUtils", "checkAccessRights", "{return true;}"); $oSess = $this->getMock('oxsession', array('checkSessionChallenge')); $oSess->expects($this->any())->method('checkSessionChallenge')->will($this->returnValue(true)); $oView = $this->getMock($this->getProxyClassName('Category_List'), array('getSession')); $oView->expects($this->any())->method('getSession')->will($this->returnValue($oSess)); $oView->init(); $this->assertEquals(array("oxcategories" => array("oxrootid" => "desc", "oxleft" => "asc")), $oView->getListSorting()); }
/** * VoucherSerie_Groups::Render() test case * * @return null */ public function testRender() { $this->setRequestParameter("oxid", "testId"); oxTestModules::addFunction('oxvoucherserie', 'isDerived', '{ return true; }'); // testing.. $oView = oxNew('VoucherSerie_Groups'); $this->assertEquals('voucherserie_groups.tpl', $oView->render()); $aViewData = $oView->getViewData(); $this->assertTrue(isset($aViewData['edit'])); $this->assertTrue($aViewData['edit'] instanceof oxvoucherserie); }
/** * News_Main::Render() test case * * @return null */ public function testRender() { oxTestModules::addFunction('oxnewsletter', 'prepare', '{}'); $this->setRequestParameter("oxid", "testId"); // testing.. $oView = oxNew('Newsletter_Preview'); $this->assertEquals('newsletter_preview.tpl', $oView->render()); $aViewData = $oView->getViewData(); $this->assertTrue(isset($aViewData['edit'])); $this->assertTrue($aViewData['edit'] instanceof oxnewsletter); }
public function testGetTagPageUrl() { oxTestModules::addFunction("oxutilsserver", "getServerVar", "{ \$aArgs = func_get_args(); if ( \$aArgs[0] === 'HTTP_HOST' ) { return '" . $this->getConfig()->getShopUrl() . "'; } elseif ( \$aArgs[0] === 'SCRIPT_NAME' ) { return ''; } else { return \$_SERVER[\$aArgs[0]]; } }"); $sUrl = $this->getConfig()->getShopUrl(oxRegistry::getLang()->getBaseLanguage()); $sTag = $this->getTestConfig()->getShopEdition() == 'EE' ? 'hingucker' : 'erste'; $sAltTag = $this->getTestConfig()->getShopEdition() == 'EE' ? 'grilltonne' : 'authentisches'; $oSeoEncoderTag = oxNew('oxSeoEncoderTag'); $this->assertEquals($sUrl . "tag/{$sTag}/16/", $oSeoEncoderTag->getTagPageUrl($sTag, 15)); $this->assertEquals($sUrl . "tag/{$sTag}/16/", $oSeoEncoderTag->getTagPageUrl($sTag, 15)); $this->assertEquals($sUrl . "tag/{$sAltTag}/14/", $oSeoEncoderTag->getTagPageUrl($sAltTag, 13)); }
public function testIncludeWidget() { $oReverseProxyBackend = $this->getMock("oxReverseProxyBackend", array("isActive"), array(), '', false); $oReverseProxyBackend->expects($this->any())->method("isActive")->will($this->returnValue(false)); oxRegistry::set("oxReverseProxyBackend", $oReverseProxyBackend); $oShopControl = $this->getMock("oxWidgetControl", array("start"), array(), '', false); $oShopControl->expects($this->any())->method("start")->will($this->returnValue('html')); oxTestModules::addModuleObject('oxWidgetControl', $oShopControl); $oSmarty = new Smarty(); $result = smarty_function_oxid_include_widget(array('cl' => 'oxwTagCloud', 'blShowTags' => 1), $oSmarty); $this->assertEquals('html', $result); }
public function testGetModulesList() { // Config mock $oConfig = $this->getMock('oxConfig', array('getModulesDir')); $oConfig->expects($this->once())->method('getModulesDir')->will($this->returnValue('/shop/modules/')); oxRegistry::set('oxConfig', $oConfig); // Modules list mock $oModuleList = $this->getMock('oxModuleList', array('__call', 'getModulesFromDir')); $oModuleList->expects($this->once())->method('getModulesFromDir')->with('/shop/modules/')->will($this->returnValue(array('my_module' => (object) array('version' => '1.0.0'), 'oxpsmodulesconfig' => (object) array('version' => '0.1.0'), 'good_extension' => (object) array('version' => '0.2.5')))); oxTestModules::addModuleObject('oxModuleList', $oModuleList); $this->assertEquals(array('my_module' => (object) array('version' => '1.0.0'), 'good_extension' => (object) array('version' => '0.2.5')), $this->SUT->getModulesList()); }
public function testGetBasket() { oxTestModules::addFunction('oxUtilsServer', 'getServerVar', '{ if ( $aA[0] == "HTTP_HOST") { return "shop.com/"; } else { return "test.php";} }'); /** @var oxSession $mySession */ $mySession = oxRegistry::getSession(); $oBasket = oxNew('oxBasket'); //$this->getSession()->setVariable( 'basket', $oBasket ); $mySession->setBasket($oBasket); $oThankyou = $this->getProxyClass('thankyou'); $oThankyou->init(); $this->assertEquals($oBasket, $oThankyou->getBasket()); }
/** * VoucherSerie_List::DeleteEntry() test case * * @return null */ public function testDeleteEntry() { oxTestModules::addFunction("oxUtilsServer", "getOxCookie", "{return array(1);}"); oxTestModules::addFunction("oxUtils", "checkAccessRights", "{return true;}"); oxTestModules::addFunction('oxvoucherserie', 'load', '{ return true; }'); oxTestModules::addFunction('oxvoucherserie', 'deleteVoucherList', '{ return true; }'); $oSess = $this->getMock('oxsession', array('checkSessionChallenge')); $oSess->expects($this->any())->method('checkSessionChallenge')->will($this->returnValue(true)); $oView = $this->getMock($this->getProxyClassName('VoucherSerie_List'), array('getSession')); $oView->expects($this->any())->method('getSession')->will($this->returnValue($oSess)); $oView->deleteEntry(); }
/** * Discount_Articles::Render() test case * * @return null */ public function testRender() { oxTestModules::addFunction("oxdiscount", "isDerived", "{return true;}"); $this->setRequestParameter("oxid", "testId"); // testing.. $oView = oxNew('Discount_Articles'); $this->assertEquals('discount_articles.tpl', $oView->render()); $aViewData = $oView->getViewData(); $this->assertTrue(isset($aViewData['edit'])); $this->assertTrue(isset($aViewData['readonly'])); $this->assertTrue($aViewData['edit'] instanceof oxdiscount); }
/** * user_remark::testDelete() test case * * @return null */ public function testDelete() { oxTestModules::addFunction('oxremark', 'delete', '{ throw new Exception( "delete" ); }'); try { $oView = oxNew('user_remark'); $oView->delete(); } catch (Exception $oExcp) { $this->assertEquals("delete", $oExcp->getMessage(), "Error in user_remark::delete()"); return; } $this->fail("Error in user_remark::delete()"); }
/** * Category_Order::Render() test case * * @return null */ public function testRender() { oxTestModules::addFunction("oxcategory", "isDerived", "{return true;}"); $this->setRequestParameter("oxid", "testId"); // testing.. $oView = oxNew('Category_Order'); $sTplName = $oView->render(); // testing view data $aViewData = $oView->getViewData(); $this->assertTrue($aViewData["edit"] instanceof oxCategory); $this->assertEquals('category_order.tpl', $sTplName); }
/** * Article_Crossselling::Render() test case * * @return null */ public function testRender() { oxTestModules::addFunction('oxarticle', 'isDerived', '{ return true; }'); $this->setRequestParameter("oxid", "1126"); // testing.. $oView = oxNew('Article_Crossselling'); $sTplName = $oView->render(); // testing view data $aViewData = $oView->getViewData(); $this->assertTrue($aViewData["edit"] instanceof oxArticle); $this->assertTrue($aViewData["readonly"]); $this->assertEquals('article_crossselling.tpl', $sTplName); }
/** * VoucherSerie_Main::Save() test case * * @return null */ public function testSave() { oxTestModules::addFunction('oxvoucherserie', 'save', '{ throw new Exception( "save" ); }'); // testing.. try { $oView = oxNew('VoucherSerie_Main'); $oView->save(); } catch (Exception $oExcp) { $this->assertEquals("save", $oExcp->getMessage(), "error in Wrapping_Main::save()"); return; } $this->fail("error in VoucherSerie_Main::save()"); }