Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update various dependencies #293

Merged
merged 5 commits into from
Aug 21, 2018
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
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@
"php": "^7.1",

"sylius/sylius": "^1.1",
"league/tactician-bundle": "^0.4",
"league/tactician-bundle": "^1.1",
"league/tactician-doctrine": "^1.1"
},
"require-dev": {
"lakion/api-test-case": "^1.1",
"phpspec/phpspec": "^3.2",
"lexik/jwt-authentication-bundle": "^2.4",
"matthiasnoback/symfony-config-test": "^2.0",
"matthiasnoback/symfony-dependency-injection-test": "^1.0",
"phpunit/phpunit": "^5.6",
"doctrine/common": "<2.8",
"lakion/api-test-case": "^3.1",
"phpspec/phpspec": "^5.0",
"lexik/jwt-authentication-bundle": "^2.5",
"matthiasnoback/symfony-config-test": "^3.1",
"matthiasnoback/symfony-dependency-injection-test": "^2.3",
"phpunit/phpunit": "^6.5",
"sylius-labs/coding-standard": "^2.0"
},
"autoload": {
Expand All @@ -28,7 +27,8 @@
"autoload-dev": {
"psr-4": {
"Tests\\Sylius\\ShopApiPlugin\\": "tests/"
}
},
"classmap": ["tests/Application/app/AppKernel.php"]
},
"suggest": {
"nelmio/cors-bundle": "allows you to send Cross-Origin Ajax API Request"
Expand Down
7 changes: 3 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.5/phpunit.xsd"
backupGlobals="false"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.5/phpunit.xsd"
colors="true"
bootstrap="vendor/autoload.php"
>
Expand All @@ -14,8 +12,9 @@
</testsuites>

<php>
<server name="KERNEL_CLASS_PATH" value="/tests/Application/app/AppKernel.php" />
<server name="KERNEL_CLASS" value="AppKernel" />
<server name="IS_DOCTRINE_ORM_SUPPORTED" value="true" />
<server name="ESCAPE_JSON" value="true" />
</php>

<filter>
Expand Down
19 changes: 10 additions & 9 deletions spec/Handler/SetDefaultAddressHandlerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PhpSpec\ObjectBehavior;
use Sylius\Component\Core\Model\AddressInterface;
use Sylius\Component\Core\Model\Customer;
use Sylius\Component\Core\Model\CustomerInterface;
use Sylius\Component\Core\Model\ShopUserInterface;
use Sylius\Component\Core\Repository\AddressRepositoryInterface;
use Sylius\Component\Core\Repository\CustomerRepositoryInterface;
Expand Down Expand Up @@ -40,36 +41,36 @@ function it_handles_setting_default_address_for_user(
$user->getCustomer()->willReturn($customer);
$address->getCustomer()->willReturn($customer);

$customer->getId()->willReturn('USER_ID');
$user->getId()->willReturn('USER_ID');
$customer->getId()->willReturn('CUSTOMER_ID');

$customer->setDefaultAddress($address)->shouldBeCalled();

$this->handle(new SetDefaultAddress(1, 'user@email.com'));
}

function it_trows_exception_if_address_does_not_belong_to_current_user(
function it_throws_exception_if_address_does_not_belong_to_current_user(
AddressInterface $address,
AddressRepositoryInterface $addressRepository,
RepositoryInterface $shopUserRepository,
ShopUserInterface $user,
Customer $customer
CustomerInterface $customer,
CustomerInterface $anotherCustomer
) {
$shopUserRepository->findOneBy(['username' => 'user@email.com'])->willReturn($user);
$addressRepository->find(1)->willReturn($address);

$user->getCustomer()->willReturn($customer);
$address->getCustomer()->willReturn($customer);
$address->getCustomer()->willReturn($anotherCustomer);

$customer->getId()->willReturn('USER_ID_1');
$user->getId()->willReturn('USER_ID_2');
$customer->getId()->willReturn('CUSTOMER_ID');
$anotherCustomer->getId()->willReturn('ANOTHER_CUSTOMER_ID');

$this->shouldThrow(\InvalidArgumentException::class)->during('handle', [
new SetDefaultAddress(1, 'user@email.com'),
]);
}

function it_trows_exception_if_address_is_not_associated_with_any_user(
function it_throws_exception_if_address_is_not_associated_with_any_user(
AddressInterface $address,
AddressRepositoryInterface $addressRepository,
RepositoryInterface $shopUserRepository,
Expand All @@ -80,7 +81,7 @@ function it_trows_exception_if_address_is_not_associated_with_any_user(

$address->getCustomer()->willReturn(null);

$user->getId()->shouldNotBeCalled();
$user->getCustomer()->shouldNotBeCalled();

$this->shouldThrow(\InvalidArgumentException::class)->during('handle', [
new SetDefaultAddress(1, 'user@email.com'),
Expand Down
2 changes: 1 addition & 1 deletion src/Handler/SetDefaultAddressHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ public function handle(SetDefaultAddress $setDefaultAddress): void
private function assertCurrentUserIsOwner(AddressInterface $address, ShopUserInterface $user)
{
Assert::notNull($address->getCustomer(), 'Address is not associated with any user.');
Assert::eq($address->getCustomer()->getId(), $user->getId(), 'Current user is not owner of this address.');
Assert::eq($address->getCustomer()->getId(), $user->getCustomer()->getId(), 'Current user is not owner of this address.');
}
}
2 changes: 2 additions & 0 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<import resource="services/queries.xml"/>
</imports>
<services>
<defaults public="true" />

<service id="sylius.shop_api_plugin.checker.promotion_coupon_eligibility_checker" class="Sylius\ShopApiPlugin\Checker\PromotionCouponEligibilityChecker">
<argument type="service" id="sylius.promotion_eligibility_checker"/>
<argument type="service" id="sylius.promotion_coupon_eligibility_checker"/>
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/config/services/actions/address_book.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults public="true" />

<service id="sylius.shop_api_plugin.controller.address_book.create_address_action"
class="Sylius\ShopApiPlugin\Controller\AddressBook\CreateAddressAction"
>
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/config/services/actions/cart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults public="true" />

<service id="sylius.shop_api_plugin.controller.cart.summarize_action"
class="Sylius\ShopApiPlugin\Controller\Cart\SummarizeAction"
>
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/config/services/actions/checkout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults public="true" />

<service id="sylius.shop_api_plugin.controller.checkout.address_action"
class="Sylius\ShopApiPlugin\Controller\Checkout\AddressAction"
>
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/config/services/actions/customer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults public="true" />

<service id="sylius.shop_api_plugin.controller.customer.resend_verification_token_action"
class="Sylius\ShopApiPlugin\Controller\Customer\ResendVerificationTokenAction"
>
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/config/services/actions/product.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults public="true" />

<service id="sylius.shop_api_plugin.controller.product.show_product_details_by_slug_action"
class="Sylius\ShopApiPlugin\Controller\Product\ShowProductDetailsBySlugAction"
>
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/config/services/actions/taxon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults public="true" />

<service id="sylius.shop_api_plugin.controller.taxon.show_taxon_tree_action"
class="Sylius\ShopApiPlugin\Controller\Taxon\ShowTaxonTreeAction"
>
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/config/services/factories.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults public="true" />

<service id="sylius.shop_api_plugin.factory.image_view_factory" class="Sylius\ShopApiPlugin\Factory\ImageViewFactory">
<argument type="string">%sylius.shop_api.view.image.class%</argument>
</service>
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/config/services/handlers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults public="true" />

<service id="sylius.shop_api_plugin.handler.address_shipment" class="Sylius\ShopApiPlugin\Handler\AddressOrderHandler">
<argument type="service" id="sylius.repository.order"/>
<argument type="service" id="sylius.factory.address"/>
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/config/services/queries.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults public="true" />

<service id="sylius.shop_api_plugin.view_repository.cart_view_repository" class="Sylius\ShopApiPlugin\ViewRepository\CartViewRepository">
<argument type="service" id="sylius.repository.order" />
<argument type="service" id="sylius.shop_api_plugin.factory.cart_view_factory" />
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/config/services/validators.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults public="true" />

<service id="sylius.shop_api_plugin.validator.channel_exists_validator"
class="Sylius\ShopApiPlugin\Validator\ChannelExistsValidator"
>
Expand Down
2 changes: 1 addition & 1 deletion src/ViewRepository/ProductCatalogViewRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private function getLocaleCode(?string $localeCode, ChannelInterface $channel):
private function findByTaxon(TaxonInterface $taxon, ChannelInterface $channel, PaginatorDetails $paginatorDetails, string $localeCode): PageView
{
$queryBuilder = $this->productRepository->createShopListQueryBuilder($channel, $taxon, $localeCode);
$queryBuilder->addOrderBy('o.id');
$queryBuilder->addOrderBy('productTaxon.position');

$pagerfanta = new Pagerfanta(new DoctrineORMAdapter($queryBuilder));

Expand Down
3 changes: 3 additions & 0 deletions tests/Application/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public function registerBundles(): array

new \Sylius\ShopApiPlugin\ShopApiPlugin(),
new \Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle(),

new \Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle(),
new \Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle(),
]);
}

Expand Down
14 changes: 9 additions & 5 deletions tests/Application/app/config/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ security:
switch_user: true
context: admin
pattern: "%sylius.security.admin_regex%"
provider: sylius_admin_user_provider
form_login:
provider: sylius_admin_user_provider
login_path: sylius_admin_login
Expand Down Expand Up @@ -49,9 +50,10 @@ security:

api:
pattern: "%sylius.security.api_regex%"
fos_oauth: true
stateless: true
anonymous: true
provider: sylius_admin_user_provider
fos_oauth: true
stateless: true
anonymous: true

shop_api_login:
pattern: "%shop_api.security.regex%/login"
Expand All @@ -67,16 +69,18 @@ security:

shop_api:
pattern: "%shop_api.security.regex%"
stateless: true
anonymous: true
stateless: true
anonymous: true
guard:
provider: sylius_shop_user_provider
authenticators:
- lexik_jwt_authentication.jwt_token_authenticator

shop:
switch_user: { role: ROLE_ALLOWED_TO_SWITCH }
context: shop
pattern: "%sylius.security.shop_regex%"
provider: sylius_shop_user_provider
form_login:
success_handler: sylius.authentication.success_handler
failure_handler: sylius.authentication.failure_handler
Expand Down
21 changes: 8 additions & 13 deletions tests/Controller/AddressBookCreateAddressApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Tests\Sylius\ShopApiPlugin\Controller;

use Lakion\ApiTestCase\JsonApiTestCase;
use PHPUnit\Framework\Assert;
use Sylius\Component\Core\Model\AddressInterface;
use Sylius\Component\Core\Model\Customer;
Expand All @@ -24,9 +23,8 @@ final class AddressBookCreateAddressApiTest extends JsonApiTestCase
*/
public function it_allows_user_to_add_new_address_to_address_book()
{
$this->loadFixturesFromFile('customer.yml');
$this->loadFixturesFromFile('country.yml');
$this->logInUser('oliver@queen.com', '123pa$$word');
$this->loadFixturesFromFiles(['customer.yml', 'country.yml']);
$this->logInUser('oliver@queen.com', '123password');

$data =
<<<EOT
Expand Down Expand Up @@ -66,9 +64,8 @@ public function it_allows_user_to_add_new_address_to_address_book()
*/
public function it_does_not_allow_user_to_add_new_address_to_address_book_without_passing_required_data()
{
$this->loadFixturesFromFile('customer.yml');
$this->loadFixturesFromFile('country.yml');
$this->logInUser('oliver@queen.com', '123pa$$word');
$this->loadFixturesFromFiles(['customer.yml', 'country.yml']);
$this->logInUser('oliver@queen.com', '123password');

$data =
<<<EOT
Expand All @@ -94,9 +91,8 @@ public function it_does_not_allow_user_to_add_new_address_to_address_book_withou
*/
public function it_does_not_allow_user_to_add_new_address_to_address_book_without_passing_correct_country_code()
{
$this->loadFixturesFromFile('customer.yml');
$this->loadFixturesFromFile('country.yml');
$this->logInUser('oliver@queen.com', '123pa$$word');
$this->loadFixturesFromFiles(['customer.yml', 'country.yml']);
$this->logInUser('oliver@queen.com', '123password');

$data =
<<<EOT
Expand All @@ -121,9 +117,8 @@ public function it_does_not_allow_user_to_add_new_address_to_address_book_withou
*/
public function it_does_not_allow_user_to_add_new_address_to_address_book_without_passing_correct_province_code()
{
$this->loadFixturesFromFile('customer.yml');
$this->loadFixturesFromFile('country.yml');
$this->logInUser('oliver@queen.com', '123pa$$word');
$this->loadFixturesFromFiles(['customer.yml', 'country.yml']);
$this->logInUser('oliver@queen.com', '123password');

$data =
<<<EOT
Expand Down
19 changes: 6 additions & 13 deletions tests/Controller/AddressBookRemoveAddressApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Tests\Sylius\ShopApiPlugin\Controller;

use Lakion\ApiTestCase\JsonApiTestCase;
use PHPUnit\Framework\Assert;
use Sylius\Component\Core\Model\AddressInterface;
use Sylius\Component\Core\Repository\AddressRepositoryInterface;
Expand All @@ -22,10 +21,8 @@ final class AddressBookRemoveAddressApiTest extends JsonApiTestCase
*/
public function it_deletes_address_from_address_book()
{
$this->loadFixturesFromFile('customer.yml');
$this->loadFixturesFromFile('country.yml');
$this->loadFixturesFromFile('address.yml');
$this->logInUser('oliver@queen.com', '123pa$$word');
$this->loadFixturesFromFiles(['customer.yml', 'country.yml', 'address.yml']);
$this->logInUser('oliver@queen.com', '123password');

/** @var AddressRepositoryInterface $addressRepository */
$addressRepository = $this->get('sylius.repository.address');
Expand All @@ -46,10 +43,8 @@ public function it_deletes_address_from_address_book()
*/
public function it_returns_bad_request_exception_if_address_has_not_been_found()
{
$this->loadFixturesFromFile('customer.yml');
$this->loadFixturesFromFile('country.yml');
$this->loadFixturesFromFile('address.yml');
$this->logInUser('oliver@queen.com', '123pa$$word');
$this->loadFixturesFromFiles(['customer.yml', 'country.yml', 'address.yml']);
$this->logInUser('oliver@queen.com', '123password');

$this->client->request('DELETE', sprintf('/shop-api/address-book/-1'), [], [], self::$acceptAndContentTypeHeader);
$response = $this->client->getResponse();
Expand All @@ -62,10 +57,8 @@ public function it_returns_bad_request_exception_if_address_has_not_been_found()
*/
public function it_validates_if_current_user_is_owner_of_address()
{
$this->loadFixturesFromFile('customer.yml');
$this->loadFixturesFromFile('country.yml');
$this->loadFixturesFromFile('address.yml');
$this->logInUser('oliver@queen.com', '123pa$$word');
$this->loadFixturesFromFiles(['customer.yml', 'country.yml', 'address.yml']);
$this->logInUser('oliver@queen.com', '123password');

/** @var AddressRepositoryInterface $addressRepository */
$addressRepository = $this->get('sylius.repository.address');
Expand Down
Loading