Example #1
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());
 }
 /**
  * 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());
     $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($this->faker->name)->setShippingAddress($this->getAddress())->setShippingRecipient($this->faker->name)->setLocale(Codes::LOCALE_EN);
     $registerUserApi = new RegisterUserApi($this->config, $registerRequest);
     $result = $registerUserApi->sendRequest();
     $this->assertEquals(0, $result->getData('resultCode'));
     $this->assertEmpty($result->getData('message'));
     $this->assertNotEmpty($result->getData('salt'));
 }
 public function testRegisterUserValidationLocale()
 {
     $request = new RegisterUser($this->config);
     $request->setUserId(11)->setUserType(\Upg\Library\User\Type::USER_TYPE_PRIVATE)->setUserRiskClass(RiskClass::RISK_CLASS_DEFAULT)->setUserData($this->getUser())->setBillingRecipient($this->faker->name)->setBillingAddress($this->getAddress())->setShippingRecipient($this->faker->name)->setShippingAddress($this->getAddress());
     /**
      * Test required
      */
     $validation = new Validation();
     $validation->getValidator($request);
     $data = $validation->performValidation();
     $this->assertValidationReturned('Upg\\Library\\Request\\RegisterUser', 'locale', 'locale must be set for the request', $data, "locale must be set for the request failed");
     /**
      * Test values validation
      */
     $request->setLocale($this->faker->name);
     $validation = new Validation();
     $validation->getValidator($request);
     $data = $validation->performValidation();
     $this->assertValidationReturned('Upg\\Library\\Request\\RegisterUser', 'locale', 'locale must be certain values', $data, "locale must be certain values failed");
 }