/
githubmirror
/
symfony
Обзор
Документация
Войти
/
githubmirror
/
symfony
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
8.2
src/Symfony/Component/Cache/Tests/Adapter/CouchbaseCollectionAdapterTest.php
62 строки
2 KB
Nicolas Grekas
Merge branch '6.4' into 7.4
24 май 2026, 11:43
24 май 2026, 11:43
e33beda
Код
Авторство
О чём код?
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Cache\Tests\Adapter; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RequiresPhpExtension; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Adapter\CouchbaseCollectionAdapter; /** * @author Antonio Jose Cerezo Aranda <aj.cerezo@gmail.com> */ #[RequiresPhpExtension('couchbase', '<4.0.0')] #[RequiresPhpExtension('couchbase', '>=3.0.5')] #[Group('integration')] class CouchbaseCollectionAdapterTest extends AdapterTestCase { protected $skippedTests = [ 'testClearPrefix' => 'Couchbase cannot clear by prefix', 'testClearPrefixWithUnderscore' => 'Couchbase cannot clear by prefix', 'testClearWithInvalidPrefix' => 'Couchbase cannot clear by prefix', ]; public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface { $client = AbstractAdapter::createConnection('couchbase://'.getenv('COUCHBASE_HOST').'/cache', ['username' => getenv('COUCHBASE_USER'), 'password' => getenv('COUCHBASE_PASS')] ); return new CouchbaseCollectionAdapter($client, str_replace('\\', '.', __CLASS__), $defaultLifetime); } /** * Couchbase consider expiration time greater than 30 days as an absolute timestamp. * This test case overrides parent to avoid this behavior for the "k2" item. */ public function testExpiration() { $cache = $this->createCachePool(); $cache->save($cache->getItem('k1')->set('v1')->expiresAfter(2)); $cache->save($cache->getItem('k2')->set('v2')->expiresAfter(86400)); sleep(3); $item = $cache->getItem('k1'); $this->assertFalse($item->isHit()); $this->assertNull($item->get(), "Item's value must be null when isHit() is false."); $item = $cache->getItem('k2'); $this->assertTrue($item->isHit()); $this->assertSame('v2', $item->get()); } }