Exemplo n.º 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();
     $registerRequest->setUserRiskClass(RiskClass::RISK_CLASS_TRUSTED);
     $updateUserApi = new UpdateUserApi($this->config, $registerRequest);
     $result = $updateUserApi->sendRequest();
     $this->assertEquals(0, $result->getData('resultCode'));
     $this->assertEmpty($result->getData('message'));
     $this->assertNotEmpty($result->getData('salt'));
 }
Exemplo n.º 2
0
 public function testRegisterUserValidationShippingRecipient()
 {
     $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->veryLongString)->setShippingAddress($this->getAddress())->setLocale(Codes::LOCALE_EN);
     $validation = new Validation();
     /**
      * Test length validation
      */
     $request->setUserRiskClass($this->veryLongString);
     $validation->getValidator($request);
     $data = $validation->performValidation();
     $this->assertValidationReturned('Upg\\Library\\Request\\RegisterUser', 'shippingRecipient', 'shippingRecipient must be between 1 and 80 characters', $data, "shippingRecipient must be between 1 and 80 characters failed");
 }