-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a basic test for the validation client due to codecov
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace VonageTest\Client\Exception; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Vonage\Client\Exception\Exception; | ||
|
||
class Validation extends TestCase | ||
{ | ||
public function testValidationException() | ||
{ | ||
$message = 'Validation failed'; | ||
$code = 422; | ||
$previous = new Exception('Previous exception'); | ||
$errors = [ | ||
'field1' => 'Error message 1', | ||
'field2' => 'Error message 2' | ||
]; | ||
|
||
$exception = new Validation($message, $code, $previous, $errors); | ||
|
||
// Assert the exception message | ||
$this->assertEquals($message, $exception->getMessage()); | ||
|
||
// Assert the exception code | ||
$this->assertEquals($code, $exception->getCode()); | ||
|
||
// Assert the previous exception | ||
$this->assertSame($previous, $exception->getPrevious()); | ||
|
||
// Assert the validation errors | ||
$this->assertEquals($errors, $exception->getValidationErrors()); | ||
} | ||
} |