初始化代码
This commit is contained in:
104
vendor/league/flysystem-cached-adapter/tests/AdapterCacheTests.php
vendored
Normal file
104
vendor/league/flysystem-cached-adapter/tests/AdapterCacheTests.php
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
use League\Flysystem\Cached\Storage\Adapter;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class AdapterCacheTests extends TestCase
|
||||
{
|
||||
public function testLoadFail()
|
||||
{
|
||||
$adapter = Mockery::mock('League\Flysystem\AdapterInterface');
|
||||
$adapter->shouldReceive('has')->once()->with('file.json')->andReturn(false);
|
||||
$cache = new Adapter($adapter, 'file.json', 10);
|
||||
$cache->load();
|
||||
$this->assertFalse($cache->isComplete('', false));
|
||||
}
|
||||
|
||||
public function testLoadExpired()
|
||||
{
|
||||
$response = ['contents' => json_encode([[], ['' => true], 1234567890]), 'path' => 'file.json'];
|
||||
$adapter = Mockery::mock('League\Flysystem\AdapterInterface');
|
||||
$adapter->shouldReceive('has')->once()->with('file.json')->andReturn(true);
|
||||
$adapter->shouldReceive('read')->once()->with('file.json')->andReturn($response);
|
||||
$adapter->shouldReceive('delete')->once()->with('file.json');
|
||||
$cache = new Adapter($adapter, 'file.json', 10);
|
||||
$cache->load();
|
||||
$this->assertFalse($cache->isComplete('', false));
|
||||
}
|
||||
|
||||
public function testLoadSuccess()
|
||||
{
|
||||
$response = ['contents' => json_encode([[], ['' => true], 9876543210]), 'path' => 'file.json'];
|
||||
$adapter = Mockery::mock('League\Flysystem\AdapterInterface');
|
||||
$adapter->shouldReceive('has')->once()->with('file.json')->andReturn(true);
|
||||
$adapter->shouldReceive('read')->once()->with('file.json')->andReturn($response);
|
||||
$cache = new Adapter($adapter, 'file.json', 10);
|
||||
$cache->load();
|
||||
$this->assertTrue($cache->isComplete('', false));
|
||||
}
|
||||
|
||||
public function testSaveExists()
|
||||
{
|
||||
$response = json_encode([[], [], null]);
|
||||
$adapter = Mockery::mock('League\Flysystem\AdapterInterface');
|
||||
$adapter->shouldReceive('has')->once()->with('file.json')->andReturn(true);
|
||||
$adapter->shouldReceive('update')->once()->with('file.json', $response, Mockery::any());
|
||||
$cache = new Adapter($adapter, 'file.json', null);
|
||||
$cache->save();
|
||||
}
|
||||
|
||||
public function testSaveNew()
|
||||
{
|
||||
$response = json_encode([[], [], null]);
|
||||
$adapter = Mockery::mock('League\Flysystem\AdapterInterface');
|
||||
$adapter->shouldReceive('has')->once()->with('file.json')->andReturn(false);
|
||||
$adapter->shouldReceive('write')->once()->with('file.json', $response, Mockery::any());
|
||||
$cache = new Adapter($adapter, 'file.json', null);
|
||||
$cache->save();
|
||||
}
|
||||
|
||||
public function testStoreContentsRecursive()
|
||||
{
|
||||
$adapter = Mockery::mock('League\Flysystem\AdapterInterface');
|
||||
$adapter->shouldReceive('has')->once()->with('file.json')->andReturn(false);
|
||||
$adapter->shouldReceive('write')->once()->with('file.json', Mockery::any(), Mockery::any());
|
||||
|
||||
$cache = new Adapter($adapter, 'file.json', null);
|
||||
|
||||
$contents = [
|
||||
['path' => 'foo/bar', 'dirname' => 'foo'],
|
||||
['path' => 'afoo/bang', 'dirname' => 'afoo'],
|
||||
];
|
||||
|
||||
$cache->storeContents('foo', $contents, true);
|
||||
|
||||
$this->assertTrue($cache->isComplete('foo', true));
|
||||
$this->assertFalse($cache->isComplete('afoo', true));
|
||||
}
|
||||
|
||||
public function testDeleteDir()
|
||||
{
|
||||
$cache_data = [
|
||||
'foo' => ['path' => 'foo', 'type' => 'dir', 'dirname' => ''],
|
||||
'foo/bar' => ['path' => 'foo/bar', 'type' => 'file', 'dirname' => 'foo'],
|
||||
'foobaz' => ['path' => 'foobaz', 'type' => 'file', 'dirname' => ''],
|
||||
];
|
||||
|
||||
$response = [
|
||||
'contents' => json_encode([$cache_data, [], null]),
|
||||
'path' => 'file.json',
|
||||
];
|
||||
|
||||
$adapter = Mockery::mock('League\Flysystem\AdapterInterface');
|
||||
$adapter->shouldReceive('has')->zeroOrMoreTimes()->with('file.json')->andReturn(true);
|
||||
$adapter->shouldReceive('read')->once()->with('file.json')->andReturn($response);
|
||||
$adapter->shouldReceive('update')->once()->with('file.json', Mockery::any(), Mockery::any())->andReturn(true);
|
||||
|
||||
$cache = new Adapter($adapter, 'file.json', null);
|
||||
$cache->load();
|
||||
|
||||
$cache->deleteDir('foo', true);
|
||||
|
||||
$this->assertSame(1, count($cache->listContents('', true)));
|
||||
}
|
||||
}
|
||||
16
vendor/league/flysystem-cached-adapter/tests/InspectionTests.php
vendored
Normal file
16
vendor/league/flysystem-cached-adapter/tests/InspectionTests.php
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
use League\Flysystem\Cached\CachedAdapter;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class InspectionTests extends TestCase {
|
||||
|
||||
public function testGetAdapter()
|
||||
{
|
||||
$adapter = Mockery::mock('League\Flysystem\AdapterInterface');
|
||||
$cache = Mockery::mock('League\Flysystem\Cached\CacheInterface');
|
||||
$cache->shouldReceive('load')->once();
|
||||
$cached_adapter = new CachedAdapter($adapter, $cache);
|
||||
$this->assertInstanceOf('League\Flysystem\AdapterInterface', $cached_adapter->getAdapter());
|
||||
}
|
||||
}
|
||||
35
vendor/league/flysystem-cached-adapter/tests/MemcachedTests.php
vendored
Normal file
35
vendor/league/flysystem-cached-adapter/tests/MemcachedTests.php
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use League\Flysystem\Cached\Storage\Memcached;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class MemcachedTests extends TestCase
|
||||
{
|
||||
public function testLoadFail()
|
||||
{
|
||||
$client = Mockery::mock('Memcached');
|
||||
$client->shouldReceive('get')->once()->andReturn(false);
|
||||
$cache = new Memcached($client);
|
||||
$cache->load();
|
||||
$this->assertFalse($cache->isComplete('', false));
|
||||
}
|
||||
|
||||
public function testLoadSuccess()
|
||||
{
|
||||
$response = json_encode([[], ['' => true]]);
|
||||
$client = Mockery::mock('Memcached');
|
||||
$client->shouldReceive('get')->once()->andReturn($response);
|
||||
$cache = new Memcached($client);
|
||||
$cache->load();
|
||||
$this->assertTrue($cache->isComplete('', false));
|
||||
}
|
||||
|
||||
public function testSave()
|
||||
{
|
||||
$response = json_encode([[], []]);
|
||||
$client = Mockery::mock('Memcached');
|
||||
$client->shouldReceive('set')->once()->andReturn($response);
|
||||
$cache = new Memcached($client);
|
||||
$cache->save();
|
||||
}
|
||||
}
|
||||
255
vendor/league/flysystem-cached-adapter/tests/MemoryCacheTests.php
vendored
Normal file
255
vendor/league/flysystem-cached-adapter/tests/MemoryCacheTests.php
vendored
Normal file
@@ -0,0 +1,255 @@
|
||||
<?php
|
||||
|
||||
use League\Flysystem\Cached\Storage\Memory;
|
||||
use League\Flysystem\Util;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class MemoryCacheTests extends TestCase
|
||||
{
|
||||
public function testAutosave()
|
||||
{
|
||||
$cache = new Memory();
|
||||
$cache->setAutosave(true);
|
||||
$this->assertTrue($cache->getAutosave());
|
||||
$cache->setAutosave(false);
|
||||
$this->assertFalse($cache->getAutosave());
|
||||
}
|
||||
|
||||
public function testCacheMiss()
|
||||
{
|
||||
$cache = new Memory();
|
||||
$cache->storeMiss('path.txt');
|
||||
$this->assertFalse($cache->has('path.txt'));
|
||||
}
|
||||
|
||||
public function testIsComplete()
|
||||
{
|
||||
$cache = new Memory();
|
||||
$this->assertFalse($cache->isComplete('dirname', false));
|
||||
$cache->setComplete('dirname', false);
|
||||
$this->assertFalse($cache->isComplete('dirname', true));
|
||||
$cache->setComplete('dirname', true);
|
||||
$this->assertTrue($cache->isComplete('dirname', true));
|
||||
}
|
||||
|
||||
public function testCleanContents()
|
||||
{
|
||||
$cache = new Memory();
|
||||
$input = [[
|
||||
'path' => 'path.txt',
|
||||
'visibility' => 'public',
|
||||
'invalid' => 'thing',
|
||||
]];
|
||||
|
||||
$expected = [[
|
||||
'path' => 'path.txt',
|
||||
'visibility' => 'public',
|
||||
]];
|
||||
|
||||
$output = $cache->cleanContents($input);
|
||||
$this->assertEquals($expected, $output);
|
||||
}
|
||||
|
||||
public function testGetForStorage()
|
||||
{
|
||||
$cache = new Memory();
|
||||
$input = [[
|
||||
'path' => 'path.txt',
|
||||
'visibility' => 'public',
|
||||
'type' => 'file',
|
||||
]];
|
||||
|
||||
$cache->storeContents('', $input, true);
|
||||
$contents = $cache->listContents('', true);
|
||||
$cached = [];
|
||||
foreach ($contents as $item) {
|
||||
$cached[$item['path']] = $item;
|
||||
}
|
||||
|
||||
$this->assertEquals(json_encode([$cached, ['' => 'recursive']]), $cache->getForStorage());
|
||||
}
|
||||
|
||||
public function testParentCompleteIsUsedDuringHas()
|
||||
{
|
||||
$cache = new Memory();
|
||||
$cache->setComplete('dirname', false);
|
||||
$this->assertFalse($cache->has('dirname/path.txt'));
|
||||
}
|
||||
|
||||
public function testFlush()
|
||||
{
|
||||
$cache = new Memory();
|
||||
$cache->setComplete('dirname', true);
|
||||
$cache->updateObject('path.txt', [
|
||||
'path' => 'path.txt',
|
||||
'visibility' => 'public',
|
||||
]);
|
||||
$cache->flush();
|
||||
$this->assertFalse($cache->isComplete('dirname', true));
|
||||
$this->assertNull($cache->has('path.txt'));
|
||||
}
|
||||
|
||||
public function testSetFromStorage()
|
||||
{
|
||||
$cache = new Memory();
|
||||
$json = [[
|
||||
'path.txt' => ['path' => 'path.txt', 'type' => 'file'],
|
||||
], ['dirname' => 'recursive']];
|
||||
$jsonString = json_encode($json);
|
||||
$cache->setFromStorage($jsonString);
|
||||
$this->assertTrue($cache->has('path.txt'));
|
||||
$this->assertTrue($cache->isComplete('dirname', true));
|
||||
}
|
||||
|
||||
public function testGetMetadataFail()
|
||||
{
|
||||
$cache = new Memory();
|
||||
$this->assertFalse($cache->getMetadata('path.txt'));
|
||||
}
|
||||
|
||||
public function metaGetterProvider()
|
||||
{
|
||||
return [
|
||||
['getTimestamp', 'timestamp', 12344],
|
||||
['getMimetype', 'mimetype', 'text/plain'],
|
||||
['getSize', 'size', 12],
|
||||
['getVisibility', 'visibility', 'private'],
|
||||
['read', 'contents', '__contents__'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider metaGetterProvider
|
||||
*
|
||||
* @param $method
|
||||
* @param $key
|
||||
* @param $value
|
||||
*/
|
||||
public function testMetaGetters($method, $key, $value)
|
||||
{
|
||||
$cache = new Memory();
|
||||
$this->assertFalse($cache->{$method}('path.txt'));
|
||||
$cache->updateObject('path.txt', $object = [
|
||||
'path' => 'path.txt',
|
||||
'type' => 'file',
|
||||
$key => $value,
|
||||
] + Util::pathinfo('path.txt'), true);
|
||||
$this->assertEquals($object, $cache->{$method}('path.txt'));
|
||||
$this->assertEquals($object, $cache->getMetadata('path.txt'));
|
||||
}
|
||||
|
||||
public function testGetDerivedMimetype()
|
||||
{
|
||||
$cache = new Memory();
|
||||
$cache->updateObject('path.txt', [
|
||||
'contents' => 'something',
|
||||
]);
|
||||
$response = $cache->getMimetype('path.txt');
|
||||
$this->assertEquals('text/plain', $response['mimetype']);
|
||||
}
|
||||
|
||||
public function testCopyFail()
|
||||
{
|
||||
$cache = new Memory();
|
||||
$cache->copy('one', 'two');
|
||||
$this->assertNull($cache->has('two'));
|
||||
$this->assertNull($cache->load());
|
||||
}
|
||||
|
||||
public function testStoreContents()
|
||||
{
|
||||
$cache = new Memory();
|
||||
$cache->storeContents('dirname', [
|
||||
['path' => 'dirname', 'type' => 'dir'],
|
||||
['path' => 'dirname/nested', 'type' => 'dir'],
|
||||
['path' => 'dirname/nested/deep', 'type' => 'dir'],
|
||||
['path' => 'other/nested/deep', 'type' => 'dir'],
|
||||
], true);
|
||||
|
||||
$this->isTrue($cache->isComplete('other/nested', true));
|
||||
}
|
||||
|
||||
public function testDelete()
|
||||
{
|
||||
$cache = new Memory();
|
||||
$cache->updateObject('path.txt', ['type' => 'file']);
|
||||
$this->assertTrue($cache->has('path.txt'));
|
||||
$cache->delete('path.txt');
|
||||
$this->assertFalse($cache->has('path.txt'));
|
||||
}
|
||||
|
||||
public function testDeleteDir()
|
||||
{
|
||||
$cache = new Memory();
|
||||
$cache->storeContents('dirname', [
|
||||
['path' => 'dirname/path.txt', 'type' => 'file'],
|
||||
]);
|
||||
$this->assertTrue($cache->isComplete('dirname', false));
|
||||
$this->assertTrue($cache->has('dirname/path.txt'));
|
||||
$cache->deleteDir('dirname');
|
||||
$this->assertFalse($cache->isComplete('dirname', false));
|
||||
$this->assertNull($cache->has('dirname/path.txt'));
|
||||
}
|
||||
|
||||
public function testReadStream()
|
||||
{
|
||||
$cache = new Memory();
|
||||
$this->assertFalse($cache->readStream('path.txt'));
|
||||
}
|
||||
|
||||
public function testRename()
|
||||
{
|
||||
$cache = new Memory();
|
||||
$cache->updateObject('path.txt', ['type' => 'file']);
|
||||
$cache->rename('path.txt', 'newpath.txt');
|
||||
$this->assertTrue($cache->has('newpath.txt'));
|
||||
}
|
||||
|
||||
public function testCopy()
|
||||
{
|
||||
$cache = new Memory();
|
||||
$cache->updateObject('path.txt', ['type' => 'file']);
|
||||
$cache->copy('path.txt', 'newpath.txt');
|
||||
$this->assertTrue($cache->has('newpath.txt'));
|
||||
}
|
||||
|
||||
public function testComplextListContents()
|
||||
{
|
||||
$cache = new Memory();
|
||||
$cache->storeContents('', [
|
||||
['path' => 'dirname', 'type' => 'dir'],
|
||||
['path' => 'dirname/file.txt', 'type' => 'file'],
|
||||
['path' => 'other', 'type' => 'dir'],
|
||||
['path' => 'other/file.txt', 'type' => 'file'],
|
||||
['path' => 'other/nested/file.txt', 'type' => 'file'],
|
||||
]);
|
||||
|
||||
$this->assertCount(3, $cache->listContents('other', true));
|
||||
}
|
||||
|
||||
public function testComplextListContentsWithDeletedFile()
|
||||
{
|
||||
$cache = new Memory();
|
||||
$cache->storeContents('', [
|
||||
['path' => 'dirname', 'type' => 'dir'],
|
||||
['path' => 'dirname/file.txt', 'type' => 'file'],
|
||||
['path' => 'other', 'type' => 'dir'],
|
||||
['path' => 'other/file.txt', 'type' => 'file'],
|
||||
['path' => 'other/another_file.txt', 'type' => 'file'],
|
||||
]);
|
||||
|
||||
$cache->delete('other/another_file.txt');
|
||||
$this->assertCount(4, $cache->listContents('', true));
|
||||
}
|
||||
|
||||
public function testCacheMissIfContentsIsFalse()
|
||||
{
|
||||
$cache = new Memory();
|
||||
$cache->updateObject('path.txt', [
|
||||
'path' => 'path.txt',
|
||||
'contents' => false,
|
||||
], true);
|
||||
|
||||
$this->assertFalse($cache->read('path.txt'));
|
||||
}
|
||||
}
|
||||
35
vendor/league/flysystem-cached-adapter/tests/NoopCacheTests.php
vendored
Normal file
35
vendor/league/flysystem-cached-adapter/tests/NoopCacheTests.php
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use League\Flysystem\Cached\Storage\Noop;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class NoopCacheTests extends TestCase
|
||||
{
|
||||
public function testNoop()
|
||||
{
|
||||
$cache = new Noop();
|
||||
$this->assertEquals($cache, $cache->storeMiss('file.txt'));
|
||||
$this->assertNull($cache->setComplete('', false));
|
||||
$this->assertNull($cache->load());
|
||||
$this->assertNull($cache->flush());
|
||||
$this->assertNull($cache->has('path.txt'));
|
||||
$this->assertNull($cache->autosave());
|
||||
$this->assertFalse($cache->isComplete('', false));
|
||||
$this->assertFalse($cache->read('something'));
|
||||
$this->assertFalse($cache->readStream('something'));
|
||||
$this->assertFalse($cache->getMetadata('something'));
|
||||
$this->assertFalse($cache->getMimetype('something'));
|
||||
$this->assertFalse($cache->getSize('something'));
|
||||
$this->assertFalse($cache->getTimestamp('something'));
|
||||
$this->assertFalse($cache->getVisibility('something'));
|
||||
$this->assertEmpty($cache->listContents('', false));
|
||||
$this->assertFalse($cache->rename('', ''));
|
||||
$this->assertFalse($cache->copy('', ''));
|
||||
$this->assertNull($cache->save());
|
||||
$object = ['path' => 'path.ext'];
|
||||
$this->assertEquals($object, $cache->updateObject('path.txt', $object));
|
||||
$this->assertEquals([['path' => 'some/file.txt']], $cache->storeContents('unknwon', [
|
||||
['path' => 'some/file.txt'],
|
||||
], false));
|
||||
}
|
||||
}
|
||||
45
vendor/league/flysystem-cached-adapter/tests/PhpRedisTests.php
vendored
Normal file
45
vendor/league/flysystem-cached-adapter/tests/PhpRedisTests.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use League\Flysystem\Cached\Storage\PhpRedis;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PhpRedisTests extends TestCase
|
||||
{
|
||||
public function testLoadFail()
|
||||
{
|
||||
$client = Mockery::mock('Redis');
|
||||
$client->shouldReceive('get')->with('flysystem')->once()->andReturn(false);
|
||||
$cache = new PhpRedis($client);
|
||||
$cache->load();
|
||||
$this->assertFalse($cache->isComplete('', false));
|
||||
}
|
||||
|
||||
public function testLoadSuccess()
|
||||
{
|
||||
$response = json_encode([[], ['' => true]]);
|
||||
$client = Mockery::mock('Redis');
|
||||
$client->shouldReceive('get')->with('flysystem')->once()->andReturn($response);
|
||||
$cache = new PhpRedis($client);
|
||||
$cache->load();
|
||||
$this->assertTrue($cache->isComplete('', false));
|
||||
}
|
||||
|
||||
public function testSave()
|
||||
{
|
||||
$data = json_encode([[], []]);
|
||||
$client = Mockery::mock('Redis');
|
||||
$client->shouldReceive('set')->with('flysystem', $data)->once();
|
||||
$cache = new PhpRedis($client);
|
||||
$cache->save();
|
||||
}
|
||||
|
||||
public function testSaveWithExpire()
|
||||
{
|
||||
$data = json_encode([[], []]);
|
||||
$client = Mockery::mock('Redis');
|
||||
$client->shouldReceive('set')->with('flysystem', $data)->once();
|
||||
$client->shouldReceive('expire')->with('flysystem', 20)->once();
|
||||
$cache = new PhpRedis($client, 'flysystem', 20);
|
||||
$cache->save();
|
||||
}
|
||||
}
|
||||
55
vendor/league/flysystem-cached-adapter/tests/PredisTests.php
vendored
Normal file
55
vendor/league/flysystem-cached-adapter/tests/PredisTests.php
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
use League\Flysystem\Cached\Storage\Predis;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PredisTests extends TestCase
|
||||
{
|
||||
public function testLoadFail()
|
||||
{
|
||||
$client = Mockery::mock('Predis\Client');
|
||||
$command = Mockery::mock('Predis\Command\CommandInterface');
|
||||
$client->shouldReceive('createCommand')->with('get', ['flysystem'])->once()->andReturn($command);
|
||||
$client->shouldReceive('executeCommand')->with($command)->andReturn(null);
|
||||
$cache = new Predis($client);
|
||||
$cache->load();
|
||||
$this->assertFalse($cache->isComplete('', false));
|
||||
}
|
||||
|
||||
public function testLoadSuccess()
|
||||
{
|
||||
$response = json_encode([[], ['' => true]]);
|
||||
$client = Mockery::mock('Predis\Client');
|
||||
$command = Mockery::mock('Predis\Command\CommandInterface');
|
||||
$client->shouldReceive('createCommand')->with('get', ['flysystem'])->once()->andReturn($command);
|
||||
$client->shouldReceive('executeCommand')->with($command)->andReturn($response);
|
||||
$cache = new Predis($client);
|
||||
$cache->load();
|
||||
$this->assertTrue($cache->isComplete('', false));
|
||||
}
|
||||
|
||||
public function testSave()
|
||||
{
|
||||
$data = json_encode([[], []]);
|
||||
$client = Mockery::mock('Predis\Client');
|
||||
$command = Mockery::mock('Predis\Command\CommandInterface');
|
||||
$client->shouldReceive('createCommand')->with('set', ['flysystem', $data])->once()->andReturn($command);
|
||||
$client->shouldReceive('executeCommand')->with($command)->once();
|
||||
$cache = new Predis($client);
|
||||
$cache->save();
|
||||
}
|
||||
|
||||
public function testSaveWithExpire()
|
||||
{
|
||||
$data = json_encode([[], []]);
|
||||
$client = Mockery::mock('Predis\Client');
|
||||
$command = Mockery::mock('Predis\Command\CommandInterface');
|
||||
$client->shouldReceive('createCommand')->with('set', ['flysystem', $data])->once()->andReturn($command);
|
||||
$client->shouldReceive('executeCommand')->with($command)->once();
|
||||
$expireCommand = Mockery::mock('Predis\Command\CommandInterface');
|
||||
$client->shouldReceive('createCommand')->with('expire', ['flysystem', 20])->once()->andReturn($expireCommand);
|
||||
$client->shouldReceive('executeCommand')->with($expireCommand)->once();
|
||||
$cache = new Predis($client, 'flysystem', 20);
|
||||
$cache->save();
|
||||
}
|
||||
}
|
||||
45
vendor/league/flysystem-cached-adapter/tests/Psr6CacheTest.php
vendored
Normal file
45
vendor/league/flysystem-cached-adapter/tests/Psr6CacheTest.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use League\Flysystem\Cached\Storage\Psr6Cache;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class Psr6CacheTests extends TestCase
|
||||
{
|
||||
public function testLoadFail()
|
||||
{
|
||||
$pool = Mockery::mock('Psr\Cache\CacheItemPoolInterface');
|
||||
$item = Mockery::mock('Psr\Cache\CacheItemInterface');
|
||||
$item->shouldReceive('isHit')->once()->andReturn(false);
|
||||
$pool->shouldReceive('getItem')->once()->andReturn($item);
|
||||
$cache = new Psr6Cache($pool);
|
||||
$cache->load();
|
||||
$this->assertFalse($cache->isComplete('', false));
|
||||
}
|
||||
|
||||
public function testLoadSuccess()
|
||||
{
|
||||
$response = json_encode([[], ['' => true]]);
|
||||
$pool = Mockery::mock('Psr\Cache\CacheItemPoolInterface');
|
||||
$item = Mockery::mock('Psr\Cache\CacheItemInterface');
|
||||
$item->shouldReceive('get')->once()->andReturn($response);
|
||||
$item->shouldReceive('isHit')->once()->andReturn(true);
|
||||
$pool->shouldReceive('getItem')->once()->andReturn($item);
|
||||
$cache = new Psr6Cache($pool);
|
||||
$cache->load();
|
||||
$this->assertTrue($cache->isComplete('', false));
|
||||
}
|
||||
|
||||
public function testSave()
|
||||
{
|
||||
$response = json_encode([[], []]);
|
||||
$ttl = 4711;
|
||||
$pool = Mockery::mock('Psr\Cache\CacheItemPoolInterface');
|
||||
$item = Mockery::mock('Psr\Cache\CacheItemInterface');
|
||||
$item->shouldReceive('expiresAfter')->once()->with($ttl);
|
||||
$item->shouldReceive('set')->once()->andReturn($response);
|
||||
$pool->shouldReceive('getItem')->once()->andReturn($item);
|
||||
$pool->shouldReceive('save')->once()->with($item);
|
||||
$cache = new Psr6Cache($pool, 'foo', $ttl);
|
||||
$cache->save();
|
||||
}
|
||||
}
|
||||
43
vendor/league/flysystem-cached-adapter/tests/StashTest.php
vendored
Normal file
43
vendor/league/flysystem-cached-adapter/tests/StashTest.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use League\Flysystem\Cached\Storage\Stash;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class StashTests extends TestCase
|
||||
{
|
||||
public function testLoadFail()
|
||||
{
|
||||
$pool = Mockery::mock('Stash\Pool');
|
||||
$item = Mockery::mock('Stash\Item');
|
||||
$item->shouldReceive('get')->once()->andReturn(null);
|
||||
$item->shouldReceive('isMiss')->once()->andReturn(true);
|
||||
$pool->shouldReceive('getItem')->once()->andReturn($item);
|
||||
$cache = new Stash($pool);
|
||||
$cache->load();
|
||||
$this->assertFalse($cache->isComplete('', false));
|
||||
}
|
||||
|
||||
public function testLoadSuccess()
|
||||
{
|
||||
$response = json_encode([[], ['' => true]]);
|
||||
$pool = Mockery::mock('Stash\Pool');
|
||||
$item = Mockery::mock('Stash\Item');
|
||||
$item->shouldReceive('get')->once()->andReturn($response);
|
||||
$item->shouldReceive('isMiss')->once()->andReturn(false);
|
||||
$pool->shouldReceive('getItem')->once()->andReturn($item);
|
||||
$cache = new Stash($pool);
|
||||
$cache->load();
|
||||
$this->assertTrue($cache->isComplete('', false));
|
||||
}
|
||||
|
||||
public function testSave()
|
||||
{
|
||||
$response = json_encode([[], []]);
|
||||
$pool = Mockery::mock('Stash\Pool');
|
||||
$item = Mockery::mock('Stash\Item');
|
||||
$item->shouldReceive('set')->once()->andReturn($response);
|
||||
$pool->shouldReceive('getItem')->once()->andReturn($item);
|
||||
$cache = new Stash($pool);
|
||||
$cache->save();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user