expectException('Predis\Response\ServerException'); $this->expectExceptionMessage(self::ERR_WRONG_KEY_TYPE); throw new ServerException(self::ERR_WRONG_KEY_TYPE); } /** * @group disconnected */ public function testExceptionClass(): void { $exception = new ServerException(self::ERR_WRONG_KEY_TYPE); $this->assertInstanceOf('Predis\Response\ServerException', $exception); $this->assertInstanceOf('Predis\Response\ErrorInterface', $exception); $this->assertInstanceOf('Predis\Response\ResponseInterface', $exception); $this->assertInstanceOf('Predis\PredisException', $exception); } /** * @group disconnected */ public function testErrorType(): void { $exception = new ServerException(self::ERR_WRONG_KEY_TYPE); $this->assertEquals('ERR', $exception->getErrorType()); } /** * @group disconnected */ public function testToErrorResponse(): void { $exception = new ServerException(self::ERR_WRONG_KEY_TYPE); $error = $exception->toErrorResponse(); $this->assertInstanceOf('Predis\Response\Error', $error); $this->assertEquals($exception->getMessage(), $error->getMessage()); $this->assertEquals($exception->getErrorType(), $error->getErrorType()); } }