コード例 #1
0
 /**
  * @param int $iCurrentTime
  */
 private function _prepareCurrentTime($iCurrentTime)
 {
     $oUtilsDate = $this->getMock('oxUtilsDate', array('getTime'));
     $oUtilsDate->expects($this->any())->method('getTime')->will($this->returnValue($iCurrentTime));
     /** @var oxUtilsDate $oUtils */
     oxRegistry::set('oxUtilsDate', $oUtilsDate);
 }
コード例 #2
0
 /**
  * Test colon smarty modifier
  *
  * @dataProvider provider
  */
 public function testColons($sTranslation, $sResult)
 {
     $oLang = $this->getMock("oxLang", array("translateString"));
     $oLang->expects($this->any())->method("translateString")->with($this->equalTo('COLON'))->will($this->returnValue($sTranslation));
     oxRegistry::set('oxLang', $oLang);
     $this->assertEquals($sResult, smarty_modifier_colon('Name'));
 }
コード例 #3
0
 /**
  * Class constructor.
  * Sets current module main data and loads the rest module info.
  */
 function __construct()
 {
     $sModuleId = 'oxpsmodulegenerator';
     $this->setModuleData(array('id' => $sModuleId, 'title' => 'OXID Module Skeleton Generator', 'description' => 'Folders structure, empty classes and metadata generation for new OXID eShop modules.'));
     $this->load($sModuleId);
     oxRegistry::set('oxpsModuleGeneratorModule', $this);
 }
コード例 #4
0
ファイル: loginTest.php プロジェクト: Crease29/oxideshop_ce
 /**
  * Tries to login with old password from different subshop, makes sure there are no crashes
  */
 public function testAdminLoginWithOldPasswordMultishop()
 {
     $this->setAdminMode(true);
     //faking cookie check
     $oUtils = $this->getMock("oxUtilsServer", array("getOxCookie"));
     $oUtils->expects($this->any())->method("getOxCookie")->will($this->returnValue(array("test" => "test")));
     oxRegistry::set("oxUtilsServer", $oUtils);
     //creating test admin user
     $oUser = $this->_createUser($this->_sDefaultUserName, $this->_sOldEncodedPassword, $this->_sOldSalt);
     //updating user over oxBase methods as oxUser restricts rights update
     $oUpdUser = oxNew('oxBase');
     $oUpdUser->init("oxuser");
     $oUpdUser->load($oUser->getId());
     $oUpdUser->oxuser__oxrights = new oxField(1);
     $oUpdUser->oxuser__oxshopid = new oxField(1);
     $oUpdUser->save();
     //set active shop 2
     oxRegistry::getConfig()->setShopId(2);
     //perform the login
     $this->_login($this->_sDefaultUserName, $this->_sDefaultUserPassword);
     $oUser->load($oUser->getId());
     $this->assertEquals(1, $oUser->oxuser__oxshopid->value, "User shop ID changed");
     $this->assertSame($oUser->getId(), oxRegistry::getSession()->getVariable('auth'), 'User ID is missing in session.');
     $this->assertNotSame($this->_sOldEncodedPassword, $oUser->oxuser__oxpassword->value, 'Old and new passwords must not match.');
     $this->assertNotSame($this->_sOldSalt, $oUser->oxuser__oxpasssalt->value, 'Old and new salt must not match.');
 }
コード例 #5
0
 /**
  * Class constructor.
  * Sets current module main data and loads the rest module info.
  */
 function __construct()
 {
     $sModuleId = 'hbocolmapper';
     $this->setModuleData(array('id' => $sModuleId, 'title' => 'HBO Val Mapper', 'description' => 'HBO Val Mapper Module'));
     $this->load($sModuleId);
     oxRegistry::set('hboValMapperModule', $this);
 }
コード例 #6
0
 /**
  * Class constructor.
  * Sets current module main data and loads the rest module info.
  */
 function __construct()
 {
     $sModuleId = 'oeloggerdemo';
     $this->setModuleData(array('id' => $sModuleId, 'title' => 'OE Logger Demo', 'description' => 'OE Logger Demo Module'));
     $this->load($sModuleId);
     oxRegistry::set('oeLoggerDemoModule', $this);
 }
コード例 #7
0
 /**
  * Class constructor.
  * Sets main module data and load additional data.
  */
 function __construct($sModuleTitle = 'Paymorrow Payments', $sModuleDescription = 'Paymorrow Payments Module')
 {
     $sModuleId = 'oxpspaymorrow';
     $this->setModuleData(array('id' => $sModuleId, 'title' => $sModuleTitle, 'description' => $sModuleDescription));
     $this->load($sModuleId);
     // Add the module class to oxRegistry
     oxRegistry::set('OxpsPaymorrowModule', $this);
 }
コード例 #8
0
 /**
  * Cleans up the registry before/after the test execution
  *
  * @return null;
  */
 protected function _resetRegistry()
 {
     $aRegKeys = oxRegistry::getKeys();
     $aSkippedClasses = array("oxconfigfile");
     foreach ($aRegKeys as $sKey) {
         if (!in_array($sKey, $aSkippedClasses)) {
             oxRegistry::set($sKey, null);
         }
     }
 }
コード例 #9
0
 /**
  * Test view render.
  *
  * @return null
  */
 public function testRender()
 {
     $_SERVER['HTTP_COOKIE'] = "shop=1";
     $oView = oxNew('ClearCookies');
     $oUtilsServer = $this->getMock('oxUtilsServer', array('setOxCookie'));
     $oUtilsServer->expects($this->at(0))->method('setOxCookie')->with($this->equalTo('shop'));
     $oUtilsServer->expects($this->at(1))->method('setOxCookie')->with($this->equalTo('language'));
     $oUtilsServer->expects($this->at(2))->method('setOxCookie')->with($this->equalTo('displayedCookiesNotification'));
     oxRegistry::set('oxUtilsServer', $oUtilsServer);
     $this->assertEquals('page/info/clearcookies.tpl', $oView->render());
 }
 /**
  * Set SUT state before test.
  */
 public function setUp()
 {
     parent::setUp();
     $this->SUT = $this->getMock('oxpsModulesConfigRequestValidator', array('__call', '_isReadableFile'));
     $this->SUT->expects($this->any())->method('_isReadableFile')->will($this->returnValue(true));
     // Content model mock
     $oContent = $this->getMock('oxpsModulesConfigContent', array('__call', 'getModulesList', 'getSettingsList'));
     $oContent->expects($this->any())->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->any())->method('getSettingsList')->will($this->returnValue(array('version' => 'Versions', 'extend' => 'Extended classes')));
     oxRegistry::set('oxpsModulesConfigContent', $oContent);
 }
コード例 #11
0
 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());
 }
コード例 #12
0
 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);
 }
コード例 #13
0
 /**
  * Test helper for test preparation.
  * Add given count of new languages.
  *
  * @param $count
  *
  * @return int
  */
 protected function prepare($count = 9)
 {
     for ($i = 0; $i < $count; $i++) {
         $languageName = chr(97 + $i) . chr(97 + $i);
         $languageId = $this->insertLanguage($languageName);
     }
     //we need a fresh instance of language object in registry,
     //otherwise stale data is used for language abbreviations.
     oxRegistry::set('oxLang', null);
     oxRegistry::set('oxTableViewNameGenerator', null);
     $this->updateViews();
     return $languageId;
 }
コード例 #14
0
 /**
  * Testing addition of comment after PayPal request processing
  */
 public function testProcess_ProcessingOfServiceResponse_CommentAdded()
 {
     $oUtilsDate = $this->getMock('oxUtilsDate', array('getTime'));
     $oUtilsDate->expects($this->any())->method('getTime')->will($this->returnValue(1410431540));
     oxRegistry::set('oxUtilsDate', $oUtilsDate);
     $sComment = 'testComment';
     $oComment = new oePayPalOrderPaymentComment();
     $oComment->setComment($sComment);
     $oPayPalResponse = $this->_getPayPalResponse();
     $oPayment = $this->_getPayment();
     $oPayment->expects($this->once())->method('addComment')->with($this->equalTo($oComment));
     $oPaymentList = $this->_getPaymentList(array('addPayment'));
     $oPaymentList->expects($this->any())->method('addPayment')->will($this->returnValue($oPayment));
     $oOrder = $this->_getOrder(array('getPaymentList'));
     $oOrder->expects($this->any())->method('getPaymentList')->will($this->returnValue($oPaymentList));
     $oData = $this->_getData();
     $oData->expects($this->any())->method('getComment')->will($this->returnValue($sComment));
     $oAction = $this->_getAction($oPayPalResponse, $oOrder, $oData);
     $oAction->process();
 }
コード例 #15
0
 /**
  * Testing oxcmp_utils::toWishList()
  *
  * @return null
  */
 public function testToWishList()
 {
     /** @var oxSession|PHPUnit_Framework_MockObject_MockObject $oSession */
     $oSession = $this->getMock('oxSession', array('checkSessionChallenge'));
     $oSession->expects($this->exactly(2))->method('checkSessionChallenge')->will($this->returnValue(true));
     oxRegistry::set('oxSession', $oSession);
     $this->getConfig()->setConfigParam("bl_showWishlist", false);
     /** @var oxcmp_utils|PHPUnit_Framework_MockObject_MockObject $oCmp */
     $oCmp = $this->getMock("oxcmp_utils", array("_toList"));
     $oCmp->expects($this->never())->method('_toList');
     $oCmp->toWishList('1126', 999, 'sel');
     $this->getConfig()->setConfigParam("bl_showWishlist", true);
     /** @var oxcmp_utils|PHPUnit_Framework_MockObject_MockObject $oCmp */
     $oCmp = $this->getMock("oxcmp_utils", array("_toList"));
     $oCmp->expects($this->once())->method('_toList')->with($this->equalTo('wishlist'), $this->equalTo('1126'), $this->equalTo(999), $this->equalTo('sel'));
     $oCmp->toWishList('1126', 999, 'sel');
 }
コード例 #16
0
 /**
  * @param string $entryPoint
  */
 private function setToRegistryOxUtilsUrlMock($entryPoint)
 {
     $utilsUrl = $this->getMock('oxUtilsUrl');
     $utilsUrl->expects($this->atLeastOnce())->method('processUrl')->with($this->identicalTo($this->shopUrl . $entryPoint, false))->will($this->returnValue($this->shopUrl . $entryPoint . '?'));
     oxRegistry::set('oxUtilsUrl', $utilsUrl);
 }
 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());
 }
コード例 #18
0
 /**
  * When oxConfigFile is not registered in registry (happens during setup), it should be created on the fly.
  */
 public function testForcingEditionByConfigWhenNotRegistered()
 {
     $path = $this->createFile('config.inc.php', '<?php $this->edition = "EE";');
     $this->setConfigParam('sShopDir', dirname($path));
     $configFile = oxRegistry::get('oxConfigFile');
     oxRegistry::set('oxConfigFile', null);
     $editionSelector = new EditionSelector();
     $this->assertTrue($editionSelector->isEnterprise());
     $this->assertFalse($editionSelector->isCommunity());
     $this->assertFalse($editionSelector->isProfessional());
     oxRegistry::set('oxConfigFile', $configFile);
 }
コード例 #19
0
 /**
  * test
  */
 public function testGetBannerLink()
 {
     $sUrl = "action-link";
     $oUtilsUrl = $this->getMock('oxUtilsUrl', array('processUrl', 'addShopHost'));
     $oUtilsUrl->expects($this->any())->method('addShopHost')->with($sUrl)->will($this->returnValue('http://with-url/' . $sUrl));
     $oUtilsUrl->expects($this->any())->method('processUrl')->with('http://with-url/' . $sUrl)->will($this->returnValue($sUrl . '/with-params'));
     oxRegistry::set("oxUtilsUrl", $oUtilsUrl);
     $oPromo = oxNew('oxActions');
     $oPromo->oxactions__oxlink = new oxField($sUrl);
     $this->assertEquals($sUrl . '/with-params', $oPromo->getBannerLink());
 }
コード例 #20
0
 /**
  * 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());
 }
コード例 #21
0
 /**
  * Testing Account_Wishlist::togglePublic()
  *
  * @return null
  */
 public function testTogglePublic()
 {
     $this->setRequestParameter("blpublic", 1);
     /** @var oxBasket|PHPUnit_Framework_MockObject_MockObject $oBasket */
     $oBasket = $this->getMock("oxBasket", array("save"));
     $oBasket->expects($this->once())->method('save');
     /** @var oxUser|PHPUnit_Framework_MockObject_MockObject $oUser */
     $oUser = $this->getMock("oxUser", array("getBasket"));
     $oUser->expects($this->once())->method('getBasket')->with($this->equalTo("wishlist"))->will($this->returnValue($oBasket));
     /** @var oxSession|PHPUnit_Framework_MockObject_MockObject $oSession */
     $oSession = $this->getMock('oxSession', array('checkSessionChallenge'));
     $oSession->expects($this->once())->method('checkSessionChallenge')->will($this->returnValue(true));
     oxRegistry::set('oxSession', $oSession);
     /** @var Account_Wishlist|PHPUnit_Framework_MockObject_MockObject $oView */
     $oView = $this->getMock("Account_Wishlist", array("getUser"));
     $oView->expects($this->once())->method('getUser')->will($this->returnValue($oUser));
     $oView->togglePublic();
 }
コード例 #22
0
 /**
  * oxsession::sid() test in amdin
  */
 function testSidIsSearchEngine()
 {
     $this->setConfigParam('blSessionUseCookies', false);
     $this->setConfigParam('aCacheViews', array());
     $utils = $this->getMock('oxUtils', array('isSearchEngine'));
     $utils->expects($this->any())->method('isSearchEngine')->will($this->returnValue(true));
     oxRegistry::set('oxUtils', $utils);
     $oSession = $this->getMock('testSession', array('_getCookieSid', 'isAdmin'));
     $oSession->expects($this->any())->method('_getCookieSid')->will($this->returnValue('admin_sid'));
     $oSession->expects($this->any())->method('isAdmin')->will($this->returnValue(false));
     $oSession->UNITsetSessionId('testSid');
     $sSid = $oSession->sid();
     // update: shp adding functionality is also in oxUtilsUrl, where it belongs
     $this->assertEquals('', $sSid);
 }
コード例 #23
0
 /**
  * /**
  * Tests retrieve session challenge token from session.
  *
  * @dataProvider _dpGetSessionChallengeToken
  *
  * @param boolean $isSessionStarted Was session started.
  * @param integer $callTimes method How many times getSessionChallengeToken is expected to be called.
  * @param string  $token            Security token.
  */
 public function testGetSessionChallengeToken($isSessionStarted, $callTimes, $token)
 {
     /** @var oxSession|PHPUnit_Framework_MockObject_MockObject $session */
     $session = $this->getMock('oxSession', array('isSessionStarted', 'getSessionChallengeToken'));
     $session->expects($this->once())->method('isSessionStarted')->will($this->returnValue($isSessionStarted));
     $session->expects($this->exactly($callTimes))->method('getSessionChallengeToken')->will($this->returnValue($token));
     oxRegistry::set('oxSession', $session);
     /** @var oxViewConfig $viewConfig */
     $viewConfig = oxNew('oxViewConfig');
     $viewConfig->setSession($session);
     $this->assertSame($token, $viewConfig->getSessionChallengeToken());
 }
コード例 #24
0
 /**
  * Testing seo call processor using http status code 301 for redirects of seo history
  * see https://bugs.oxid-esales.com/view.php?id=5471
  * We test processing a simple url.
  *
  */
 public function testProcessSeoCallUsingStatus301ForRedirectsSimpleUrl()
 {
     $encoder = $this->getMock('oxseodecoder', array('_getParams', 'decodeUrl', '_decodeOldUrl', '_decodeSimpleUrl'));
     $shopUrl = $encoder->getConfig()->getShopURL();
     $parameters = 'en/Kiteboarding/Kites/Kite-CORE-GTS.html';
     $decodedSimpleUrlPart = 'en/Something/really/simple.html';
     $redirectSimpleUrl = rtrim($shopUrl, '/') . '/' . $decodedSimpleUrlPart;
     $encoder->expects($this->once())->method('_getParams')->will($this->returnValue($parameters));
     $encoder->expects($this->once())->method('decodeUrl')->will($this->returnValue(null));
     $encoder->expects($this->once())->method('_decodeOldUrl')->with($this->equalTo($parameters))->will($this->returnValue(null));
     $encoder->expects($this->once())->method('_decodeSimpleUrl')->with($this->equalTo($parameters))->will($this->returnValue($decodedSimpleUrlPart));
     $utils = $this->getMock('oxutils', array('redirect'));
     $utils->expects($this->once())->method('redirect')->with($this->equalTo($redirectSimpleUrl), $this->equalTo(false), $this->equalTo(301));
     oxRegistry::set('oxUtils', $utils);
     //call simulates decoding of an old style (simple) url
     $encoder->processSeoCall();
 }
コード例 #25
0
 /**
  * Creates middle classes if needed.
  *
  * @param array  $aClassChain Module names
  * @param string $sBaseModule Oxid base class
  *
  * @throws oxSystemComponentException missing system component exception
  *
  * @return string
  */
 protected function _makeSafeModuleClassParents($aClassChain, $sBaseModule)
 {
     $sParent = $sBaseModule;
     $sClassName = $sBaseModule;
     //building middle classes if needed
     foreach ($aClassChain as $sModule) {
         //creating middle classes
         //e.g. class suboutput1_parent extends oxoutput {}
         //     class suboutput2_parent extends suboutput1 {}
         //$sModuleClass = $this->getClassName($sModule);
         //security: just preventing string termination
         $sModule = str_replace(chr(0), '', $sModule);
         //get parent and module class names from sub/suboutput2
         $sModuleClass = basename($sModule);
         if (!class_exists($sModuleClass, false)) {
             $sParentClass = basename($sParent);
             $sModuleParentClass = $sModuleClass . "_parent";
             //initializing middle class
             if (!class_exists($sModuleParentClass, false)) {
                 // If possible using alias instead if eval (since php 5.3).
                 if (function_exists('class_alias')) {
                     class_alias($sParentClass, $sModuleParentClass);
                 } else {
                     eval("abstract class {$sModuleParentClass} extends {$sParentClass} {}");
                 }
             }
             $sParentPath = oxRegistry::get("oxConfigFile")->getVar("sShopDir") . "/modules/" . $sModule . ".php";
             //including original file
             if (file_exists($sParentPath)) {
                 include_once $sParentPath;
             } elseif (!class_exists($sModuleClass)) {
                 // special case is when oxconfig class is extended: we cant call "_disableModule" as it requires valid config object
                 // but we can't create it as module class extending it does not exist. So we will use orginal oxConfig object instead.
                 if ($sParentClass == "oxconfig") {
                     $oConfig = $this->_getObject("oxconfig", 0, null);
                     oxRegistry::set("oxconfig", $oConfig);
                 }
                 // disable module if extended class is not found
                 $blDisableModuleOnError = !oxRegistry::get("oxConfigFile")->getVar("blDoNotDisableModuleOnError");
                 if ($blDisableModuleOnError) {
                     $this->_disableModule($sModule);
                 } else {
                     //to avoid problems with unitest and only throw a exception if class does not exists MAFI
                     /** @var oxSystemComponentException $oEx */
                     $oEx = oxNew("oxSystemComponentException");
                     $oEx->setMessage("EXCEPTION_SYSTEMCOMPONENT_CLASSNOTFOUND");
                     $oEx->setComponent($sModuleClass);
                     throw $oEx;
                 }
                 continue;
             }
         }
         $sParent = $sModule;
         $sClassName = $sModule;
     }
     //returning the last module from the chain
     return $sClassName;
 }
コード例 #26
0
 public function testInstanceExists()
 {
     oxRegistry::set("testKey", "testVal");
     $this->assertTrue(Registry::instanceExists('testKey'));
     oxRegistry::set("testKey", null);
     $this->assertFalse(Registry::instanceExists('testKey'));
 }
コード例 #27
0
 /**
  * Test view logout().
  *
  * @return null
  */
 public function testCreateUserNotConfirmedAGB()
 {
     $this->getConfig()->setConfigParam('blConfirmAGB', true);
     $oUtilsView = $this->getMock('oxUtilsView', array("addErrorToDisplay"));
     $oUtilsView->expects($this->once())->method('addErrorToDisplay')->with($this->equalTo('READ_AND_CONFIRM_TERMS'), $this->equalTo(false), $this->equalTo(true));
     oxRegistry::set('oxUtilsView', $oUtilsView);
     $oParent = $this->getMock('oxubase', array("isEnabledPrivateSales"));
     $oParent->expects($this->once())->method('isEnabledPrivateSales')->will($this->returnValue(true));
     $oUserView = $this->getMock($this->getProxyClassName("oxcmp_user"), array('getParent'));
     $oUserView->expects($this->any())->method('getParent')->will($this->returnValue($oParent));
     $this->assertNull($oUserView->createUser());
 }
コード例 #28
0
 /**
  * add object to be returned from oxNew for a class
  *
  * @param string $sClassName
  * @param object $oObject
  *
  * @return null
  */
 public static function addModuleObject($sClassName, $oObject)
 {
     oxRegistry::set($sClassName, null);
     oxUtilsObject::setClassInstance($sClassName, $oObject);
     /*
     $sClassName = strtolower($sClassName);
     if (!self::$_oOrigOxUtilsObj) {
         self::$_oOrigOxUtilsObj = oxUtilsObject::getInstance();
         self::addFunction('oxUtilsObject', 'oxNew($class)', '{return oxTestModules::getModuleObject($class);}');
     }
     self::$_aModuleMap[$sClassName] = $oObject;
     */
 }
コード例 #29
0
 /**
  * Tests if recommlist rating is saved
  *
  * @return null
  */
 public function testSaveReview()
 {
     $this->setRequestParameter("recommlistrating", 3);
     $this->setRequestParameter("rvw_txt", "testRecommId");
     /** @var oxSession|PHPUnit_Framework_MockObject_MockObject $oSession */
     $oSession = $this->getMock('oxSession', array('checkSessionChallenge'));
     $oSession->expects($this->once())->method('checkSessionChallenge')->will($this->returnValue(true));
     oxRegistry::set('oxSession', $oSession);
     /** @var oxRecommList|PHPUnit_Framework_MockObject_MockObject $oRecommList */
     $oRecommList = $this->getMock("oxRecommList", array("addToRatingAverage", "getId"));
     $oRecommList->expects($this->once())->method('addToRatingAverage');
     $oRecommList->expects($this->any())->method('getId')->will($this->returnValue("testRecommListId"));
     /** @var oxUser|PHPUnit_Framework_MockObject_MockObject $oUser */
     $oUser = $this->getMock("oxuser", array("getId"));
     $oUser->expects($this->any())->method('getId')->will($this->returnValue("testUserId"));
     /** @var RecommList|PHPUnit_Framework_MockObject_MockObject $oView */
     $oView = $this->getMock("RecommList", array("getActiveRecommList", "getUser", "canAcceptFormData"));
     $oView->expects($this->any())->method('canAcceptFormData')->will($this->returnValue(true));
     $oView->expects($this->any())->method('getUser')->will($this->returnValue($oUser));
     $oView->expects($this->any())->method('getActiveRecommList')->will($this->returnValue($oRecommList));
     $oView->saveReview();
     $oDb = oxDb::getDb();
     // testing db for records
     $this->assertTrue("1" === $oDb->getOne("select 1 from oxratings where oxuserid='testUserId' and oxrating = '3' and oxobjectid = 'testRecommListId'"));
     $this->assertTrue("1" === $oDb->getOne("select 1 from oxreviews where oxuserid='testUserId' and oxobjectid = 'testRecommListId'"));
 }
コード例 #30
0
 /**
  * Special case is when oxconfig class is extended: we cant call "_disableModule" as it requires valid config object
  * but we can't create it as module class extending it does not exist. So we will use original oxConfig object instead.
  *
  * @param string $requestedClass Class, for which extension chain was generated.
  * @param string $extensionClass
  */
 protected function handleSpecialCases($requestedClass, $extensionClass)
 {
     if ($requestedClass == "oxconfig") {
         $config = new oxConfig();
         oxRegistry::set("oxConfig", $config);
     }
 }