示例#1
0
 public function testCustomErrorMessages()
 {
     $validator = new Academe\SagePay\Validator\Server();
     $server = $this->getBasicServer();
     // Set the custom error message
     $customErrorMessage = "This is not a real error message";
     $validator->CANNOT_BE_EMPTY = $customErrorMessage;
     // Empty a field which should not be empty
     $server->setField('Vendor', '');
     // Call the errors, and check the error message matches
     $errors = $validator->validate($server)->getErrors();
     $this->assertEquals($errors['Vendor'], $customErrorMessage);
 }
示例#2
0
 public function testDescriptionLength()
 {
     $validator = new Academe\SagePay\Validator\Server();
     $server = $this->getBasicServer();
     $server->setField('Description', str_pad('', 101, '_'));
     $errors = $validator->validate($server)->getErrors();
     $this->assertArrayHasKey('Description', $errors);
     $correctError = sprintf($validator->BAD_RANGE, 'Description', $this->transactionData['Description']['min'], $this->transactionData['Description']['max']);
     $this->assertStringStartsWith($errors['Description'], $correctError);
     $server->setField('Description', str_pad('', 10, '_'));
     $errors = $validator->validate($server)->getErrors();
     $this->assertArrayNotHasKey('Description', $errors);
 }