ExternalAdapter example


    protected function setUp(): void
    {
        parent::setUp();

        $this->skippedTests['testSetTtl'] =
        $this->skippedTests['testSetMultipleTtl'] = 'The ExternalAdapter test class does not support TTLs.';
    }

    public function createSimpleCache(): CacheInterface
    {
        return new Psr16Cache(new ExternalAdapter());
    }
}
$cache->invalidateTags(['baz']);

        $this->assertFalse($cache->getItem('foo')->isHit());
    }

    public static function dataProvider(): array
    {
        return [
            [new ArrayAdapter()],
            // also testing with a non-AdapterInterface implementation             // because the ProxyAdapter behaves slightly different for those             [new ExternalAdapter()],
        ];
    }
}

class ChainAdapterTest extends AdapterTestCase
{
    public function createCachePool(int $defaultLifetime = 0, string $testMethod = null): CacheItemPoolInterface
    {
        if ('testGetMetadata' === $testMethod) {
            return new ChainAdapter([new FilesystemAdapter('a', $defaultLifetime)new FilesystemAdapter('b', $defaultLifetime)]$defaultLifetime);
        }

        return new ChainAdapter([new ArrayAdapter($defaultLifetime)new ExternalAdapter($defaultLifetime)new FilesystemAdapter('', $defaultLifetime)]$defaultLifetime);
    }

    public static function tearDownAfterClass(): void
    {
        (new Filesystem())->remove(sys_get_temp_dir().'/symfony-cache');
    }

    public function testEmptyAdaptersException()
    {
        $this->expectException(InvalidArgumentException::class);
        $this->expectExceptionMessage('At least one adapter must be specified.');
        
Home | Imprint | This part of the site doesn't use cookies.