|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * This file is part of RedisClient. |
| 4 | + * git: https://github.com/cheprasov/php-redis-client |
| 5 | + * |
| 6 | + * (C) Alexander Cheprasov <[email protected]> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | +namespace Test\Integration\Version2x6; |
| 12 | + |
| 13 | +use RedisClient\Client\Version\RedisClient2x6; |
| 14 | + |
| 15 | +/** |
| 16 | + * @see \RedisClient\Command\Traits\Version2x6\SetsCommandsTrait |
| 17 | + */ |
| 18 | +class CommonTest extends \PHPUnit_Framework_TestCase { |
| 19 | + |
| 20 | + const TEST_REDIS_SERVER_1 = TEST_REDIS_SERVER_2x6_1; |
| 21 | + |
| 22 | + /** |
| 23 | + * @var RedisClient2x6 |
| 24 | + */ |
| 25 | + protected static $Redis; |
| 26 | + |
| 27 | + /** |
| 28 | + * @inheritdoc |
| 29 | + */ |
| 30 | + public static function setUpBeforeClass() { |
| 31 | + static::$Redis = new RedisClient2x6([ |
| 32 | + 'server' => static::TEST_REDIS_SERVER_1, |
| 33 | + 'timeout' => 2, |
| 34 | + ]); |
| 35 | + } |
| 36 | + |
| 37 | + /** |
| 38 | + * @inheritdoc |
| 39 | + */ |
| 40 | + public static function tearDownAfterClass() { |
| 41 | + static::$Redis->flushall(); |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * @inheritdoc |
| 46 | + */ |
| 47 | + protected function setUp() { |
| 48 | + static::$Redis->flushall(); |
| 49 | + } |
| 50 | + |
| 51 | + /** |
| 52 | + * @see \RedisClient\Client\AbstractRedisClient::executeRawString |
| 53 | + */ |
| 54 | + public function test_executeRawString() { |
| 55 | + $Redis = static::$Redis; |
| 56 | + |
| 57 | + $this->assertSame('PONG', $Redis->executeRawString('PING')); |
| 58 | + |
| 59 | + $this->assertSame(true, $Redis->executeRawString('SET foo bar')); |
| 60 | + $this->assertSame('bar', $Redis->executeRawString('GET foo')); |
| 61 | + |
| 62 | + $this->assertSame(true, $Redis->executeRawString('SET foo "hello world"')); |
| 63 | + $this->assertSame('hello world', $Redis->executeRawString('GET foo')); |
| 64 | + |
| 65 | + $this->assertSame(true, $Redis->executeRawString("SET \"\" \"String\r\nwith\r\nnewlines\"")); |
| 66 | + $this->assertSame("String\r\nwith\r\nnewlines", $Redis->executeRawString('GET ""')); |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * @see \RedisClient\Client\AbstractRedisClient::executeRaw |
| 71 | + */ |
| 72 | + public function test_executeRaw() { |
| 73 | + $Redis = static::$Redis; |
| 74 | + |
| 75 | + $this->assertSame('PONG', $Redis->executeRaw(['PING'])); |
| 76 | + |
| 77 | + $this->assertSame(true, $Redis->executeRaw(['SET', 'foo', 'bar'])); |
| 78 | + $this->assertSame('bar', $Redis->executeRaw(['GET', 'foo'])); |
| 79 | + |
| 80 | + $this->assertSame(true, $Redis->executeRaw(['SET', 'foo', 'hello world'])); |
| 81 | + $this->assertSame('hello world', $Redis->executeRaw(['GET', 'foo'])); |
| 82 | + |
| 83 | + $this->assertSame(true, $Redis->executeRaw(['SET', '', "String\r\nwith\r\nnewlines"])); |
| 84 | + $this->assertSame("String\r\nwith\r\nnewlines", $Redis->executeRaw(['GET', ''])); |
| 85 | + } |
| 86 | + |
| 87 | +} |
0 commit comments