getCommand(); $command->setArguments([]); $this->assertSame([], $command->getArguments()); } /** * @group disconnected */ public function testParseResponse(): void { $this->assertSame('OK', $this->getCommand()->parseResponse('OK')); } /** * @group connected * @group relay-incompatible * @requiresRedisVersion >= 2.0.0 */ public function testAbortsTransactionAndRestoresNormalFlow(): void { $redis = $this->getClient(); $redis->multi(); $this->assertEquals('QUEUED', $redis->set('foo', 'bar')); $this->assertEquals('OK', $redis->discard()); $this->assertSame(0, $redis->exists('foo')); } /** * @group connected * @group ext-relay */ public function testAbortsTransactionAndRestoresNormalFlowUsingRelay(): void { $redis = $this->getClient(); $relay = $redis->getConnection()->getClient(); $redis->multi(); $this->assertSame($relay, $redis->set('foo', 'bar')); $this->assertTrue($redis->discard()); $this->assertSame(0, $redis->exists('foo')); } /** * @group connected * @group relay-incompatible * @requiresRedisVersion >= 6.0.0 */ public function testAbortsTransactionAndRestoresNormalFlowResp3(): void { $redis = $this->getResp3Client(); $redis->multi(); $this->assertEquals('QUEUED', $redis->set('foo', 'bar')); $this->assertEquals('OK', $redis->discard()); $this->assertSame(0, $redis->exists('foo')); } /** * @group connected * @requiresRedisVersion >= 2.0.0 */ public function testThrowsExceptionWhenCallingOutsideTransaction(): void { $this->expectException('Predis\Response\ServerException'); $this->expectExceptionMessage('DISCARD without MULTI'); $redis = $this->getClient(); $redis->discard(); } }