public function testSerializeShouldXMLFull()
 {
     $preApproval = new PreApproval();
     $preApproval->setChargeType('auto');
     $preApproval->setName('Assinatura Revista');
     $preApproval->setPeriod('MONTHLY');
     $preApproval->setFinalDate(new DateTime('2016-11-18'));
     $preApproval->setMaxTotalAmount(3000);
     $preApproval->setDetails('Cobranca Mensal da Revista');
     $preApproval->setAmountPerPayment(100);
     $preApproval->setMaxAmountPerPayment(150);
     $preApproval->setInitialDate(new DateTime('2015-11-18'));
     $preApproval->setMaxPaymentsPerPeriod(12);
     $preApproval->setMaxAmountPerPeriod(1200);
     $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);
     $request = new Request($preApproval);
     $request->setCustomer($customer);
     $request->setReference('abcdef');
     $request->setReviewOn('http://localhost/return.php');
     $request->setRedirectTo('http://localhost/success.php');
     $serializer = new RequestSerializer();
     $xml = $serializer->serialize($request);
     $this->assertInstanceOf(SimpleXMLElement::class, $xml);
     $expected = simplexml_load_file(__DIR__ . '/xml/preAprovalsRequestFull.xml');
     $this->assertEquals($expected, $xml);
 }
 /**
  * @param SimpleXMLElement $xml
  * @param Request $request
  */
 private function appendRequest(SimpleXMLElement $xml, Request $request)
 {
     $this->appendCustomer($xml, $request->getCustomer());
     $this->appendPreApproval($xml, $request->getPreApproval());
     if ($reference = $request->getReference()) {
         $xml->addChild('reference', $reference);
     }
     if ($reviewOn = $request->getReviewOn()) {
         $xml->addChild('reviewURL', $reviewOn);
     }
     if ($redirectTo = $request->getRedirectTo()) {
         $xml->addChild('redirectURL', $redirectTo);
     }
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function setInitialDate(DateTime $initialDate)
 {
     $this->request->getPreApproval()->setInitialDate($initialDate);
     return $this;
 }
Exemplo n.º 4
0
 /**
  * @test
  */
 public function setCustomerToShouldChangeTheAttribute()
 {
     $customer = $this->getMock(Customer::class, [], [], '', false);
     $this->request->setCustomer($customer);
     $this->assertAttributeSame($customer, 'customer', $this->request);
 }