Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ parameters:
- %rootDir%/../../../src

ignoreErrors:
-
message: '#.*NodeDefinition::children.*#'
path: ./src/DependencyInjection

-
message: '#.*Extension::processConfiguration.*#'
path: ./src/DependencyInjection
7 changes: 1 addition & 6 deletions src/Command/FindPoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Answear\InpostBundle\Command;

use Answear\InpostBundle\Client\Client;
use Answear\InpostBundle\Client\Serializer;
use Answear\InpostBundle\Request\FindPointsRequest;
use Answear\InpostBundle\Response\FindPointsResponse;
use GuzzleHttp\Psr7\Request as HttpRequest;
Expand All @@ -14,14 +13,11 @@
class FindPoints extends AbstractCommand
{
private Client $client;
private Serializer $serializer;

public function __construct(
Client $client,
Serializer $serializer,
) {
$this->client = $client;
$this->serializer = $serializer;
}

public function findPoints(FindPointsRequest $request): FindPointsResponse
Expand All @@ -30,9 +26,8 @@ public function findPoints(FindPointsRequest $request): FindPointsResponse
$request->getMethod(),
new Uri($request->getRequestUrl()),
[
'Content-type' => 'application/json',
'Content-Type' => 'application/json',
],
$this->serializer->serialize($request)
);

$response = $this->client->request($httpRequest);
Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public function getConfigTreeBuilder(): TreeBuilder

$treeBuilder->getRootNode()
->children()
?->scalarNode('baseUrl')->defaultNull()->end()
?->end();
->scalarNode('baseUrl')->defaultNull()->end()
->end();

return $treeBuilder;
}
Expand Down
19 changes: 17 additions & 2 deletions tests/Integration/Command/FindPointsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Answear\InpostBundle\Tests\Integration\Command;

use Answear\InpostBundle\Client\Client;
use Answear\InpostBundle\Client\Serializer;
use Answear\InpostBundle\Command\FindPoints;
use Answear\InpostBundle\ConfigProvider;
use Answear\InpostBundle\Enum\PointFunctionsType;
Expand Down Expand Up @@ -89,6 +88,22 @@ public function successfulFindPointsPoland(): void
$this->assertTrue($point->location247);
}

/**
* @test
*/
public function findPointsSendsGetRequestWithoutBody(): void
{
$this->mockGuzzleResponse(new Response(200, [], $this->getSuccessfulBody(self::POLAND)));

$this->getCommand()->findPoints(new FindPointsRequest());

$this->assertCount(1, $this->clientHistory);
$request = $this->clientHistory[0]['request'];
$this->assertSame('GET', $request->getMethod());
$this->assertSame('', (string) $request->getBody());
$this->assertSame(['application/json'], $request->getHeader('Content-Type'));
}

/**
* @test
*/
Expand Down Expand Up @@ -168,7 +183,7 @@ public function successfulFindPointsItaly(): void

private function getCommand(): FindPoints
{
return new FindPoints($this->client, new Serializer());
return new FindPoints($this->client);
}

private function getSuccessfulBody(string $country): string
Expand Down
Loading