/
CouchbaseBucketAdapterTest.php
58 lines (48 loc) · 1.84 KB
/
CouchbaseBucketAdapterTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?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 Psr\Cache\CacheItemPoolInterface;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\Cache\Adapter\AbstractAdapter;
use Symfony\Component\Cache\Adapter\CouchbaseBucketAdapter;
/**
* @requires extension couchbase <3.0.0
* @requires extension couchbase >=2.6.0
*
* @group legacy integration
*
* @author Antonio Jose Cerezo Aranda <aj.cerezo@gmail.com>
*/
class CouchbaseBucketAdapterTest extends AdapterTestCase
{
use ExpectDeprecationTrait;
protected $skippedTests = [
'testClearPrefix' => 'Couchbase cannot clear by prefix',
];
protected \CouchbaseBucket $client;
protected function setUp(): void
{
$this->expectDeprecation('Since symfony/cache 7.1: The "Symfony\Component\Cache\Adapter\CouchbaseBucketAdapter" class is deprecated, use "Symfony\Component\Cache\Adapter\CouchbaseCollectionAdapter" instead.');
$this->client = AbstractAdapter::createConnection('couchbase://'.getenv('COUCHBASE_HOST').'/cache',
['username' => getenv('COUCHBASE_USER'), 'password' => getenv('COUCHBASE_PASS')]
);
}
public function createCachePool($defaultLifetime = 0): CacheItemPoolInterface
{
$client = $defaultLifetime
? AbstractAdapter::createConnection('couchbase://'
.getenv('COUCHBASE_USER')
.':'.getenv('COUCHBASE_PASS')
.'@'.getenv('COUCHBASE_HOST')
.'/cache')
: $this->client;
return new CouchbaseBucketAdapter($client, str_replace('\\', '.', __CLASS__), $defaultLifetime);
}
}