Skip to content

Commit

Permalink
Fixes in configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Zales0123 committed Jan 31, 2019
1 parent 0727784 commit 978ce87
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 92 deletions.
27 changes: 27 additions & 0 deletions src/Doctrine/ORM/ProductRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace Sylius\ShopApiPlugin\Doctrine\ORM;

use Sylius\Bundle\CoreBundle\Doctrine\ORM\ProductRepository as BaseProductRepository;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Core\Model\TaxonInterface;
use Doctrine\ORM\QueryBuilder;

final class ProductRepository extends BaseProductRepository
{
public function createShopListQueryBuilder(
ChannelInterface $channel,
TaxonInterface $taxon,
string $locale,
array $sorting = [],
bool $includeAllDescendants = false
): QueryBuilder {
$queryBuilder = parent::createShopListQueryBuilder($channel, $taxon, $locale, $sorting, $includeAllDescendants);

$queryBuilder->addSelect('productTaxon');

return $queryBuilder;
}
}
7 changes: 7 additions & 0 deletions src/Resources/config/app/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ sylius_customer:
customer:
classes:
controller: Sylius\ShopApiPlugin\Controller\Customer\CustomerController

sylius_product:
resources:
product:
classes:
# temporarily, until Sylius 1.4 release
repository: Sylius\ShopApiPlugin\Doctrine\ORM\ProductRepository
3 changes: 3 additions & 0 deletions tests/Application/config/packages/_sylius.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ imports:

- { resource: "@SyliusShopBundle/Resources/config/app/config.yml" }

- { resource: "@ShopApiPlugin/Resources/config/app/config.yml" }
- { resource: "@ShopApiPlugin/Resources/config/app/sylius_mailer.yml" }

parameters:
sylius_core.public_dir: '%kernel.project_dir%/public'

Expand Down
42 changes: 21 additions & 21 deletions tests/Application/config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,27 @@ security:
stateless: true
anonymous: true

sylius_shop_api_login:
pattern: "%shop_api.security.regex%/login"
stateless: true
anonymous: true
form_login:
provider: sylius_shop_user_provider
login_path: /shop-api/login_check
check_path: /shop-api/login_check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
require_previous_session: false

shop_api:
pattern: "%shop_api.security.regex%"
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
Expand Down Expand Up @@ -85,27 +106,6 @@ security:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false

sylius_shop_api_login:
pattern: "%shop_api.security.regex%/login"
stateless: true
anonymous: true
form_login:
provider: sylius_shop_user_provider
login_path: sylius_shop_api_login_check
check_path: sylius_shop_api_login_check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
require_previous_session: false

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

access_control:
- { path: "%sylius.security.admin_regex%/_partial", role: IS_AUTHENTICATED_ANONYMOUSLY, ips: [127.0.0.1, ::1] }
- { path: "%sylius.security.admin_regex%/_partial", role: ROLE_NO_ACCESS }
Expand Down
2 changes: 1 addition & 1 deletion tests/Application/config/services.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en_US
locale: en_GB
74 changes: 37 additions & 37 deletions tests/Controller/TaxonShowDetailsApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@

final class TaxonShowDetailsApiTest extends JsonApiTestCase
{
// /**
// * @test
// */
// public function it_shows_summary_of_a_chosen_taxon_with_fallback_locale_from_channel()
// {
// $this->loadFixturesFromFiles(['shop.yml']);
//
// $this->client->request('GET', '/shop-api/WEB_GB/taxons/T_SHIRTS', [], [], ['ACCEPT' => 'application/json']);
// $response = $this->client->getResponse();
//
// $this->assertResponse($response, 'taxon/one_of_taxons_response', Response::HTTP_OK);
// }
//
// /**
// * @test
// */
// public function it_shows_summary_of_a_chosen_taxon_with_strange_code()
// {
// $this->loadFixturesFromFiles(['shop.yml']);
//
// $this->client->request('GET', '/shop-api/WEB_GB/taxons/de%3Flol%3Dxd%23boom?locale=en_GB', [], [], ['ACCEPT' => 'application/json']);
// $response = $this->client->getResponse();
//
// $this->assertResponse($response, 'taxon/strange_taxon_code_response', Response::HTTP_OK);
// }
/**
* @test
*/
public function it_shows_summary_of_a_chosen_taxon_with_fallback_locale_from_channel()
{
$this->loadFixturesFromFiles(['shop.yml']);

$this->client->request('GET', '/shop-api/WEB_GB/taxons/T_SHIRTS', [], [], ['ACCEPT' => 'application/json']);
$response = $this->client->getResponse();

$this->assertResponse($response, 'taxon/one_of_taxons_response', Response::HTTP_OK);
}

/**
* @test
*/
public function it_shows_summary_of_a_chosen_taxon_with_strange_code()
{
$this->loadFixturesFromFiles(['shop.yml']);

$this->client->request('GET', '/shop-api/WEB_GB/taxons/de%3Flol%3Dxd%23boom?locale=en_GB', [], [], ['ACCEPT' => 'application/json']);
$response = $this->client->getResponse();

$this->assertResponse($response, 'taxon/strange_taxon_code_response', Response::HTTP_OK);
}

/**
* @test
Expand All @@ -47,16 +47,16 @@ public function it_shows_summary_of_a_chosen_taxon_in_different_language()
$this->assertResponse($response, 'taxon/german_one_of_taxons_response', Response::HTTP_OK);
}

// /**
// * @test
// */
// public function it_does_not_show_taxon_details_in_non_existent_channel()
// {
// $this->loadFixturesFromFiles(['shop.yml']);
//
// $this->client->request('GET', '/shop-api/SPACE_KLINGON/taxons/T_SHIRTS?locale=en_GB', [], [], ['ACCEPT' => 'application/json']);
// $response = $this->client->getResponse();
//
// $this->assertResponse($response, 'channel_has_not_been_found_response', Response::HTTP_NOT_FOUND);
// }
/**
* @test
*/
public function it_does_not_show_taxon_details_in_non_existent_channel()
{
$this->loadFixturesFromFiles(['shop.yml']);

$this->client->request('GET', '/shop-api/SPACE_KLINGON/taxons/T_SHIRTS?locale=en_GB', [], [], ['ACCEPT' => 'application/json']);
$response = $this->client->getResponse();

$this->assertResponse($response, 'channel_has_not_been_found_response', Response::HTTP_NOT_FOUND);
}
}
54 changes: 27 additions & 27 deletions tests/Controller/TaxonShowTreeApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@

final class TaxonShowTreeApiTest extends JsonApiTestCase
{
// /**
// * @test
// */
// public function it_shows_tree_of_all_taxons_with_fallback_locale_from_channel()
// {
// $this->loadFixturesFromFiles(['shop.yml']);
//
// $this->client->request('GET', '/shop-api/WEB_GB/taxons/', [], [], ['ACCEPT' => 'application/json']);
//
// $response = $this->client->getResponse();
//
// $this->assertResponse($response, 'taxon/all_taxons_response', Response::HTTP_OK);
// }
/**
* @test
*/
public function it_shows_tree_of_all_taxons_with_fallback_locale_from_channel()
{
$this->loadFixturesFromFiles(['shop.yml']);

$this->client->request('GET', '/shop-api/WEB_GB/taxons/', [], [], ['ACCEPT' => 'application/json']);

$response = $this->client->getResponse();

$this->assertResponse($response, 'taxon/all_taxons_response', Response::HTTP_OK);
}

/**
* @test
Expand All @@ -35,18 +35,18 @@ public function it_shows_tree_of_all_taxons_in_different_language()

$this->assertResponse($response, 'taxon/german_all_taxons_response', Response::HTTP_OK);
}
//
// /**
// * @test
// */
// public function it_does_not_show_taxons_tree_in_non_existent_channel()
// {
// $this->loadFixturesFromFiles(['shop.yml']);
//
// $this->client->request('GET', '/shop-api/SPACE_KLINGON/taxons/', [], [], ['ACCEPT' => 'application/json']);
//
// $response = $this->client->getResponse();
//
// $this->assertResponse($response, 'channel_has_not_been_found_response', Response::HTTP_NOT_FOUND);
// }

/**
* @test
*/
public function it_does_not_show_taxons_tree_in_non_existent_channel()
{
$this->loadFixturesFromFiles(['shop.yml']);

$this->client->request('GET', '/shop-api/SPACE_KLINGON/taxons/', [], [], ['ACCEPT' => 'application/json']);

$response = $this->client->getResponse();

$this->assertResponse($response, 'channel_has_not_been_found_response', Response::HTTP_NOT_FOUND);
}
}
4 changes: 1 addition & 3 deletions tests/DataFixtures/ORM/channel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Sylius\Component\Core\Model\Channel:
description: "Lorem ipsum"
baseCurrency: "@pound"
defaultLocale: "@locale_en_gb"
locales: ["@locale_en_gb", "@locale_de_de", "@locale_en_US"]
locales: ["@locale_en_gb", "@locale_de_de"]
color: "black"
enabled: true
taxCalculationStrategy: "order_items_based"
Expand Down Expand Up @@ -35,5 +35,3 @@ Sylius\Component\Locale\Model\Locale:
code: en_GB
locale_de_de:
code: de_DE
locale_en_US:
code: en_US
4 changes: 1 addition & 3 deletions tests/DataFixtures/ORM/shop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Sylius\Component\Core\Model\Channel:
description: "Lorem ipsum"
baseCurrency: "@pound"
defaultLocale: "@locale_en_gb"
locales: ["@locale_en_gb", "@locale_de_de", "@locale_en_us"]
locales: ["@locale_en_gb", "@locale_de_de"]
color: "black"
enabled: true
taxCalculationStrategy: "order_items_based"
Expand All @@ -33,8 +33,6 @@ Sylius\Component\Locale\Model\Locale:
code: en_GB
locale_de_de:
code: de_DE
locale_en_us:
code: en_US

Sylius\Component\Core\Model\Product:
mug:
Expand Down

0 comments on commit 978ce87

Please sign in to comment.