|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/* |
| 6 | + * Copyright MacFJA |
| 7 | + * |
| 8 | + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated |
| 9 | + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the |
| 10 | + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to |
| 11 | + * permit persons to whom the Software is furnished to do so, subject to the following conditions: |
| 12 | + * |
| 13 | + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the |
| 14 | + * Software. |
| 15 | + * |
| 16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE |
| 17 | + * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
| 18 | + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
| 19 | + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 20 | + */ |
| 21 | + |
| 22 | +namespace MacFJA\RediSearch\tests\fixes; |
| 23 | + |
| 24 | +use Exception; |
| 25 | +use MacFJA\RediSearch\Redis\Client; |
| 26 | +use MacFJA\RediSearch\Redis\Initializer; |
| 27 | +use PHPUnit\Framework\TestCase; |
| 28 | + |
| 29 | +/** |
| 30 | + * @covers \MacFJA\RediSearch\Redis\Initializer |
| 31 | + * |
| 32 | + * @internal |
| 33 | + */ |
| 34 | +class PR42Test extends TestCase |
| 35 | +{ |
| 36 | + public function testUnavailableCommand(): void |
| 37 | + { |
| 38 | + $client = $this->createMock(Client::class); |
| 39 | + $client->method('executeRaw')->willThrowException(new Exception('ERR unknown command `module`, with args beginning with: `list`')); |
| 40 | + |
| 41 | + $response = Initializer::getRediSearchVersion($client); |
| 42 | + |
| 43 | + static::assertNull($response); |
| 44 | + } |
| 45 | + |
| 46 | + public function testUnknownError(): void |
| 47 | + { |
| 48 | + $this->expectException(Exception::class); |
| 49 | + |
| 50 | + $client = $this->createMock(Client::class); |
| 51 | + $client->method('executeRaw')->willThrowException(new Exception('ERR unknown server error')); |
| 52 | + |
| 53 | + Initializer::getRediSearchVersion($client); |
| 54 | + } |
| 55 | +} |
0 commit comments