/**
  * @test
  */
 public function testSerializeShouldReturnXMLFull()
 {
     $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));
     $shippingAddress = new Address('CE', 'Ortega do Norte', '40610-912', 'Ipe', 'R. Regina Salas', '3601', 'Bl.A');
     $shipping = new Shipping(1, $shippingAddress, 23.45);
     $order = new Order($items);
     $order->setReference('REF1234');
     $order->setExtraAmount(1.01);
     $order->setShipping($shipping);
     $customerAddress = new Address('AC', 'Sao Maite', '99500-079', 'Centro', 'Rua David Delgado', '55', 'Fundos');
     $customerPhone = new Phone('11', '99999999');
     $customer = new Customer('*****@*****.**', 'FooBar', $customerPhone, $customerAddress);
     $checkout = new Checkout($order);
     $checkout->setCustomer($customer);
     $checkout->setRedirectTo('http://localhost/return.php');
     $checkout->setMaxUses(5);
     $checkout->setMaxAge(60);
     $serializer = new CheckoutSerializer();
     $xml = $serializer->serialize($checkout);
     $this->assertInstanceOf(SimpleXMLElement::class, $xml);
     $expected = simplexml_load_file(__DIR__ . '/xml/checkoutFull.xml');
     $this->assertEquals($expected, $xml);
 }
Exemplo n.º 2
0
 /**
  * @param SimpleXMLElement $xml
  * @param Checkout $checkout
  */
 private function appendCheckoutData(SimpleXMLElement $xml, Checkout $checkout)
 {
     $this->appendOrder($xml, $checkout->getOrder());
     $this->appendCustomer($xml, $checkout->getCustomer());
     if ($redirectTo = $checkout->getRedirectTo()) {
         $xml->addChild('redirectURL', $redirectTo);
     }
     if ($notificationURL = $checkout->getNotificationURL()) {
         $xml->addChild('notificationURL', $notificationURL);
     }
     if ($maxUses = $checkout->getMaxUses()) {
         $xml->addChild('maxUses', $maxUses);
     }
     if ($maxAge = $checkout->getMaxAge()) {
         $xml->addChild('maxAge', $maxAge);
     }
 }
 /**
  * @test
  */
 public function setReferenceShouldConfigureTheReference()
 {
     $this->builder->setReference('testing');
     $this->assertAttributeEquals('testing', 'reference', $this->checkout->getOrder());
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function setMaxUses($maxUses)
 {
     $this->checkout->setMaxUses($maxUses);
     return $this;
 }
Exemplo n.º 5
0
 /**
  * @test
  */
 public function getCustomerShouldReturnConfiguredCustomer()
 {
     $customer = $this->getMock(Customer::class, [], [], '', false);
     $this->checkout->setCustomer($customer);
     $this->assertSame($customer, $this->checkout->getCustomer());
 }
Exemplo n.º 6
0
 /**
  * @test
  */
 public function setMaxUsesShouldTheNumberOfUses()
 {
     $this->checkout->setMaxUses(1);
     $this->assertAttributeEquals(1, 'maxUses', $this->checkout);
 }
Exemplo n.º 7
0
 /**
  * @test
  */
 public function setNotificationURLShouldConfigureTheNotificationUri()
 {
     $uri = 'http://chibungo.com';
     $this->checkout->setNotificationURL($uri);
     $this->assertAttributeEquals($uri, 'notificationURL', $this->checkout);
 }