Skip to content

Commit

Permalink
tmp fix coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
grongor committed Jul 4, 2020
1 parent 2aa7b5e commit ea57eef
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Helpers/ValueGetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public static function first(array $response)
/**
* @param list<array<string, mixed>> $responses
*
* @return mixed
* @return list<mixed>
*
* @psalm-template T
* @psalm-param list<array<string, T>> $responses
* @psalm-return list<T>
*/
public static function batchFirst(array $responses)
public static function batchFirst(array $responses) : array
{
$result = [];
foreach ($responses as $response) {
Expand Down
8 changes: 8 additions & 0 deletions tests/Transport/ApiSnmpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Psr\Http\Message\RequestInterface;
use SimPod\PhpSnmp\Exception\EndOfMibReached;
use SimPod\PhpSnmp\Exception\GeneralException;
use SimPod\PhpSnmp\Exception\NoRequestsProvided;
use SimPod\PhpSnmp\Exception\NoSuchInstanceExists;
use SimPod\PhpSnmp\Exception\NoSuchObjectExists;
use SimPod\PhpSnmp\Transport\ApiSnmpClient;
Expand Down Expand Up @@ -282,6 +283,13 @@ static function (RequestInterface $request) : bool {
);
}

public function testBatchNoRequests() : void
{
$this->expectExceptionObject(NoRequestsProvided::new());

$this->createApiSnmp()->batch();
}

public function testThatParametersAreCorrectlyPropagatedToTheJsonRequest() : void
{
$this->client = $this->createMock(Client::class);
Expand Down
15 changes: 15 additions & 0 deletions tests/Transport/FallbackSnmpClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Psr\Log\Test\TestLogger;
use SimPod\PhpSnmp\Exception\GeneralException;
use SimPod\PhpSnmp\Transport\FallbackSnmpClient;
use SimPod\PhpSnmp\Transport\Request;
use SimPod\PhpSnmp\Transport\SnmpClient;

final class FallbackSnmpClientTest extends TestCase
Expand Down Expand Up @@ -55,6 +56,20 @@ public function testWalk() : void
self::assertSame($expected, $result);
}

public function testBatch() : void
{
$client1 = $this->createMock(SnmpClient::class);
$client1->expects(self::once())
->method('batch')
->with($request1 = Request::walk('.1.2.3', 10), $request2 = Request::get(['.4.5.6']))
->willReturn($expected = [['.1.2.3' => 123], ['.4.5.6' => 456]]);

$fallbackClient = new FallbackSnmpClient(new NullLogger(), $client1);
$result = $fallbackClient->batch($request1, $request2);

self::assertSame($expected, $result);
}

public function testOnlyLastClientWorks() : void
{
$client1 = $this->createMock(SnmpClient::class);
Expand Down

0 comments on commit ea57eef

Please sign in to comment.