diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 21dd30a..bb2016e 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['7.3', '7.4'] + php-versions: ['7.3', '7.4', '8.0'] steps: - name: Install prerequesits @@ -20,8 +20,8 @@ jobs: tools: composer - name: Install dependencies run: | - composer update + composer update composer style composer install - name: Test - run: composer test \ No newline at end of file + run: composer test diff --git a/composer.json b/composer.json index 0cdffd2..0cb4929 100644 --- a/composer.json +++ b/composer.json @@ -24,13 +24,13 @@ } }, "require": { - "php": ">=5.6", + "php": "^8.0", "emartech/escher": "1", "guzzlehttp/guzzle": "6", "psr/log": "1" }, "require-dev": { - "phpunit/phpunit": "^5.7", + "phpunit/phpunit": "^8.4", "squizlabs/php_codesniffer": "^3.3" }, "suggest": { diff --git a/tests/CachedClientTest.php b/tests/CachedClientTest.php index aa273f1..111d183 100644 --- a/tests/CachedClientTest.php +++ b/tests/CachedClientTest.php @@ -2,6 +2,7 @@ namespace Test\SessionValidator; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use SessionValidator\Cache\CacheInterface; use SessionValidator\CachedClient; @@ -9,24 +10,28 @@ class CachedClientTest extends TestCase { - /** @var ClientInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var ClientInterface|MockObject */ private $clientMock; - /** @var CacheInterface|\PHPUnit_Framework_MockObject_MockObject */ + + /** @var CacheInterface|MockObject */ private $cacheMock; /** @var string */ private $msid; + /** @var string */ private $value; + /** @var array */ private $msids; + /** @var array */ private $invalidMsids; /** @var CachedClient */ private $client; - protected function setUp() + protected function setUp(): void { $this->clientMock = $this->createMock(ClientInterface::class); $this->cacheMock = $this->createMock(CacheInterface::class); diff --git a/tests/ClientTest.php b/tests/ClientTest.php index 1933e44..b7d791a 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -4,13 +4,14 @@ use GuzzleHttp\Exception\TransferException; use GuzzleHttp\Psr7\Response; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use SessionValidator\Client; use SessionValidator\Http\EscherClient; class ClientTest extends TestCase { - /** @var EscherClient|\PHPUnit_Framework_MockObject_MockObject */ + /** @var EscherClient|MockObject */ private $escherClientMock; /** @var string */ @@ -19,7 +20,7 @@ class ClientTest extends TestCase /** @var Client */ private $client; - protected function setUp() + protected function setUp(): void { $this->escherClientMock = $this->createMock(EscherClient::class); @@ -89,7 +90,12 @@ public function filterInvalidCallsTheProperApiEndpoint() $msids = ['msid1', 'msid2']; $body = json_encode(['msids' => $msids]); - $this->expectHttpRequest('POST', "{$this->serviceUrl}/sessions/filter", $body); + $this->expectHttpRequest( + 'POST', + "{$this->serviceUrl}/sessions/filter", + $body, + new Response(200, [], json_encode(['msids' => ['msid1']])) + ); $this->client->filterInvalid($msids); } @@ -153,8 +159,9 @@ private function mockHttpClientException() ->willThrowException(new TransferException()); } - private function expectHttpRequest($method, $url, $body) + private function expectHttpRequest($method, $url, $body, $response = null) { + $responseReturned = $response ?? new Response(); $this->escherClientMock ->expects($this->once()) ->method('request') @@ -162,6 +169,6 @@ private function expectHttpRequest($method, $url, $body) 'headers' => ['Content-Type' => 'application/json'], 'body' => $body ]) - ->willReturn(new Response()); + ->willReturn($responseReturned); } } diff --git a/tests/Http/EscherClientTest.php b/tests/Http/EscherClientTest.php index e118816..b55db8b 100644 --- a/tests/Http/EscherClientTest.php +++ b/tests/Http/EscherClientTest.php @@ -4,27 +4,31 @@ use Escher\Escher; use GuzzleHttp\ClientInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use SessionValidator\Http\EscherClient; class EscherClientTest extends TestCase { - /** @var ClientInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var ClientInterface|MockObject */ private $clientMock; - /** @var Escher|\PHPUnit_Framework_MockObject_MockObject */ + + /** @var Escher|MockObject */ private $escherMock; /** @var string */ private $escherKey; + /** @var string */ private $escherSecret; + /** @var array */ private $requestOptions; /** @var EscherClient */ private $client; - protected function setUp() + protected function setUp(): void { $this->clientMock = $this->createMock(ClientInterface::class); $this->escherMock = $this->createMock(Escher::class);