Skip to content

Commit

Permalink
AT-3577: update php version
Browse files Browse the repository at this point in the history
  • Loading branch information
halaz-lazlo committed Apr 1, 2022
1 parent b0ec8ad commit b369aa3
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,8 +20,8 @@ jobs:
tools: composer
- name: Install dependencies
run: |
composer update
composer update
composer style
composer install
- name: Test
run: composer test
run: composer test
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
11 changes: 8 additions & 3 deletions tests/CachedClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,36 @@

namespace Test\SessionValidator;

use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use SessionValidator\Cache\CacheInterface;
use SessionValidator\CachedClient;
use SessionValidator\ClientInterface;

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);
Expand Down
17 changes: 12 additions & 5 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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);

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -153,15 +159,16 @@ 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')
->with($method, $url, [
'headers' => ['Content-Type' => 'application/json'],
'body' => $body
])
->willReturn(new Response());
->willReturn($responseReturned);
}
}
10 changes: 7 additions & 3 deletions tests/Http/EscherClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b369aa3

Please sign in to comment.