forked from symfony/symfony
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
767e0f9
commit 4173c38
Showing
12 changed files
with
1,478 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
CHANGELOG | ||
========= | ||
|
||
6.3 | ||
--- | ||
|
||
* Add support for Relay PHP extension for Redis | ||
|
||
6.1 | ||
--- | ||
|
||
|
42 changes: 42 additions & 0 deletions
42
src/Symfony/Component/Cache/Tests/Adapter/RelayAdapterSentinelTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* 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\SkippedTestSuiteError; | ||
use Relay\Relay; | ||
use Relay\Sentinel; | ||
use Symfony\Component\Cache\Adapter\AbstractAdapter; | ||
|
||
/** | ||
* @group integration | ||
*/ | ||
class RelayAdapterSentinelTest extends AbstractRedisAdapterTest | ||
{ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
if (!class_exists(Sentinel::class)) { | ||
throw new SkippedTestSuiteError('The Relay\Sentinel class is required.'); | ||
} | ||
if (!$hosts = getenv('REDIS_SENTINEL_HOSTS')) { | ||
throw new SkippedTestSuiteError('REDIS_SENTINEL_HOSTS env var is not defined.'); | ||
} | ||
if (!$service = getenv('REDIS_SENTINEL_SERVICE')) { | ||
throw new SkippedTestSuiteError('REDIS_SENTINEL_SERVICE env var is not defined.'); | ||
} | ||
|
||
self::$redis = AbstractAdapter::createConnection( | ||
'redis:?host['.str_replace(' ', ']&host[', $hosts).']', | ||
['redis_sentinel' => $service, 'prefix' => 'prefix_', 'class' => Relay::class], | ||
); | ||
self::assertInstanceOf(Relay::class, self::$redis); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/Symfony/Component/Cache/Tests/Adapter/RelayAdapterTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* 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\SkippedTestSuiteError; | ||
use Relay\Relay; | ||
use Symfony\Component\Cache\Adapter\AbstractAdapter; | ||
use Symfony\Component\Cache\Adapter\RedisAdapter; | ||
use Symfony\Component\Cache\Exception\InvalidArgumentException; | ||
use Symfony\Component\Cache\Traits\RelayProxy; | ||
|
||
/** | ||
* @requires extension relay | ||
* | ||
* @group integration | ||
*/ | ||
class RelayAdapterTest extends AbstractRedisAdapterTest | ||
{ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
try { | ||
new Relay(...explode(':', getenv('REDIS_HOST'))); | ||
} catch (\Relay\Exception $e) { | ||
throw new SkippedTestSuiteError(getenv('REDIS_HOST').': '.$e->getMessage()); | ||
} | ||
self::$redis = AbstractAdapter::createConnection('redis://'.getenv('REDIS_HOST'), ['lazy' => true, 'class' => Relay::class]); | ||
self::assertInstanceOf(RelayProxy::class, self::$redis); | ||
} | ||
|
||
public function testCreateHostConnection() | ||
{ | ||
$redis = RedisAdapter::createConnection('redis://'.getenv('REDIS_HOST').'?class=Relay\Relay'); | ||
$this->assertInstanceOf(Relay::class, $redis); | ||
$this->assertTrue($redis->isConnected()); | ||
$this->assertSame(0, $redis->getDbNum()); | ||
} | ||
|
||
public function testLazyConnection() | ||
{ | ||
$redis = RedisAdapter::createConnection('redis://nonexistenthost?class=Relay\Relay&lazy=1'); | ||
$this->assertInstanceOf(RelayProxy::class, $redis); | ||
// no exception until now | ||
$this->expectException(InvalidArgumentException::class); | ||
$this->expectExceptionMessage('Failed to resolve host address'); | ||
$redis->getHost(); // yep, only here exception is thrown | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.