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);
 }
Ejemplo n.º 2
0
 public function testSettersAndGettersAttributes()
 {
     $preApproval = new PreApproval();
     $preApproval->setName('Name Assinatura');
     $preApproval->setChargeType('auto');
     $preApproval->setDetails('Cobranca Mensal');
     $preApproval->setPeriod('MONTHLY');
     $preApproval->setFinalDate(new DateTime('2016-11-18'));
     $preApproval->setMaxTotalAmount(3000);
     $preApproval->setAmountPerPayment(100);
     $preApproval->setMaxAmountPerPayment(150);
     $preApproval->setMaxPaymentsPerPeriod(12);
     $preApproval->setMaxAmountPerPeriod(1200);
     $preApproval->setInitialDate(new DateTime('2015-11-18'));
     $this->assertAttributeEquals('Name Assinatura', 'name', $preApproval);
     $this->assertAttributeEquals('auto', 'chargeType', $preApproval);
     $this->assertAttributeEquals('Cobranca Mensal', 'details', $preApproval);
     $this->assertAttributeEquals('MONTHLY', 'period', $preApproval);
     $this->assertAttributeEquals(new DateTime('2016-11-18'), 'finalDate', $preApproval);
     $this->assertAttributeEquals(3000, 'maxTotalAmount', $preApproval);
     $this->assertAttributeEquals(100, 'amountPerPayment', $preApproval);
     $this->assertAttributeEquals(150, 'maxAmountPerPayment', $preApproval);
     $this->assertAttributeEquals(12, 'maxPaymentsPerPeriod', $preApproval);
     $this->assertAttributeEquals(1200, 'maxAmountPerPeriod', $preApproval);
     $this->assertAttributeEquals(new DateTime('2015-11-18'), 'initialDate', $preApproval);
     $this->assertEquals('Name Assinatura', $preApproval->getName());
     $this->assertEquals('auto', $preApproval->getChargeType());
     $this->assertEquals('Cobranca Mensal', $preApproval->getDetails());
     $this->assertEquals('MONTHLY', $preApproval->getPeriod());
     $this->assertEquals(new DateTime('2016-11-18'), $preApproval->getFinalDate());
     $this->assertEquals(3000, $preApproval->getMaxTotalAmount());
     $this->assertEquals(100, $preApproval->getAmountPerPayment());
     $this->assertEquals(150, $preApproval->getMaxAmountPerPayment());
     $this->assertEquals(12, $preApproval->getMaxPaymentsPerPeriod());
     $this->assertEquals(1200, $preApproval->getMaxAmountPerPeriod());
     $this->assertEquals(new DateTime('2015-11-18'), $preApproval->getInitialDate());
 }