Mise à jour des librairies vendor
This commit is contained in:
65
vendor/google/auth/tests/CacheTraitTest.php
vendored
65
vendor/google/auth/tests/CacheTraitTest.php
vendored
@@ -18,8 +18,9 @@
|
||||
namespace Google\Auth\Tests;
|
||||
|
||||
use Google\Auth\CacheTrait;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CacheTraitTest extends \PHPUnit_Framework_TestCase
|
||||
class CacheTraitTest extends TestCase
|
||||
{
|
||||
private $mockFetcher;
|
||||
private $mockCacheItem;
|
||||
@@ -44,6 +45,10 @@ class CacheTraitTest extends \PHPUnit_Framework_TestCase
|
||||
public function testSuccessfullyPullsFromCache()
|
||||
{
|
||||
$expectedValue = '1234';
|
||||
$this->mockCacheItem
|
||||
->expects($this->once())
|
||||
->method('isHit')
|
||||
->will($this->returnValue(true));
|
||||
$this->mockCacheItem
|
||||
->expects($this->once())
|
||||
->method('get')
|
||||
@@ -61,6 +66,64 @@ class CacheTraitTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($expectedValue, $cachedValue);
|
||||
}
|
||||
|
||||
public function testSuccessfullyPullsFromCacheWithInvalidKey()
|
||||
{
|
||||
$key = 'this-key-has-@-illegal-characters';
|
||||
$expectedKey = 'thiskeyhasillegalcharacters';
|
||||
$expectedValue = '1234';
|
||||
$this->mockCacheItem
|
||||
->expects($this->once())
|
||||
->method('isHit')
|
||||
->will($this->returnValue(true));
|
||||
$this->mockCacheItem
|
||||
->expects($this->once())
|
||||
->method('get')
|
||||
->will($this->returnValue($expectedValue));
|
||||
$this->mockCache
|
||||
->expects($this->once())
|
||||
->method('getItem')
|
||||
->with($expectedKey)
|
||||
->will($this->returnValue($this->mockCacheItem));
|
||||
|
||||
$implementation = new CacheTraitImplementation([
|
||||
'cache' => $this->mockCache,
|
||||
'key' => $key,
|
||||
]);
|
||||
|
||||
$cachedValue = $implementation->gCachedValue();
|
||||
$this->assertEquals($expectedValue, $cachedValue);
|
||||
}
|
||||
|
||||
public function testSuccessfullyPullsFromCacheWithLongKey()
|
||||
{
|
||||
$key = 'this-key-is-over-64-characters-and-it-will-still-work'
|
||||
. '-but-it-will-be-hashed-and-shortened';
|
||||
$expectedKey = str_replace('-', '', $key);
|
||||
$expectedKey = substr(hash('sha256', $expectedKey), 0, 64);
|
||||
$expectedValue = '1234';
|
||||
$this->mockCacheItem
|
||||
->expects($this->once())
|
||||
->method('isHit')
|
||||
->will($this->returnValue(true));
|
||||
$this->mockCacheItem
|
||||
->expects($this->once())
|
||||
->method('get')
|
||||
->will($this->returnValue($expectedValue));
|
||||
$this->mockCache
|
||||
->expects($this->once())
|
||||
->method('getItem')
|
||||
->with($expectedKey)
|
||||
->will($this->returnValue($this->mockCacheItem));
|
||||
|
||||
$implementation = new CacheTraitImplementation([
|
||||
'cache' => $this->mockCache,
|
||||
'key' => $key
|
||||
]);
|
||||
|
||||
$cachedValue = $implementation->gCachedValue();
|
||||
$this->assertEquals($expectedValue, $cachedValue);
|
||||
}
|
||||
|
||||
public function testFailsPullFromCacheWithNoCache()
|
||||
{
|
||||
$implementation = new CacheTraitImplementation();
|
||||
|
||||
Reference in New Issue
Block a user