示例#1
0
 /**
  * @test
  */
 public function getByNotificationShouldDoAGetRequestAddingCredentialsData()
 {
     $xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?><data />');
     $this->client->expects($this->once())->method('get')->with('https://ws.test.com/v2/transactions/notifications/1?email=a%40a.com&token=t')->willReturn($xml);
     $this->decoder->expects($this->once())->method('decode')->with($xml)->willReturn($this->transaction);
     $service = new Locator($this->credentials, $this->client, $this->decoder);
     $this->assertSame($this->transaction, $service->getByNotification(1));
 }
示例#2
0
 public function testDecodeShouldDoReturningObjectTransaction()
 {
     $detailsDate = new DateTime('2011-02-10T16:13:41.000-03:00');
     $detailsLastEventDate = new DateTime('2011-02-10T19:15:11.000-03:00');
     $detailsAddress = new Address('AC', 'Sao Maite', '99500079', 'Centro', 'R Delgado', '55', 'Fundos');
     $customer = new Customer('*****@*****.**', 'FooBar', new Phone('11', '99999999'), $detailsAddress);
     $details = new Details('9E884542', 'REF1234', '6', $detailsDate, $detailsLastEventDate, $customer);
     $paymentMethod = new PaymentMethod(1, 101);
     $escrowEndDate = new DateTime('2011-03-10T08:00:00.000-03:00');
     $payment = new Payment($paymentMethod, 49900.0, 0.01, 0.04, 49900.03, 0.02, 1, $escrowEndDate);
     $shippingAddress = new Address('CE', 'Ortega', '40610912', 'Ipe', 'R. Regina', '36', 'Bl.A');
     $shipping = new Shipping(2, $shippingAddress, 23.45);
     $items = new Items();
     $items->add(new Item(77, 'Produto 01', 2.5, 4, 20, 300));
     $items->add(new Item(88, 'Produto 02', 342.51, 3, 134.98, 1000));
     $transaction = new Transaction($details, $payment, 2, $items, $shipping);
     $obj = simplexml_load_file(__DIR__ . '/xml/transactionFull.xml');
     $decoder = new Decoder();
     $this->assertEquals($transaction, $decoder->decode($obj));
 }
示例#3
0
 /**
  * {@inheritdoc}
  */
 public function getByNotification($code)
 {
     return $this->decoder->decode($this->get(static::ENDPOINT . '/notifications/' . $code));
 }