/** * @see BuyerEntity::toArray() */ public function testToArray() { $address = array('street1' => 'street1_' . rand(1, 1000), 'street2' => 'street2_' . rand(1, 1000), 'city' => 'city_' . rand(1, 1000), 'state' => 'state_' . rand(1, 1000), 'country' => 'country_' . rand(1, 1000), 'postalCode' => 'postalCode_' . rand(1, 1000), 'phone' => 'phone_' . rand(1, 1000)); $shippingAddress = new ShippingAddressEntity(); $shippingAddress->setStreet1($address['street1'])->setStreet2($address['street2'])->setCity($address['city'])->setState($address['state'])->setCountry($address['country'])->setPostalCode($address['postalCode'])->setPhone($address['phone']); $this->object->setShippingAddress($shippingAddress); $buyer = array('fullName' => 'person name ' . rand(1, 9) . rand(1, 9) . rand(1, 9), 'emailAddress' => 'email' . rand(1, 9) . rand(1, 9) . rand(1, 9) . '@foo-bar.com', 'dniNumber' => Cpf::random(), 'shippingAddress' => $address); $this->object->setFullName($buyer['fullName'])->setEmailAddress($buyer['emailAddress'])->setDniNumber($buyer['dniNumber']); $rs = $this->object->toArray(); $this->assertSame($buyer, $rs); }
/** * @see OrderEntity::setBuyer() */ public function testSetBuyer() { $address = array('street1' => 'street1_' . rand(1, 1000), 'street2' => 'street2_' . rand(1, 1000), 'city' => 'city_' . rand(1, 1000), 'state' => 'state_' . rand(1, 1000), 'country' => 'country_' . rand(1, 1000), 'postalCode' => 'postalCode_' . rand(1, 1000), 'phone' => 'phone_' . rand(1, 1000)); $shippingAddress = new ShippingAddressEntity(); $shippingAddress->setStreet1($address['street1'])->setStreet2($address['street2'])->setCity($address['city'])->setState($address['state'])->setCountry($address['country'])->setPostalCode($address['postalCode'])->setPhone($address['phone']); $buyerEntity = new BuyerEntity(); $buyerEntity->setShippingAddress($shippingAddress); $buyer = array('fullName' => 'person name ' . rand(1, 9) . rand(1, 9) . rand(1, 9), 'emailAddress' => 'email' . rand(1, 9) . rand(1, 9) . rand(1, 9) . '@foo-bar.com', 'dniNumber' => Cpf::random(), 'shippingAddress' => $address); $buyerEntity->setFullName($buyer['fullName'])->setEmailAddress($buyer['emailAddress'])->setDniNumber($buyer['dniNumber']); $this->object->setBuyer($buyerEntity); $rs = $this->object->getBuyer(); $this->assertInstanceOf('\\PayU\\Entity\\Transaction\\Order\\BuyerEntity', $rs); $this->assertEquals($buyer['fullName'], $rs->getFullName()); $this->assertEquals($buyer['emailAddress'], $rs->getEmailAddress()); $this->assertEquals($buyer['dniNumber'], $rs->getDniNumber()); $shippingAddress = $rs->getShippingAddress(); $this->assertInstanceOf('\\PayU\\Entity\\Transaction\\ShippingAddressEntity', $shippingAddress); $this->assertEquals($shippingAddress->getStreet1(), $address['street1']); $this->assertEquals($shippingAddress->getStreet2(), $address['street2']); $this->assertEquals($shippingAddress->getCity(), $address['city']); $this->assertEquals($shippingAddress->getState(), $address['state']); $this->assertEquals($shippingAddress->getCountry(), $address['country']); $this->assertEquals($shippingAddress->getPostalCode(), $address['postalCode']); $this->assertEquals($shippingAddress->getPhone(), $address['phone']); }
/** * Generate array order. * @return array */ public function toArray() { $return = array('accountId' => $this->accountId, 'referenceCode' => $this->referenceCode, 'description' => $this->description, 'language' => $this->language, 'notifyUrl' => $this->notifyUrl, 'signature' => $this->signature, 'buyer' => $this->buyer->toArray(), 'additionalValues' => $this->additionalValues->toArray()); if (!$this->getShippingAddress()->isEmpty()) { $return = array_merge($return, array('shippingAddress' => $this->shippingAddress->toArray())); } return $return; }