/** * 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(); }
/** * 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."); }
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()); }
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 testDisableModule() { $sModuleId = 'testId'; $oModule = oxNew('oxModule'); $oModule->load($sModuleId); /** @var oxModuleVariablesLocator|MockObject $oUtilsObject */ $moduleVariablesLocator = $this->getMock('oxModuleVariablesLocator', array(), array(), '', false); $moduleChainsGenerator = oxNew('oxModuleChainsGenerator', $moduleVariablesLocator); $oModuleInstaller = $this->getMock('oxModuleInstaller', array('deactivate')); $oModuleInstaller->expects($this->once())->method('deactivate')->with($oModule); oxTestModules::addModuleObject('oxModuleInstaller', $oModuleInstaller); $moduleChainsGenerator->disableModule($sModuleId); }
/** * PriceAlarm_Send::SendeMail() test case * * @return null */ public function testSendeMail() { $oAlarm = $this->getMock('oxpricealarm', array('save', 'load')); $oAlarm->expects($this->once())->method('load')->with($this->equalTo("paid"))->will($this->returnValue(true)); $oAlarm->expects($this->once())->method('save')->will($this->returnValue(true)); oxTestModules::addModuleObject('oxpricealarm', $oAlarm); $oEmail = $this->getMock('oxemail', array('sendPricealarmToCustomer')); $oEmail->expects($this->once())->method('sendPricealarmToCustomer')->with($this->equalTo("*****@*****.**"), $this->isInstanceOf('oxpricealarm'))->will($this->returnValue(true)); oxTestModules::addModuleObject('oxemail', $oEmail); // testing.. $oView = oxNew('PriceAlarm_Send'); $oView->sendeMail("*****@*****.**", "", "paid", ""); }
/** * Test for oxFiles::StartDownload() */ public function testDownload() { $sFilePath = $this->createFile('out/downloads/test.jpg', 'test jpg file'); /** @var oxFile|PHPUnit_Framework_MockObject_MockObject $oFile */ $oFile = $this->getMock('oxFile', array('getStoreLocation', 'isUnderDownloadFolder')); $oFile->expects($this->any())->method('getStoreLocation')->will($this->returnValue($sFilePath)); $oFile->expects($this->any())->method('isUnderDownloadFolder')->will($this->returnValue(true)); /** @var oxUtils|PHPUnit_Framework_MockObject_MockObject $oUtils */ $oUtils = $this->getMock('oxUtils', array('setHeader', 'showMessageAndExit')); $oUtils->expects($this->any())->method('setHeader'); $oUtils->expects($this->once())->method('showMessageAndExit'); oxTestModules::addModuleObject('oxUtils', $oUtils); ob_start(); $oFile->download(); $content = ob_get_contents(); ob_end_clean(); $this->assertEquals('test jpg file', $content); }
/** * Set SUT state before test. * Create test folder for modules generation. */ public function setUp() { parent::setUp(); $this->SUT = $this->getMock('Admin_oxpsModuleGenerator', array('_Admin_oxpsModuleGenerator_init_parent', '_Admin_oxpsModuleGenerator_render_parent')); // Mock config for module settings $oConfig = oxRegistry::getConfig(); $oConfig->setConfigParam('oxpsModuleGeneratorVendorPrefix', 'test'); $oConfig->setConfigParam('oxpsModuleGeneratorModuleAuthor', 'TEST'); $oConfig->setConfigParam('oxpsModuleGeneratorAuthorLink', 'www.example.com'); $oConfig->setConfigParam('oxpsModuleGeneratorAuthorMail', '*****@*****.**'); $oConfig->setConfigParam('oxpsModuleGeneratorCopyright', 'TEST '); $oConfig->setConfigParam('oxpsModuleGeneratorComment', '* This is automatically generated test output.'); oxRegistry::set('oxConfig', $oConfig); // Module instance mock for generation path only $oModule = $this->getMock('oxpsModuleGeneratorOxModule', array('getVendorPath')); $oModule->expects($this->any())->method('getVendorPath')->will($this->returnValue($this->_getTestPath('modules/test/'))); oxTestModules::addModuleObject('oxpsModuleGeneratorOxModule', $oModule); @mkdir($this->_getTestPath()); @mkdir($this->_getTestPath('modules')); }
/** * Test get article list. * * @return null */ public function testGetArticleList() { $oUser = $this->getMock('oxUser', array('getId')); $oUser->expects($this->any())->method('getId')->will($this->returnValue("userId")); $oFileOrder = oxNew("oxorderfile"); $oFileOrder->oxorderfiles__oxorderarticleid = new oxField("testArtNr"); $oFileOrder->oxorderfiles__oxordernr = new oxField("testOrder"); $oFileOrder->oxorderfiles__oxorderdate = new oxField("2011-11-11 11:11:11"); $oFileOrder->oxorderfiles__oxarticletitle = new oxField("testArtTitle"); $oOrderFileList = $this->getMock('oxOrderFileList', array('loadUserFiles')); $oOrderFileList->expects($this->any())->method('loadUserFiles')->will($this->returnValue("orderfilelist")); $oOrderFileList[] = $oFileOrder; oxTestModules::addModuleObject('oxOrderFileList', $oOrderFileList); $oAccDownloads = $this->getMock('Account_Downloads', array('getUser')); $oAccDownloads->expects($this->any())->method('getUser')->will($this->returnValue($oUser)); $aOrderFilesList = $oAccDownloads->getOrderFilesList(); $this->assertEquals("testOrder", $aOrderFilesList["testArtNr"]["oxordernr"]); $this->assertEquals("2011-11-11 11:11", $aOrderFilesList["testArtNr"]["oxorderdate"]); $this->assertEquals("testArtTitle", $aOrderFilesList["testArtNr"]["oxarticletitle"]); $this->assertTrue($aOrderFilesList["testArtNr"]["oxorderfiles"][0] instanceof oxorderfile); }
/** * Article_stock::addprice test case when updating existing stock prices in subshop * * @return null */ public function testAddPriceShopMall() { //set default params for first save $this->setRequestParameter("editval", array("oxprice2article__oxamountto" => 123, "pricetype" => "oxaddabs", "price" => 9)); //set oxid $sOXID = "_testId"; //expected shop id $sShopId = $this->getTestConfig()->getShopEdition() == 'EE' ? '2' : 'oxbaseshop'; $oConfig = $this->getMock("oxConfig", array("getShopId")); $oConfig->expects($this->any())->method('getShopId')->will($this->returnValue($sShopId)); $oBase = $this->getMock('oxbase', array('isDerived')); $oBase->expects($this->any())->method('isDerived')->will($this->returnValue(false)); oxTestModules::addModuleObject('oxbase', $oBase); $oView = $this->getMock("Article_Stock", array('getConfig', 'resetContentCache', 'getEditObjectId', 'oxNew'), array(), '', false); $oView->expects($this->atLeastOnce())->method('getConfig')->will($this->returnValue($oConfig)); $oView->expects($this->atLeastOnce())->method('resetContentCache'); $oView->expects($this->atLeastOnce())->method('getEditObjectId')->will($this->returnValue('_testArtId')); //init db $oDb = oxDb::getDb(); //first add new stock price $oView->addprice($sOXID); $this->assertEquals("123", $oDb->getOne("select oxamountto from oxprice2article where oxid='_testId'")); //pass update params $aParams = array("oxprice2article__oxamountto" => 777, "pricetype" => "oxaddabs", "price" => 20); $oView->addprice($sOXID, $aParams); $this->assertEquals("777", $oDb->getOne("select oxamountto from oxprice2article where oxid='_testId'")); $this->assertEquals($sShopId, $oDb->getOne("select oxshopid from oxprice2article where oxid='_testId'")); //update only amount to $aParams = array("oxprice2article__oxamountto" => 10101); $oView->addprice($sOXID, $aParams); $this->assertEquals("10101", $oDb->getOne("select oxamountto from oxprice2article where oxid='_testId'")); $this->assertEquals($sShopId, $oDb->getOne("select oxshopid from oxprice2article where oxid='_testId'")); }
/** * test */ public function testGetBannerArticle_Existing() { $dbMock = $this->getBannerArticleMockWithSpecificReturn('2000'); oxDb::setDbObject($dbMock); $oArticle = $this->getMock('stdclass', array('load')); $oArticle->expects($this->once())->method('load')->with($this->equalTo('2000'))->will($this->returnValue(true)); oxTestModules::addModuleObject('oxarticle', $oArticle); $oPromo = oxNew('oxActions'); $oPromo->setId('promoid'); $oArt = $oPromo->getBannerArticle(); $this->assertNotNull($oArt); $this->assertSame($oArticle, $oArt); }
/** * Testing method render() * * @return null */ public function testRender_invitationNotActive() { $oConfig = $this->getConfig(); $oConfig->setConfigParam("blInvitationsEnabled", false); $oUtils = $this->getMock('oxUtils', array('redirect')); $oUtils->expects($this->once())->method('redirect')->with($this->equalTo($oConfig->getShopHomeURL())); oxTestModules::addModuleObject('oxUtils', $oUtils); $oView = $this->getProxyClass("invite"); $this->assertEquals(null, $oView->render()); }
/** * Test case for oePayPalOxUser::initializeUserForCallBackPayPalUser() * Creating user * * @return null */ public function testInitializeUserForCallBackPayPalUser() { oxTestModules::addModuleObject('oxAddress', new oePayPalOxAddress()); $aPayPalData["SHIPTOSTREET"] = "testStreetName str. 12a"; $aPayPalData["SHIPTOCITY"] = "testCity"; $aPayPalData["SHIPTOSTATE"] = "SS"; $aPayPalData["SHIPTOCOUNTRY"] = "US"; $aPayPalData["SHIPTOZIP"] = "testZip"; $oPayPalUser = new oePayPalOxUser(); $oPayPalUser->initializeUserForCallBackPayPalUser($aPayPalData); $this->assertTrue(is_string($oPayPalUser->getId())); $this->assertEquals('testStreetName str.', $oPayPalUser->oxuser__oxstreet->value); $this->assertEquals('12a', $oPayPalUser->oxuser__oxstreetnr->value); $this->assertEquals('testCity', $oPayPalUser->oxuser__oxcity->value); $this->assertEquals('testZip', $oPayPalUser->oxuser__oxzip->value); $this->assertEquals('8f241f11096877ac0.98748826', $oPayPalUser->oxuser__oxcountryid->value); $this->assertEquals('333', $oPayPalUser->oxuser__oxstateid->value); }
/** * Test User_Main::Save() - try to set new password with spec. chars. * #0003680 * * @return null */ public function testSave_passwordSpecChars() { $this->setAdminMode(true); $sPass = '******'; $this->setRequestParameter('newPassword', $sPass); $oUser = $this->getMock('oxuser', array('setPassword', 'checkIfEmailExists', 'load')); $oUser->expects($this->once())->method('setPassword')->with($this->equalTo($sPass)); $oUser->expects($this->once())->method('checkIfEmailExists')->will($this->returnValue(true)); oxTestModules::addModuleObject('oxuser', $oUser); /** @var User_Main|PHPUnit_Framework_MockObject_MockObject $oView */ $oView = $this->getMock('User_Main', array('getEditObjectId', '_allowAdminEdit')); $oView->expects($this->once())->method('_allowAdminEdit')->will($this->returnValue(true)); $oView->save(); }
/** * Test oxcmp_user::login() - try to login with password with spec chars. * #0003680 * * @return null */ public function testLogin_setPasswordWithSpecChars() { $this->setExpectedException('oxException', 'Login user test'); $sPass = '******'; $this->setRequestParameter('lgn_usr', 'test_username'); $this->setRequestParameter('lgn_pwd', $sPass); $this->setRequestParameter('lgn_cook', null); $oUser = $this->getMock('oxUser', array('login')); $oUser->expects($this->once())->method('login')->with($this->equalTo('test_username'), $this->equalTo($sPass), $this->equalTo(null))->will($this->throwException(new oxException('Login user test'))); oxTestModules::addModuleObject('oxuser', $oUser); $oView = $this->getMock('oxcmp_user', array('setLoginStatus')); $oView->login(); }
/** * Testing method send() * * @return null */ public function testSendEmailNotSend() { /** @var oxUtilsView|PHPUnit_Framework_MockObject_MockObject $oUtils */ $oUtils = $this->getMock('oxUtilsView', array('addErrorToDisplay')); $oUtils->expects($this->once())->method('addErrorToDisplay')->with($this->equalTo("ERROR_MESSAGE_CHECK_EMAIL")); oxTestModules::addModuleObject('oxUtilsView', $oUtils); $aParams = array("oxuser__oxusername" => "*****@*****.**", "oxuser__oxfname" => "admin", "oxuser__oxlname" => "admin", "oxuser__oxsal" => "MR"); $this->setRequestParameter("editval", $aParams); $this->setRequestParameter("c_message", "message"); $this->setRequestParameter("c_subject", "subject"); /** @var oxEmail|PHPUnit_Framework_MockObject_MockObject $oEmail */ $oEmail = $this->getMock("oxemail", array("sendContactMail")); $oEmail->expects($this->once())->method('sendContactMail')->will($this->returnValue(false)); oxTestModules::addModuleObject('oxemail', $oEmail); /** @var Contact|PHPUnit_Framework_MockObject_MockObject $oContact */ $oContact = oxNew('Contact'); $oContact->send(); }
public function testGetLanguageSetTables() { $oObj = oxNew('oxi18n'); $oObj->init('oxstates'); $this->assertEquals(array(), $oObj->UNITgetLanguageSetTables()); $oLang = $this->getMock('oxLang', array('getLanguageIds')); $oLang->expects($this->any())->method('getLanguageIds')->will($this->returnValue(array(0 => 'de', 1 => 'en', 90 => 'lt'))); oxTestModules::addModuleObject('oxLang', $oLang); $this->assertEquals(array('oxstates_set11'), $oObj->UNITgetLanguageSetTables()); }
public function testRecommListsEnabledNoList() { $oCfg = $this->getMock('oxConfig', array('getConfigParam')); $oCfg->expects($this->once())->method('getConfigParam')->with($this->equalTo('bl_rssRecommLists'))->will($this->returnValue(true)); $oObj = $this->getMock('oxarticle', array('load')); $oObj->expects($this->once())->method('load')->with($this->equalTo('x&objid'))->will($this->returnValue(false)); $oUtils = $this->getMock('oxutils', array('handlePageNotFoundError')); $oUtils->expects($this->once())->method('handlePageNotFoundError'); oxTestModules::addModuleObject('oxutils', $oUtils); $oRss = $this->getMock('Rss', array('getConfig', '_getRssFeed')); $oRss->expects($this->once())->method('getConfig')->will($this->returnValue($oCfg)); $oRss->expects($this->never())->method('_getRssFeed'); $this->setRequestParameter('anid', 'x&objid'); oxTestModules::addModuleObject('oxarticle', $oObj); $oRss->recommlists(); }
public function testGetPictureUrlForAltImageDirA() { $sDir = 'http://www.example.com/test.gif'; $oPH = $this->getMock('oxPictureHandler', array('getAltImageUrl')); $oPH->expects($this->once())->method('getAltImageUrl')->will($this->returnValue($sDir)); oxTestModules::addModuleObject('oxPictureHandler', $oPH); $oConfig = oxNew('oxConfig'); $oConfig->init(); $this->assertEquals($sDir, $oConfig->getPictureUrl("/test.gif", false)); }
public function testActionSubmit_importSuccess() { // Config mock $oConfig = $this->getMock('oxConfig', array('getUploadedFile')); $oConfig->expects($this->once())->method('getUploadedFile')->with('oxpsmodulesconfig_file')->will($this->returnValue(array('error' => '', 'type' => 'application/octet-stream', 'tmp_name' => '/path/to/good_file.json'))); oxRegistry::set('oxConfig', $oConfig); modConfig::setRequestParameter('oxpsmodulesconfig_modules', array('my_module')); modConfig::setRequestParameter('oxpsmodulesconfig_settings', array('version' => 1, 'extend' => 1)); modConfig::setRequestParameter('oxpsmodulesconfig_import', 1); // Request validator instance mock $oValidator = $this->getMock('oxpsModulesConfigRequestValidator', array('__call', 'validateRequestData', 'validateImportData', 'addErrors')); $oValidator->expects($this->once())->method('validateRequestData')->with(array('modules' => array('my_module'), 'settings' => array('version', 'extend'), 'action' => 'import'))->will($this->returnValue(true)); $oValidator->expects($this->once())->method('validateImportData')->with(array('error' => '', 'type' => 'application/octet-stream', 'tmp_name' => '/path/to/good_file.json'))->will($this->returnValue(true)); $oValidator->expects($this->never())->method('addErrors'); oxRegistry::set('oxpsModulesConfigRequestValidator', $oValidator); // Configuration data transfer handler mock $oConfigTransfer = $this->getMock('oxpsModulesConfigTransfer', array('__call', 'backupToFile', 'setImportDataFromFile', 'importData', 'getImportErrors')); $oConfigTransfer->expects($this->once())->method('backupToFile')->with(array('modules' => array('my_module', 'good_extension'), 'settings' => array('version', 'extend', 'files'), 'action' => ''), 'full_backup')->will($this->returnValue(true)); $oConfigTransfer->expects($this->once())->method('setImportDataFromFile')->with(array('error' => '', 'type' => 'application/octet-stream', 'tmp_name' => '/path/to/good_file.json')); $oConfigTransfer->expects($this->once())->method('importData')->with(array('modules' => array('my_module'), 'settings' => array('version', 'extend'), 'action' => 'import'))->will($this->returnValue(true)); $oConfigTransfer->expects($this->never())->method('getImportErrors'); oxTestModules::addModuleObject('oxpsModulesConfigTransfer', $oConfigTransfer); // Content model mock $oContent = $this->getMock('oxpsModulesConfigContent', array('__call', 'getModulesList', 'getSettingsList')); $oContent->expects($this->once())->method('getModulesList')->will($this->returnValue(array('my_module' => (object) array('version' => '1.0.0'), 'good_extension' => (object) array('version' => '0.2.5')))); $oContent->expects($this->once())->method('getSettingsList')->will($this->returnValue(array('version' => 'Versions', 'extend' => 'Extended classes', 'files' => 'New classes'))); oxRegistry::set('oxpsModulesConfigContent', $oContent); // Module instance mock $oModule = $this->getMock('oxpsModulesConfigModule', array('__construct', '__call', 'clearTmp')); //$oModule->expects($this->once())->method('clearTmp'); oxTestModules::addModuleObject('oxpsModulesConfigModule', $oModule); $this->SUT->actionSubmit(); $this->assertSame('import', $this->SUT->getAction()); $this->assertSame(array('OXPS_MODULESCONFIG_MSG_BACKUP_SUCCESS', 'OXPS_MODULESCONFIG_MSG_IMPORT_SUCCESS'), $this->SUT->getMessages()); }
/** * Test case for oepaypalexpresscheckoutdispatcher::getExpressCheckoutDetails() */ public function testGetExpressCheckoutDetailsChangedOrderTotal() { $data = array('TOKEN' => 'EC-3KM09768MH0883231', 'BILLINGAGREEMENTACCEPTEDSTATUS' => '0', 'CHECKOUTSTATUS' => 'PaymentActionNotInitiated', 'TIMESTAMP' => '2016-02-15T14:12:43Z', 'CORRELATIONID' => '397ac1846e235', 'ACK' => 'Success', 'VERSION' => '84.0', 'BUILD' => '18308778', 'EMAIL' => '*****@*****.**', 'PAYERID' => 'XXXXXXXXYYYYY', 'PAYERSTATUS' => 'verified', 'FIRSTNAME' => 'Max', 'LASTNAME' => 'Muster', 'COUNTRYCODE' => 'DE', 'SHIPTONAME' => 'Erna Helvetia', 'SHIPTOSTREET' => 'Dorfstrasse 117', 'SHIPTOCITY' => 'Oberbuchsiten', 'SHIPTOZIP' => '4625', 'SHIPTOCOUNTRYCODE' => 'CH', 'SHIPTOCOUNTRYNAME' => 'Switzerland', 'ADDRESSSTATUS' => 'Unconfirmed', 'CURRENCYCODE' => 'EUR', 'AMT' => '29.90', 'ITEMAMT' => '29.90', 'SHIPPINGAMT' => '0.00', 'HANDLINGAMT' => '0.00', 'TAXAMT' => '0.00', 'CUSTOM' => 'Your order at PayPal Testshop in the amount of 29,90 EUR', 'DESC' => 'Your order at PayPal Testshop in the amount of 29,90 EUR', 'INSURANCEAMT' => '0.00', 'SHIPDISCAMT' => '0.00', 'INSURANCEOPTIONOFFERED' => 'false', 'L_NAME0' => 'Kuyichi leather belt JEVER', 'L_NUMBER0' => '3503', 'L_QTY0' => '1', 'L_TAXAMT0' => '0.00', 'L_AMT0' => '29.90', 'L_ITEMWEIGHTVALUE0' => ' 0.00000', 'L_ITEMLENGTHVALUE0' => ' 0.00000', 'L_ITEMWIDTHVALUE0' => ' 0.00000', 'L_ITEMHEIGHTVALUE0' => ' 0.00000', 'SHIPPINGCALCULATIONMODE' => 'FlatRate', 'INSURANCEOPTIONSELECTED' => 'false', 'SHIPPINGOPTIONISDEFAULT' => 'true', 'SHIPPINGOPTIONAMOUNT' => '0.00', 'SHIPPINGOPTIONNAME' => 'Standard', 'PAYMENTREQUEST_0_CURRENCYCODE' => 'EUR', 'PAYMENTREQUEST_0_AMT' => '29.90', 'PAYMENTREQUEST_0_ITEMAMT' => '29.90', 'PAYMENTREQUEST_0_SHIPPINGAMT' => '0.00', 'PAYMENTREQUEST_0_HANDLINGAMT' => '0.00', 'PAYMENTREQUEST_0_TAXAMT' => '0.00', 'PAYMENTREQUEST_0_CUSTOM' => 'Your order at PayPal Testshop in the amount of 29,90 EUR', 'PAYMENTREQUEST_0_DESC' => 'Your order at PayPal Testshop in the amount of 29,90 EUR', 'PAYMENTREQUEST_0_INSURANCEAMT' => '0.00', 'PAYMENTREQUEST_0_SHIPDISCAMT' => '0.00', 'PAYMENTREQUEST_0_INSURANCEOPTIONOFFERED' => 'false', 'PAYMENTREQUEST_0_SHIPTONAME' => 'Erna Helvetia', 'PAYMENTREQUEST_0_SHIPTOSTREET' => 'Dorfstrasse 117', 'PAYMENTREQUEST_0_SHIPTOCITY' => 'Oberbuchsiten', 'PAYMENTREQUEST_0_SHIPTOZIP' => '4625', 'PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE' => 'CH', 'PAYMENTREQUEST_0_SHIPTOCOUNTRYNAME' => 'Switzerland', 'PAYMENTREQUEST_0_ADDRESSSTATUS' => 'Unconfirmed', 'L_PAYMENTREQUEST_0_NAME0' => 'Kuyichi leather belt JEVER', 'L_PAYMENTREQUEST_0_NUMBER0' => '3503', 'L_PAYMENTREQUEST_0_QTY0' => '1', 'L_PAYMENTREQUEST_0_TAXAMT0' => '0.00', 'L_PAYMENTREQUEST_0_AMT0' => '29.90', 'L_PAYMENTREQUEST_0_ITEMWEIGHTVALUE0' => ' 0.00000', 'L_PAYMENTREQUEST_0_ITEMLENGTHVALUE0' => ' 0.00000', 'L_PAYMENTREQUEST_0_ITEMWIDTHVALUE0' => ' 0.00000', 'L_PAYMENTREQUEST_0_ITEMHEIGHTVALUE0' => ' 0.00000', 'PAYMENTREQUESTINFO_0_ERRORCODE' => '0'); oxRegistry::set('oxVatSelector', new modOxVatSelector()); $article = oxNew('oxarticle'); $article->disableLazyLoading(); $article->setId(substr_replace(oxUtilsObject::getInstance()->generateUId(), '_', 0, 1)); $article->oxarticles__oxprice = new oxField('8.0', oxField::T_RAW); $article->oxarticles__oxartnum = new oxField('666-T-V', oxField::T_RAW); $article->oxarticles__oxactive = new oxField('1', oxField::T_RAW); $article->save(); $basket = oxNew('oxBasket'); $basket->addToBasket($article->getId(), 1); //8 EUR $this->getSession()->setBasket($basket); $details = oxNew('oePayPalResponseGetExpressCheckoutDetails'); $details->setData($data); $payPalService = $this->getMock('oePayPalService', array('getExpressCheckoutDetails')); $payPalService->expects($this->any())->method('getExpressCheckoutDetails')->will($this->returnValue($details)); $proxy = $this->getProxyClassName('oePayPalExpressCheckoutDispatcher'); $dispatcher = $this->getMock($proxy, array('getPayPalCheckoutService', '_isPayPalPaymentValid')); $dispatcher->expects($this->any())->method('_isPayPalPaymentValid')->will($this->returnValue(true)); $dispatcher->expects($this->any())->method('getPayPalCheckoutService')->will($this->returnValue($payPalService)); $utilsView = $this->getMock('oxUtilsView', array('addErrorToDisplay')); $utilsView->expects($this->once())->method('addErrorToDisplay')->with($this->equalTo('OEPAYPAL_ORDER_TOTAL_HAS_CHANGED')); oxTestModules::addModuleObject('oxUtilsView', $utilsView); $this->assertSame('basket', $dispatcher->getExpressCheckoutDetails()); $this->getSession()->setUser(null); // make sure we get the desired active user //proceed in normal checkout $basket = $this->getSession()->getBasket(); //verify basket calculation results $basket->calculateBasket(true); $this->assertSame(6.72, $basket->getNettoSum()); $this->assertSame(6.72, $basket->getBruttoSum()); //no VAT for Switzerland //Change to german address, verify VAT for Germany is charged $this->changeUser(); //during regular checkout, shop will work with a new instance of oxVatSelector //Make sure we use one with clean cache here oxRegistry::get('oxVatSelector')->cleanInstanceCache(); $basket = $this->getSession()->getBasket(); $basket->calculateBasket(true); $this->assertSame(6.72, $basket->getNettoSum()); $this->assertSame(8.0, $basket->getBruttoSum()); }
/** * Testing calcBasketDiscount() and checking if discount is minus (-10) * #1934 * * @return null */ public function testCalcBasketDiscountIfDiscountIsMinus() { $oDiscount2 = oxNew("oxDiscount"); $oDiscount2->setId('_testDiscountId2'); $oDiscount2->oxdiscount__oxtitle = new oxField('Test discount title 123', oxField::T_RAW); $oDiscount2->oxdiscount__oxaddsumtype = new oxField("abs", oxField::T_RAW); $oDiscount2->oxdiscount__oxaddsum = new oxField(-10, oxField::T_RAW); $aDiscounts[] = $oDiscount2; $oDiscountList = $this->getMock('oxDiscountList', array('getBasketDiscounts')); $oDiscountList->expects($this->once())->method('getBasketDiscounts')->will($this->returnValue($aDiscounts)); oxTestModules::addModuleObject('oxDiscountList', $oDiscountList); $oBasket = $this->getProxyClass("oxBasket"); $oPrice = oxNew("oxPrice"); $oPrice->setPrice(20); $oPriceList = oxNew("oxPriceList"); $oPriceList->addToPriceList($oPrice); $aDiscounts = $oBasket->setNonPublicVar('_oDiscountProductsPriceList', $oPriceList); $oBasket->UNITcalcBasketDiscount(); $aDiscounts = $oBasket->getNonPublicVar('_aDiscounts'); $this->assertEquals(1, count($aDiscounts)); //asserting second discount values $this->assertEquals('Test discount title 123', $aDiscounts['_testDiscountId2']->sDiscount); $this->assertEquals(-10, $aDiscounts['_testDiscountId2']->dDiscount); }
/** * Testing getter for checking if user is connected using Facebook connect * * return null */ public function testIsNotConnectedWithFb() { $oFB = $this->getMock("oxFb", array("isConnected")); $oFB->expects($this->any())->method("isConnected")->will($this->returnValue(false)); oxTestModules::addModuleObject('oxFb', $oFB); $this->setConfigParam("bl_showFbConnect", true); $oView = oxNew('oxView'); $this->assertFalse($oView->isConnectedWithFb()); }
public function testGetItemsWithoutActiveArticleCheck() { $oA = $this->getMock('oxarticle', array('getSqlActiveSnippet')); $oA->expects($this->never())->method('getSqlActiveSnippet'); oxTestModules::addModuleObject('oxarticle', $oA); $oBasket = oxNew('oxUserBasket'); $oBasket->load("testUserBasket"); $aItems = $oBasket->getItems(true, false); }
/** * Test counting price category articles * * @return null */ public function testLoadPriceArticles_totalArticlesCount() { $oUtilsCount = $this->getMock('oxUtilsCount', array("getPriceCatArticleCount")); $oUtilsCount->expects($this->once())->method("getPriceCatArticleCount")->will($this->returnValue(25)); oxTestModules::addModuleObject("oxUtilsCount", $oUtilsCount); $oCat = oxNew('oxCategory'); $oArticleList = oxNew('oxArticleList'); $iRes = $oArticleList->loadPriceArticles(1, 2, $oCat); $this->assertEquals(25, $iRes); }
public function testSendPassInvalidMail() { $this->setRequestParameter('editval', array('name' => 'test', 'value' => 'testvalue', 'rec_name' => 'test1', 'rec_email' => 'test2', 'send_name' => 'test3', 'send_email' => 'test4', 'send_message' => 'test5', 'send_subject' => 'test6')); $oEmail = $this->getMock("stdclass", array('sendSuggestMail')); $oEmail->expects($this->never())->method('sendSuggestMail'); oxTestModules::addModuleObject('oxemail', $oEmail); $oProduct = $this->getMock("stdclass", array('getId')); $oProduct->expects($this->never())->method('getId'); /** @var Suggest|PHPUnit_Framework_MockObject_MockObject $oSuggest */ $oSuggest = $this->getMock("suggest", array("getProduct")); $oSuggest->expects($this->never())->method('getProduct')->will($this->returnValue($oProduct)); $oUtilsView = $this->getMock("stdclass", array('addErrorToDisplay')); $oUtilsView->expects($this->once())->method('addErrorToDisplay'); oxTestModules::addModuleObject('oxUtilsView', $oUtilsView); $this->assertEquals('', $oSuggest->send()); }
/** * oxBasketReservation::discardArticleReservation() test case * test the discard of one article reservation and return the reserved * stock to article * * @return null */ public function testDiscardArticleReservation() { $oUB = $this->getMock('stdclass', array('addItemToBasket')); $oUB->expects($this->exactly(1))->method('addItemToBasket')->with($this->equalTo('2000'), $this->equalTo(0), $this->equalTo(null), $this->equalTo(true))->will($this->returnValue(null)); $oR = $this->getMock('oxBasketReservation', array('getReservations', 'getReservedAmount')); $oR->expects($this->exactly(1))->method('getReservations')->will($this->returnValue($oUB)); $oR->expects($this->exactly(1))->method('getReservedAmount')->with($this->equalTo('2000'))->will($this->returnValue(4)); $oA = $this->getMock('oxarticle', array('reduceStock')); $oA->expects($this->exactly(1))->method('reduceStock')->with($this->equalTo(-4))->will($this->returnValue(null)); oxTestModules::addModuleObject('oxarticle', $oA); $oR->discardArticleReservation(2000); }
/** * Test sending a notification to the customer that price alarm was subscribed */ public function testSendPriceAlarmToCustomer() { $config = $this->getConfig(); $config->setConfigParam('blAdmin', true); $config->setAdminMode(true); $oAlarm = oxNew("oxpricealarm"); $oAlarm->oxpricealarm__oxprice = new oxField('123', oxField::T_RAW); $oAlarm->oxpricealarm__oxcurrency = new oxField('EUR'); oxTestModules::addModuleObject("oxShop", $this->_oShop); $oSmarty = $this->getMock('Smarty', array("fetch")); $oSmarty->expects($this->once())->method('fetch')->will($this->returnValue("body")); $oEmail = $this->getMock('oxEmail', array("_sendMail", "_getShop", "_getUseInlineImages", "_getSmarty")); $oEmail->expects($this->once())->method('_sendMail')->will($this->returnValue(true)); $oEmail->expects($this->any())->method('_getShop')->will($this->returnValue($this->_oShop)); $oEmail->expects($this->any())->method('_getUseInlineImages')->will($this->returnValue(true)); $oEmail->expects($this->any())->method('_getSmarty')->will($this->returnValue($oSmarty)); $blRet = $oEmail->sendPriceAlarmToCustomer('*****@*****.**', $oAlarm); $config->setConfigParam('blAdmin', false); $config->setAdminMode(false); $this->assertTrue($blRet, 'Price alarm mail was not sent to user'); // check mail fields $aFields['sRecipient'] = '*****@*****.**'; $aFields['sRecipientName'] = '*****@*****.**'; $aFields['sSubject'] = $this->_oShop->oxshops__oxname->value; $aFields['sFrom'] = '*****@*****.**'; $aFields['sReplyTo'] = '*****@*****.**'; $this->checkMailFields($aFields, $oEmail); }