/**
  * Test case for oepaypaldispatcher::setExpressCheckout()
  * Main functionality
  *
  * @return null
  */
 public function testSetExpressCheckout_onSuccess()
 {
     $oResult = new oePayPalResponseSetExpressCheckout();
     $oResult->setData(array('TOKEN' => 'token'));
     $sUrl = "https://www.sandbox.paypal.com/cgi-bin/webscr&cmd=_express-checkout&token=token";
     //utils
     $oUtils = $this->getMock("oxUtils", array("redirect"));
     $oUtils->expects($this->once())->method("redirect")->with($this->equalTo($sUrl), $this->equalTo(false));
     //config
     $oPayPalConfig = $this->getMock("oePayPalConfig", array("getPayPalCommunicationUrl"));
     $oPayPalConfig->expects($this->once())->method("getPayPalCommunicationUrl")->with($this->equalTo($oResult->getToken()))->will($this->returnValue($sUrl));
     // preparing service
     $oPayPalService = $this->getMock("oePayPalService", array("setExpressCheckout", "setParameter"));
     $oPayPalService->expects($this->once())->method("setExpressCheckout")->will($this->returnValue($oResult));
     // preparing
     $oDispatcher = $this->getMock("oepaypalstandarddispatcher", array("getPayPalCheckoutService", '_getUtils', 'getPayPalConfig'));
     $oDispatcher->expects($this->once())->method("getPayPalCheckoutService")->will($this->returnValue($oPayPalService));
     $oDispatcher->expects($this->any())->method("getPayPalConfig")->will($this->returnValue($oPayPalConfig));
     $oDispatcher->expects($this->once())->method("_getUtils")->will($this->returnValue($oUtils));
     // testing
     $oDispatcher->setExpressCheckout();
 }
 /**
  * Test case for oepaypalexpresscheckoutdispatcher::setExpressCheckout()
  *
  * @return null
  */
 public function testSetExpressCheckout_onSuccess()
 {
     $oResult = new oePayPalResponseSetExpressCheckout();
     $oResult->setData(array('TOKEN' => 'token'));
     $oPayPalConfig = $this->getMock("oePayPalConfig", array("getPayPalCommunicationUrl"));
     $oPayPalConfig->expects($this->once())->method("getPayPalCommunicationUrl")->with($this->equalTo($oResult->getToken()))->will($this->returnValue('url+123'));
     // preparing paypal service
     $oPayPalService = $this->getMock("oePayPalService", array("setExpressCheckout", "getRedirectUrl"));
     $oPayPalService->expects($this->once())->method("setExpressCheckout")->will($this->returnValue($oResult));
     // preparing paypal service
     $oUtils = $this->getMock("oxUtils", array("redirect"));
     $oUtils->expects($this->once())->method("redirect")->with($this->equalTo("url+123"), $this->equalTo(false));
     // preparing
     $oDispatcher = $this->getMock("oepaypalexpresscheckoutdispatcher", array("getPayPalCheckoutService", "_getUtils", "getPayPalConfig"));
     $oDispatcher->expects($this->once())->method("getPayPalCheckoutService")->will($this->returnValue($oPayPalService));
     $oDispatcher->expects($this->any())->method("getPayPalConfig")->will($this->returnValue($oPayPalConfig));
     $oDispatcher->expects($this->once())->method("_getUtils")->will($this->returnValue($oUtils));
     // testing
     $oDispatcher->setExpressCheckout();
     $this->assertEquals("token", $this->getSession()->getVariable("oepaypal-token"));
 }
 /**
  * Test getting callback url
  */
 public function testGetToken()
 {
     $oResponse = new oePayPalResponseSetExpressCheckout();
     $oResponse->setData($this->_getResponseData());
     $this->assertEquals('thisIsToken', $oResponse->getToken());
 }