function testCall() { XmlSerializer::$sort = true; $data = $this->schemaRequest('WpfPayment.json'); $requestXml = $this->schemaRequest('WpfPayment.xml'); $responseXml = $this->schemaResponse('WpfPayment_new.xml'); $this->curlMock()->shouldReceive('xmlPost')->with('https://testpayment.hypercharge.net/payment', $requestXml)->once()->andReturn($responseXml); $request = new PaymentRequest($data['payment']); $url = new PaymentUrl(Config::getMode()); $ws = new XmlWebservice(); $response = $ws->call($url, $request); $this->assertIsA($response, 'Hypercharge\\Payment'); $this->assertEqual($response->type, 'WpfPayment'); }
function mockUrls() { $mode = Config::getMode(); $c = $this->credentials; $factory = m::mock('Hypercharge\\Factory[createPaymentUrl,createTransactionUrl,createUrl]'); //////////// // Payments foreach (array('cancel', 'void', 'capture', 'refund', 'reconcile') as $action) { $url = m::mock('Hypercharge\\PaymentUrl[getUrl]', array($mode, $action)); $url->shouldReceive('getUrl')->andReturn($c->paymentHost . '/payment'); $factory->shouldReceive('createPaymentUrl')->with($action)->andReturn($url); } // action = 'create' $url = m::mock('Hypercharge\\PaymentUrl[getUrl]', array($mode)); $url->shouldReceive('getUrl')->andReturn($c->paymentHost . '/payment'); $factory->shouldReceive('createPaymentUrl')->with()->andReturn($url); /////////////// // Transactions // foreach (array('process', 'reconcile', 'reconcile/by_date') as $action) { // USD channel $url = m::mock('Hypercharge\\TransactionUrl[getUrl]', array($mode, $c->channelTokens->USD, $action)); $url->shouldReceive('getUrl')->andReturn($c->gatewayHost); $factory->shouldReceive('createTransactionUrl')->with($c->channelTokens->USD, $action)->andReturn($url); // EUR channel $url = m::mock('Hypercharge\\TransactionUrl[getUrl]', array($mode, $c->channelTokens->EUR, $action)); $url->shouldReceive('getUrl')->andReturn($c->gatewayHost); $factory->shouldReceive('createTransactionUrl')->with($c->channelTokens->EUR, $action)->andReturn($url); $url = m::mock('Hypercharge\\TransactionUrl[getUrl]', array($mode, 'wrong_channel_token', $action)); $url->shouldReceive('getUrl')->andReturn($c->gatewayHost); $factory->shouldReceive('createTransactionUrl')->with('wrong_channel_token', $action)->andReturn($url); } Config::setFactory($factory); }