Skip to content

Commit

Permalink
Build fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Zales0123 committed Jan 21, 2019
1 parent b4018f8 commit f7df088
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php

php:
- 7.1
- 7.2

env:
Expand Down
33 changes: 20 additions & 13 deletions spec/Parser/CommandRequestParserSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,43 @@
use Sylius\ShopApiPlugin\Exception\CannotParseCommand;
use Sylius\ShopApiPlugin\Parser\CommandRequestParserInterface;
use Sylius\ShopApiPlugin\Request\ChangeItemQuantityRequest;
use Sylius\ShopApiPlugin\Request\CommandRequestInterface;
use Sylius\ShopApiPlugin\Request\PickupCartRequest;
use Symfony\Component\DependencyInjection\ServiceLocator;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;

final class CommandRequestParserSpec extends ObjectBehavior
{
function let(): void
function let(ServiceLocator $commandRequestLocator): void
{
$this->beConstructedWith([
'ChangeItemQuantity' => ChangeItemQuantityRequest::class,
'PickupCart' => PickupCartRequest::class,
]);
$this->beConstructedWith($commandRequestLocator);
}

function it_is_command_request(): void
{
$this->shouldImplement(CommandRequestParserInterface::class);
}

function it_provides_command_request_object_for_command_name(Request $request): void
{
$request->attributes = new ParameterBag([]);
$request->request = new ParameterBag([]);
function it_provides_command_request_object_for_command_name(
ServiceLocator $commandRequestLocator,
Request $request,
CommandRequestInterface $commandRequest
): void {
$commandRequestLocator->has('ValidCommand')->willReturn(true);

$commandRequestLocator->get('ValidCommand')->willReturn($commandRequest);
$commandRequest->populateData($request)->shouldBeCalled();

$this->parse($request, 'ChangeItemQuantity')->shouldHaveType(ChangeItemQuantityRequest::class);
$this->parse($request, 'PickupCart')->shouldHaveType(PickupCartRequest::class);
$this->parse($request, 'ValidCommand')->shouldReturn($commandRequest);
}

function it_throws_exception_if_command_request_cannot_be_parsed(Request $request): void
{
function it_throws_exception_if_command_request_cannot_be_parsed(
ServiceLocator $commandRequestLocator,
Request $request
): void {
$commandRequestLocator->has('InvalidCommand')->willReturn(false);

$this
->shouldThrow(CannotParseCommand::withCommandName('InvalidCommand'))
->during('parse', [$request, 'InvalidCommand'])
Expand Down
4 changes: 3 additions & 1 deletion tests/DependencyInjection/ShopApiExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ final class ShopApiExtensionTest extends AbstractExtensionTestCase
*/
public function it_sets_up_parameter_with_attributes_to_serialize(): void
{
$this->setParameter('kernel.project_dir', __DIR__.'/../../');
$this->load([
'included_attributes' => [
'ATTRIBUTE_CODE',
],
]
]);

$this->assertContainerBuilderHasParameter('sylius.shop_api.included_attributes', ['ATTRIBUTE_CODE']);
Expand All @@ -29,6 +30,7 @@ public function it_sets_up_parameter_with_attributes_to_serialize(): void
*/
public function it_defines_view_classes_parameters(): void
{
$this->setParameter('kernel.project_dir', __DIR__.'/../../');
$this->load([]);

$nameToClass = [
Expand Down
3 changes: 2 additions & 1 deletion tests/Request/PutSimpleItemToCartRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ final class PutSimpleItemToCartRequestTest extends TestCase
*/
public function it_creates_put_simple_item_to_cart_command_from_request()
{
$putSimpleItemToCartRequest = PutSimpleItemToCartRequest::fromRequest(new Request([], [
$putSimpleItemToCartRequest = new PutSimpleItemToCartRequest();
$putSimpleItemToCartRequest->populateData(new Request([], [
'productCode' => 'HACKTOBERFEST_TSHIRT_CODE',
'quantity' => 4,
], ['token' => 'ORDERTOKEN']));
Expand Down

0 comments on commit f7df088

Please sign in to comment.