Skip to content

Commit

Permalink
Driver discovery test
Browse files Browse the repository at this point in the history
  • Loading branch information
jenky committed Sep 22, 2023
1 parent f838919 commit 2398def
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/ConnectorPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
use Jenky\Atlas\Response;

if (! \interface_exists(ConnectorInterface::class)) {
// @codeCoverageIgnoreStart
throw new \LogicException('You cannot use the ConnectorPool as the "fansipan/fansipan" package is not installed.');
// @codeCoverageIgnoreEnd
}

/**
Expand Down
12 changes: 11 additions & 1 deletion tests/PoolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ public function test_concurrency_limit(): void
$pool->concurrent(-1);
}

public function test_driver_discovery(): void
{
$this->assertSame(Driver::PSL, DriverDiscovery::find(false));

DriverDiscovery::prefer(Driver::REACT);

$this->assertSame(Driver::REACT, DriverDiscovery::find(false));
}

public function test_async_client_factory(): void
{
$client = Factory::createAsyncClient(new Client());
Expand Down Expand Up @@ -67,7 +76,7 @@ public function test_invalid_pool_request(): void
$connectorPool->send([1, fn () => new \stdClass()]);
}

public function test_create_pool_using_unsupported_client(): void
public function test_pool_factory(): void
{
$pool = PoolFactory::createForConnector((new GenericConnector())->withClient(new Client()));
$this->assertInstanceOf(GuzzleClient::class, $this->getClientFromPool($pool));
Expand All @@ -79,6 +88,7 @@ public function test_create_pool_using_unsupported_client(): void
$pool = PoolFactory::createForClient(new FakeHttpClient());

DriverDiscovery::prefer(Driver::REACT);

$pool = PoolFactory::createForClient(Factory::createAsyncClient(new FakeHttpClient()));
$this->assertInstanceOf(ReactClient::class, $this->getClientFromPool($pool));
}
Expand Down

0 comments on commit 2398def

Please sign in to comment.