Skip to content

Commit

Permalink
Add PHP-8.1 and 8.2 test in GitHub action
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k committed Sep 5, 2023
1 parent 37fcde0 commit fb2100f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 21 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['7.2', '7.3', '7.4', '8.0']
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}

steps:
Expand All @@ -34,14 +34,9 @@ jobs:
- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies for PHP 7
if: matrix.php-versions < '8.0'
- name: Install dependencies for PHP
run: composer update --prefer-dist --no-progress

- name: Install dependencies for PHP 8
if: matrix.php-versions >= '8.0'
run: composer update --prefer-dist --no-progress --ignore-platform-reqs

- name: Run test suite
run: composer check
env:
Expand Down
4 changes: 1 addition & 3 deletions src/Encoder/EncoderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Selective\Validation\Encoder;

use UnexpectedValueException;

/**
* Encoder interface.
*/
Expand All @@ -14,7 +12,7 @@ interface EncoderInterface
*
* @param mixed $data The data
*
* @throws UnexpectedValueException
* @throws \UnexpectedValueException
*
* @return string The encoded string
*/
Expand Down
6 changes: 2 additions & 4 deletions src/Encoder/JsonEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Selective\Validation\Encoder;

use UnexpectedValueException;

/**
* Encoder interface.
*/
Expand All @@ -14,7 +12,7 @@ final class JsonEncoder implements EncoderInterface
*
* @param mixed $data The data
*
* @throws UnexpectedValueException
* @throws \UnexpectedValueException
*
* @return string The encoded string
*/
Expand All @@ -23,7 +21,7 @@ public function encode($data): string
$result = json_encode($data);

if ($result === false) {
throw new UnexpectedValueException(
throw new \UnexpectedValueException(
sprintf('JSON encoding failed. Code: %s. Error: %s.', json_last_error(), json_last_error_msg())
);
}
Expand Down
7 changes: 3 additions & 4 deletions src/Exception/ValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

namespace Selective\Validation\Exception;

use DomainException;
use Selective\Validation\ValidationResult;
use Throwable;

/**
* Validation Exception.
*/
final class ValidationException extends DomainException
final class ValidationException extends \DomainException
{
/**
* @var ValidationResult|null
Expand All @@ -22,13 +21,13 @@ final class ValidationException extends DomainException
* @param string $message The Exception message to throw
* @param ValidationResult|null $validationResult The validation result object
* @param int $code The Exception code
* @param Throwable|null $previous The previous throwable used for the exception chaining
* @param \Throwable|null $previous The previous throwable used for the exception chaining
*/
public function __construct(
string $message,
ValidationResult $validationResult = null,
int $code = 422,
Throwable $previous = null
\Throwable $previous = null
) {
parent::__construct($message, $code, $previous);

Expand Down
3 changes: 1 addition & 2 deletions tests/Encoder/JsonEncoderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use PHPUnit\Framework\TestCase;
use Selective\Validation\Encoder\JsonEncoder;
use UnexpectedValueException;

/**
* Tests.
Expand All @@ -31,7 +30,7 @@ public function testEncode(): void
*/
public function testInvalidEncoding(): void
{
$this->expectException(UnexpectedValueException::class);
$this->expectException(\UnexpectedValueException::class);
$this->expectExceptionMessage('JSON encoding failed. Code: 5. Error: Malformed UTF-8 characters,' .
' possibly incorrectly encoded.');

Expand Down
2 changes: 1 addition & 1 deletion tests/Exception/ValidationExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function testSuccessAction(): void
$service = new TestService();
$result = $service->process(1);

$this->assertSame('{"success":true}', (json_encode($result)));
$this->assertSame('{"success":true}', json_encode($result));
}

/**
Expand Down

0 comments on commit fb2100f

Please sign in to comment.