Ejemplo n.º 1
0
 public function testGetUserValidationSuccess()
 {
     $request = new GetUser($this->config);
     $request->setUserID(1);
     $validation = new Validation();
     $validation->getValidator($request);
     $data = $validation->performValidation();
     $this->assertEmpty($data, "Validation found an issue when there should be none");
 }
Ejemplo n.º 2
0
 /**
  * Make an successful call
  * Create a transaction then do the reserve call
  */
 public function testSuccessfulApiCall()
 {
     if (is_null($this->config)) {
         $this->markTestSkipped('Config is not set, please set up the required environment variables');
         return false;
     }
     $userId = "REGISTED:" . hash('md5', microtime());
     $billingRecipient = $this->faker->name;
     $shippingRecipient = $this->faker->name;
     $registerRequest = new RegisterUserRequest($this->config);
     $registerRequest->setUserID($userId)->setUserType(\Upg\Library\User\Type::USER_TYPE_PRIVATE)->setUserRiskClass(RiskClass::RISK_CLASS_DEFAULT)->setUserData($this->getUser())->setBillingAddress($this->getAddress())->setBillingRecipient($billingRecipient)->setShippingAddress($this->getAddress())->setShippingRecipient($shippingRecipient)->setLocale(Codes::LOCALE_EN);
     $registerUserApi = new RegisterUserApi($this->config, $registerRequest);
     $registerUserApi->sendRequest();
     /**
      * ok now get the user
      */
     $getUserRequest = new GetUserRequest($this->config);
     $getUserRequest->setUserID($userId);
     $getUserApi = new GetUserApi($this->config, $getUserRequest);
     $result = $getUserApi->sendRequest();
     $this->assertEquals(0, $result->getData('resultCode'));
     $this->assertEmpty($result->getData('message'));
     $this->assertNotEmpty($result->getData('salt'));
     /**
      * @var Person $returnedPerson
      */
     $returnedPerson = $result->getData('userData');
     $this->assertEquals(\Upg\Library\Request\Objects\Person::SALUTATIONMALE, $returnedPerson->getSalutation());
     $this->assertEquals($this->getUser()->getName(), $returnedPerson->getName());
     $this->assertEquals($this->getUser()->getSurname(), $returnedPerson->getSurname());
     $this->assertEquals($this->getUser()->getDateOfBirth()->format('Y-m-d'), $returnedPerson->getDateOfBirth()->format('Y-m-d'));
     $this->assertEquals($this->getUser()->getEmail(), $returnedPerson->getEmail());
     $this->assertEquals($this->getUser()->getPhoneNumber(), $returnedPerson->getPhoneNumber());
     $this->assertEquals($billingRecipient, $result->getData('billingRecipient'));
     /**
      * billingAddress and shippingAddress should be converted to an address object
      */
     $this->assertEquals($this->getAddress()->getNo(), $result->getData('billingAddress')->getNo());
     $this->assertEquals($this->getAddress()->getStreet(), $result->getData('billingAddress')->getStreet());
     $this->assertEquals($this->getAddress()->getZip(), $result->getData('billingAddress')->getZip());
     $this->assertEquals($this->getAddress()->getCity(), $result->getData('billingAddress')->getCity());
     $this->assertEquals($this->getAddress()->getState(), $result->getData('billingAddress')->getState());
     $this->assertEquals($this->getAddress()->getCountry(), $result->getData('billingAddress')->getCountry());
     $this->assertEquals($this->getAddress()->getNo(), $result->getData('shippingAddress')->getNo());
     $this->assertEquals($this->getAddress()->getStreet(), $result->getData('shippingAddress')->getStreet());
     $this->assertEquals($this->getAddress()->getZip(), $result->getData('shippingAddress')->getZip());
     $this->assertEquals($this->getAddress()->getCity(), $result->getData('shippingAddress')->getCity());
     $this->assertEquals($this->getAddress()->getState(), $result->getData('shippingAddress')->getState());
     $this->assertEquals($this->getAddress()->getCountry(), $result->getData('shippingAddress')->getCountry());
 }