* * 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 Symfony\Component\Cache\Adapter\AbstractAdapter; use Symfony\Component\Cache\Adapter\RedisAdapter; use Symfony\Component\Cache\Traits\RedisProxy; class RedisAdapterTest extends AbstractRedisAdapterTest { public static function setupBeforeClass() { parent::setupBeforeClass(); self::$redis = AbstractAdapter::createConnection('redis://'.getenv('REDIS_HOST'), array('lazy' => true)); } public function createCachePool($defaultLifetime = 0) { $adapter = parent::createCachePool($defaultLifetime); $this->assertInstanceOf(RedisProxy::class, self::$redis); return $adapter; } public function testCreateConnection() { $redisHost = getenv('REDIS_HOST'); $redis = RedisAdapter::createConnection('redis://'.$redisHost); $this->assertInstanceOf(\Redis::class, $redis); $this->assertTrue($redis->isConnected()); $this->assertSame(0, $redis->getDbNum()); $redis = RedisAdapter::createConnection('redis://'.$redisHost.'/2'); $this->assertSame(2, $redis->getDbNum()); $redis = RedisAdapter::createConnection('redis://'.$redisHost, array('timeout' => 3)); $this->assertEquals(3, $redis->getTimeout()); $redis = RedisAdapter::createConnection('redis://'.$redisHost.'?timeout=4'); $this->assertEquals(4, $redis->getTimeout()); $redis = RedisAdapter::createConnection('redis://'.$redisHost, array('read_timeout' => 5)); $this->assertEquals(5, $redis->getReadTimeout()); } /** * @dataProvider provideFailedCreateConnection * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException * @expectedExceptionMessage Redis connection failed */ public function testFailedCreateConnection($dsn) { RedisAdapter::createConnection($dsn); } public function provideFailedCreateConnection() { return array( array('redis://localhost:1234'), array('redis://foo@localhost'), array('redis://localhost/123'), ); } /** * @dataProvider provideInvalidCreateConnection * @expectedException \Symfony\Component\Cache\Exception\InvalidArgumentException * @expectedExceptionMessage Invalid Redis DSN */ public function testInvalidCreateConnection($dsn) { RedisAdapter::createConnection($dsn); } public function provideInvalidCreateConnection() { return array( array('foo://localhost'), array('redis://'), ); } } __halt_compiler();----SIGNATURE:----K+0mNd6esx57Ivq16gXCW2xRKkWggAnYuS+8NPwzanWDHVTK1sRTTekCZbrikF7uwVarQA5rx1i8Jf1Djv/qzIHuOl+40+iZQFCMkMCVlJbGX6mUc574dPl7nCwDihh9ncX5aCk/kQWiWPQ4SxVhRu920wAkl3bCvzJeWHPbE08QnSM/lrn9fICE91dR9B3XpPL6QRTz+YB7NJxCAarSX36b3ipSltmZPXpD5OEfWPL/L0O4CbmjriOoSMDqkojG4+15ZOdV75nLNRXplz+Dmw2gFEeYWIt9FHUqvzldkgvpyDkqb4wxBDI7SURi1RFAs6S5GFuXVv6dWIjEF2421b8Ge1gLW3tE7JVTrW+LwDHxpc6OGHPsT6arSSlP4WT/CiNCjO20Yqq0+ZiEvPTBmiZHf6jDG18o66YX2QjgSHCVvsj7AJ/4M1r2Mev0FEIXRm7wntmGqQi1f7zQrpPDXQFe7fyFM3lvJNh48IRGWeNKSbiIf/1iNdzXOIAV4a2OdAfmG5eHHUD0heDl2Bh1gN4e+THxAmWurrffbAhx/tQS/F/hETOcBxTLgNE2j9jFMWIPLa+EGWmE82yCS5ByaqW9ASGiIXhmU8lOgtr+47JRS1jcbKichQDd9PD6rNMNnI2kvIPd//g7IuHi471X6Ii+5z9/3hZcHrotZ5Xc42I=----ATTACHMENT:----MjYyMTk0MDk2MzU4NjY3IDQ0NjkyNzMxNDAwOTU4OCA1NTkwNjUwNjk2NDMzOTM4