Skip to content

Commit

Permalink
Fix/psr 16 token persistence (#14)
Browse files Browse the repository at this point in the history
* Enforce strict PSR16 compliancy. Fixes #12.
  • Loading branch information
nreynis authored and eljam committed Jul 6, 2019
1 parent 07d1f70 commit c8ea177
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ cache:
- vendor

php:
- 5.5
- 5.6
- 7.0

Expand Down
21 changes: 19 additions & 2 deletions Tests/Persistence/TokenPersistenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
use Eljam\GuzzleJwt\JwtToken;
use Eljam\GuzzleJwt\Persistence\NullTokenPersistence;
use Eljam\GuzzleJwt\Persistence\SimpleCacheTokenPersistence;
use Symfony\Component\Cache\Simple\FilesystemCache;
use Kodus\Cache\MockCache;
use Psr\SimpleCache\CacheInterface;

/**
* @author Nicolas Reynis (nreynis)
Expand All @@ -26,12 +27,28 @@ public function testNullTokenPersistence()
$this->assertNull($tokenPersistence->restoreToken());
}

/**
* testSimpleCacheTokenPersistenceInterface.
* Makes sure we only use the interface methods.
*/
public function testSimpleCacheTokenPersistenceInterface()
{
$simpleCache = $this->getMock(CacheInterface::class);
$tokenPersistence = new SimpleCacheTokenPersistence($simpleCache);
$token = new JwtToken('foo', new \DateTime('now'));

$this->assertNull($tokenPersistence->saveToken($token));
$this->assertNull($tokenPersistence->hasToken());
$this->assertNull($tokenPersistence->restoreToken());
$this->assertNull($tokenPersistence->deleteToken());
}

/**
* testSimpleCacheTokenPersistence.
*/
public function testSimpleCacheTokenPersistence()
{
$simpleCache = new FilesystemCache();
$simpleCache = new MockCache();
$tokenPersistence = new SimpleCacheTokenPersistence($simpleCache);
$token = new JwtToken('foo', new \DateTime('now'));

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
"require-dev": {
"phpunit/phpunit": "4.5",
"satooshi/php-coveralls": "^0.6.1",
"symfony/cache": ">=3.3"
"kodus/mock-cache": "^1.0"
},
"require": {
"php" : ">=5.5.0",
"php" : ">=5.6.0",
"guzzlehttp/guzzle": "~6.0",
"psr/simple-cache": "^1.0",
"symfony/options-resolver": ">=2.8"
Expand Down
2 changes: 1 addition & 1 deletion src/Persistence/SimpleCacheTokenPersistence.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function restoreToken()
*/
public function deleteToken()
{
$this->cache->deleteItem($this->cacheKey);
$this->cache->delete($this->cacheKey);
return;
}

Expand Down

0 comments on commit c8ea177

Please sign in to comment.