-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kim Pepper <[email protected]> Co-authored-by: Romain Ruaud <[email protected]>
- Loading branch information
1 parent
14181fa
commit ec2b48a
Showing
4 changed files
with
70 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OpenSearch\Tests; | ||
|
||
use GuzzleHttp\Ring\Future\FutureArray; | ||
use OpenSearch\ConnectionPool\AbstractConnectionPool; | ||
use OpenSearch\Connections\Connection; | ||
use OpenSearch\LegacyTransportWrapper; | ||
use OpenSearch\Transport; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
use Psr\Log\LoggerInterface; | ||
use React\Promise\Deferred; | ||
|
||
/** | ||
* Tests for the LegacyTransportWrapper class. | ||
* | ||
* @coversDefaultClass \OpenSearch\LegacyTransportWrapper | ||
* @group legacy | ||
* @deprecated in 2.4.2 and will be removed in 3.0.0. | ||
*/ | ||
class LegacyTransportWrapperTest extends TestCase | ||
{ | ||
private Connection&MockObject $connection; | ||
|
||
private AbstractConnectionPool&MockObject $connectionPool; | ||
|
||
private MockObject&LoggerInterface $logger; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->logger = $this->createMock(LoggerInterface::class); | ||
$this->connectionPool = $this->createMock(AbstractConnectionPool::class); | ||
$this->connection = $this->createMock(Connection::class); | ||
} | ||
|
||
public function testSuccess(): void | ||
{ | ||
$deferred = new Deferred(); | ||
$deferred->resolve(['foo' => 'bar']); | ||
$future = new FutureArray($deferred->promise()); | ||
|
||
$this->connection->method('performRequest') | ||
->willReturn($future); | ||
|
||
$this->connectionPool->method('nextConnection') | ||
->willReturn($this->connection); | ||
|
||
$transport = new Transport(1, $this->connectionPool, $this->logger); | ||
|
||
$wrapper = new LegacyTransportWrapper($transport); | ||
|
||
$response = $wrapper->sendRequest('GET', 'http://localhost:9200', [], null, []); | ||
|
||
$this->assertIsIterable($response); | ||
|
||
$this->assertEquals(['foo' => 'bar'], $response); | ||
} | ||
|
||
} |