Skip to content

Commit

Permalink
Replace cache/void-adapter with NullCacheItemPool
Browse files Browse the repository at this point in the history
  • Loading branch information
Art4 committed Feb 24, 2023
1 parent bfd7225 commit 9da75ce
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"require": {
"php": "^8.0",
"art4/json-api-client": "^1.0",
"cache/void-adapter": "^1.1",
"guzzlehttp/guzzle": "^7.2",
"psr/cache": "^2.0 || ^3.0",
"psr/http-client": "^1.0",
Expand Down
13 changes: 2 additions & 11 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

use Art4\JsonApiClient\Accessable;
use Art4\JsonApiClient\Helper\Parser as JsonApiParser;
use Cache\Adapter\Void\VoidCachePool;
use DateInterval;
use DateTimeImmutable;
use Exception;
Expand All @@ -43,6 +42,7 @@
use Throwable;
use Youthweb\Api\Authentication\Authenticator;
use Youthweb\Api\Authentication\NativeAuthenticator;
use Youthweb\Api\Cache\NullCacheItemPool;
use Youthweb\Api\Exception\ErrorResponseException;
use Youthweb\Api\Exception\UnauthorizedException;
use Youthweb\Api\Resource\ResourceInterface;
Expand Down Expand Up @@ -198,7 +198,7 @@ public function __construct(array $options = [], array $collaborators = [])
$this->oauth2Provider = $collaborators['oauth2_provider'];

if (empty($collaborators['cache_provider'])) {
$collaborators['cache_provider'] = new VoidCachePool();
$collaborators['cache_provider'] = new NullCacheItemPool();
}

$this->cacheProvider = $collaborators['cache_provider'];
Expand Down Expand Up @@ -417,15 +417,6 @@ public function postUnauthorized(string $path, array $data = []): Accessable
return $this->runRequest($request);
}

/**
* destructor
**/
public function __destruct()
{
// Save deferred items
$this->cacheProvider->commit();
}

/**
* Returns the Url
*
Expand Down
5 changes: 3 additions & 2 deletions tests/Integration/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@
namespace Youthweb\Api\Tests\Integration;

use Youthweb\Api\Client;
use Youthweb\Api\ClientInterface;

class ClientTest extends \PHPUnit\Framework\TestCase
{
/**
* @test
*/
public function testCreateClientWithoutParameters(): void
public function testClientImplementsClientInterface(): void
{
$client = new Client();

$this->assertInstanceOf('Youthweb\Api\ClientInterface', $client);
$this->assertInstanceOf(ClientInterface::class, $client);
}
}

0 comments on commit 9da75ce

Please sign in to comment.