/** * Test case for oepaypalstandarddispatcher::getExpressCheckoutDetails() * * @return null */ public function testGetExpressCheckoutDetails() { // preparing session, inputs etc. $this->getSession()->setVariable("oepaypal-token", "111"); $aDetails["PAYERID"] = "111"; $oDetails = new oePayPalResponseGetExpressCheckoutDetails(); $oDetails->setData($aDetails); // preparing config $oPayPalConfig = $this->getMock("oePayPalConfig", array("finalizeOrderOnPayPalSide")); $oPayPalConfig->expects($this->once())->method("finalizeOrderOnPayPalSide")->will($this->returnValue(true)); // preparing service $oPayPalService = $this->getMock("oePayPalService", array("getExpressCheckoutDetails")); $oPayPalService->expects($this->once())->method("getExpressCheckoutDetails")->will($this->returnValue($oDetails)); // preparing $oDispatcher = $this->getMock("oepaypalstandarddispatcher", array("getPayPalCheckoutService", "getPayPalConfig")); $oDispatcher->expects($this->once())->method("getPayPalCheckoutService")->will($this->returnValue($oPayPalService)); $oDispatcher->expects($this->once())->method("getPayPalConfig")->will($this->returnValue($oPayPalConfig)); // testing $this->assertEquals("order?fnc=execute", $oDispatcher->getExpressCheckoutDetails()); $this->assertEquals("111", $this->getSession()->getVariable("oepaypal-payerId")); }
/** * Test getting company name */ public function testGetBusiness() { $oResponse = new oePayPalResponseGetExpressCheckoutDetails(); $oResponse->setData($this->_getResponseData()); $this->assertEquals('company', $oResponse->getBusiness()); }
/** * Test case for oePayPalAddress::createPayPalAddress() * Creating new address * * @dataProvider createPayPalAddress_splittingUserName_dataProvider * * @return null */ public function testCreatePayPalAddress_splittingUserName($sName, $aResult) { $aPayPalData = $this->_getPayPalData(); $oPayPalData = new oePayPalResponseGetExpressCheckoutDetails(); $aPayPalData['PAYMENTREQUEST_0_SHIPTONAME'] = $sName; $oPayPalData->setData($aPayPalData); $oPayPalOxAddress = new oePayPalOxAddress(); $oPayPalOxAddress->createPayPalAddress($oPayPalData, 'testUserId'); $sAddressId = $oPayPalOxAddress->getId(); $oAddress = new oxAddress(); $oAddress->load($sAddressId); $this->assertEquals($aResult[0], $oAddress->oxaddress__oxfname->value); $this->assertEquals($aResult[1], $oAddress->oxaddress__oxlname->value); }
/** * Test case for oepaypalexpresscheckoutdispatcher::_initializeUserData() - Logged in shop user, paypal returns user email * that exists in shop and has same address. No new user address should be created. * * @return null */ public function testInitializeUserData_loggedUser_sameAddress() { $aUserDetails["EMAIL"] = "testUserEmail"; $oDetails = new oePayPalResponseGetExpressCheckoutDetails(); $oDetails->setData($aUserDetails); $this->getSession()->setVariable("deladrid", "testDelId"); $this->assertEquals("testDelId", $this->getSession()->getVariable("deladrid")); $oUser = $this->getMock("oxUser", array("isRealPayPalUser", "isSamePayPalUser", "isSameAddressPayPalUser", 'isSameAddressUserPayPalUser')); $oUser->expects($this->once())->method("isRealPayPalUser")->with($this->equalTo("testLoggedUserEmail"))->will($this->returnValue("testLoggedUserId")); $oUser->expects($this->once())->method("isSameAddressPayPalUser")->with($this->equalTo($oDetails))->will($this->returnValue(true)); $oUser->expects($this->once())->method("isSameAddressUserPayPalUser")->with($this->equalTo($oDetails))->will($this->returnValue(true)); $oUser->expects($this->never())->method("isSamePayPalUser"); $oUser->oxuser__oxusername = new oxField("testLoggedUserEmail"); oxTestModules::addModuleObject('oxUser', $oUser); // preparing $oDispatcher = $this->getMock("oepaypalexpresscheckoutdispatcher", array("_createUserAddress", "getUser")); $oDispatcher->expects($this->never())->method("_createUserAddress"); $oDispatcher->expects($this->once())->method("getUser")->will($this->returnValue($oUser)); // testing $oDispatcher->UNITinitializeUserData($oDetails); // delivery address id storred in session should be deleted $this->assertNull($this->getSession()->getVariable("deladrid")); }
/** * Test case for oePayPalOxUser::isSamePayPalUser() * * @return null */ public function testIsSameAddressPayPalUser_decoding_html() { $aPayPalData = $this->_getPayPalData(); $oDetails = new oePayPalResponseGetExpressCheckoutDetails(); $oDetails->setData($aPayPalData); oxTestModules::addModuleObject('oxAddress', new oePayPalOxAddress()); $oUser = new oePayPalOxUser(); $oUser->createPayPalUser($oDetails); // by default single quote ' will be convrted to ' $oUser->oxuser__oxstreet = new oxField("test'StreetName"); $oUser->oxuser__oxstreetnr = new oxField("5"); $oUser->oxuser__oxcity = new oxField("test'City"); $aPayPalData['PAYMENTREQUEST_0_SHIPTOSTREET'] = "test'StreetName 5"; $aPayPalData["PAYMENTREQUEST_0_SHIPTOCITY"] = "test'City"; $oDetails->setData($aPayPalData); $this->assertTrue($oUser->isSamePayPalUser($oDetails)); }