Skip to content

Commit

Permalink
Merge pull request #1762 from dpfaffenbauer/features/1760
Browse files Browse the repository at this point in the history
[All] remove installed translations and use symfony translations instead
  • Loading branch information
dpfaffenbauer authored Oct 29, 2021
2 parents 402329d + 53d46bd commit 7fda4fe
Show file tree
Hide file tree
Showing 45 changed files with 1,257 additions and 3,138 deletions.
12 changes: 12 additions & 0 deletions features/ui/frontend/product/view_product_via_link.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,15 @@ Feature: Viewing a product details using it's link
Then I should be on the product's detail page
Then I should see the product name "T-Shirt"

Scenario: View product via link and the same name
Given the site has a product "T-Shirt" with key "tshirt-1"
And the product is active and published and available for store "Austria"
And the site has another product "T-Shirt" with key "tshirt-2"
And the product is active and published and available for store "Austria"
When I open the page "en/t-shirt" for this product
Then I should be on the detail page for product with key "tshirt-1"
Then I should see the product name "T-Shirt"
When I open the page "en/t-shirt-1" for this product
Then I should be on the detail page for product with key "tshirt-2"
Then I should see the product name "T-Shirt"

20 changes: 19 additions & 1 deletion src/CoreShop/Behat/Context/Hook/PimcoreDaoContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Behat\Behat\Context\Context;
use CoreShop\Component\Order\Repository\OrderRepositoryInterface;
use CoreShop\Component\Resource\Model\AbstractObject;
use Doctrine\DBAL\Connection;
use Pimcore\Cache;
use Pimcore\Model\DataObject;
use Pimcore\Model\DataObject\ClassDefinition;
Expand All @@ -28,7 +29,11 @@

final class PimcoreDaoContext implements Context
{
public function __construct(private KernelInterface $kernel, private OrderRepositoryInterface $orderRepository)
public function __construct(
private KernelInterface $kernel,
private OrderRepositoryInterface $orderRepository,
private Connection $connection
)
{
}

Expand Down Expand Up @@ -151,6 +156,19 @@ public function clearBehatAdminUser(): void
}
}

/**
* @BeforeScenario
*/
public function clearSlugs(): void
{
$this->connection->executeQuery('DELETE FROM `object_url_slugs`');

$reflection = new \ReflectionClass(DataObject\Data\UrlSlug::class);
$cacheProperty = $reflection->getProperty('cache');
$cacheProperty->setAccessible(true);
$reflection->setStaticPropertyValue('cache', []);
}

/**
* @BeforeScenario
*/
Expand Down
14 changes: 14 additions & 0 deletions src/CoreShop/Behat/Context/Setup/ProductContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public function __construct(private SharedStorageInterface $sharedStorage, priva

/**
* @Given /^the site has a product "([^"]+)"$/
* @Given /^the site has another product "([^"]+)"$/
*/
public function theSiteHasAProduct(string $productName): void
{
Expand All @@ -53,6 +54,19 @@ public function theSiteHasAProduct(string $productName): void
$this->saveProduct($product);
}

/**
* @Given /^the site has a product "([^"]+)" with key "([^"]+)"$/
* @Given /^the site has another product "([^"]+)" with key "([^"]+)"$/
*/
public function theSiteHasAProductWithKey(string $productName, string $key): void
{
$product = $this->createSimpleProduct($productName);

$product->setKey($key);

$this->saveProduct($product);
}

/**
* @Given /^the (product "[^"]+") has a meta title "([^"]+)"$/
* @Given /^the (products) meta title is "([^"]+)"$/
Expand Down
27 changes: 27 additions & 0 deletions src/CoreShop/Behat/Context/Transform/ProductContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,33 @@ public function getProductByName($productName)
return $this->productRepository->forceFind($product->getId());
}

/**
* @Transform /^product with key "([^"]+)"$/
*/
public function getProductByKey($productName)
{
/**
* @var \Pimcore\Model\DataObject\Listing\Concrete $list
*/
$list = $this->productRepository->getList();
$list->setLocale('en');
$list->setObjectTypes([AbstractObject::OBJECT_TYPE_OBJECT, AbstractObject::OBJECT_TYPE_VARIANT]);
$list->setCondition('o_key = ?', [$productName]);
$list->load();

Assert::eq(
count($list->getObjects()),
1,
sprintf('%d products has been found with key "%s".', count($list->getObjects()), $productName)
);

$objects = $list->getObjects();
$product = \reset($objects);

//This is to not run into cache issues
return $this->productRepository->forceFind($product->getId());
}

/**
* @Transform /^product(?:|s) "([^"]+)" with unit "([^"]+)"$/
*/
Expand Down
1 change: 1 addition & 0 deletions src/CoreShop/Behat/Context/Ui/Frontend/ProductContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function iOpenPage($url, ProductInterface $product): void

/**
* @Then /^I should be on the (product's) detail page$/
* @Then /^I should be on the detail page for (product with key "([^"]+)")$/
*/
public function iShouldBeOnProductDetailedPage(ProductInterface $product): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ services:
arguments:
- '@kernel'
- '@coreshop.repository.order'
- '@doctrine.dbal.default_connection'
tags:
- { name: fob.context_service }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,6 @@ private function addPimcoreResourcesSection(ArrayNodeDefinition $node): void
->cannotBeOverwritten()
->defaultValue(['country', 'state', 'zone'])
->end()
->arrayNode('install')
->addDefaultsIfNotSet()
->children()
->arrayNode('admin_translations')
->treatNullLike([])
->scalarPrototype()->end()
->defaultValue(['@CoreShopAddressBundle/Resources/install/pimcore/admin-translations.yml'])
->end()
->end()
->end()
->end()
->end()
->end();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,16 @@ coreshop_address_street: 'Straße'
coreshop_address_street_number: 'Hausnummer'
coreshop_address_identifier: 'Adressen Kennung'
coreshop_countries: 'Länder'
CoreShopAddress: 'Adresse'
coreshop.address.salutation: 'Anrede'
coreshop.address.firstname: 'Vorname'
coreshop.address.lastname: 'Nachname'
coreshop.address.company: 'Firma'
coreshop.address.street: 'Straße'
coreshop.address.number: 'Nummer'
coreshop.address.post_code: 'PLZ'
coreshop.address.city: 'Stadt'
coreshop.address.country: 'Land'
coreshop.address.state: 'Bundesland/Region'
coreshop.address.phone_number: 'Telefonnummer'
coreshop.address.address_identifier: 'Adresstyp'
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,16 @@ coreshop_address_street: 'Street'
coreshop_address_street_number: 'Street Number'
coreshop_address_identifier: 'Address Identifier'
coreshop_countries: 'Countries'
CoreShopAddress: 'Address'
coreshop.address.salutation: 'Salutation'
coreshop.address.firstname: 'Firstname'
coreshop.address.lastname: 'Lastname'
coreshop.address.company: 'Company'
coreshop.address.street: 'Street'
coreshop.address.number: 'Number'
coreshop.address.post_code: 'Post Code'
coreshop.address.city: 'City'
coreshop.address.country: 'Country'
coreshop.address.state: 'State/County'
coreshop.address.phone_number: 'Phone Number'
coreshop.address.address_identifier: 'Address Identifier'
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,6 @@ private function addPimcoreResourcesSection(ArrayNodeDefinition $node): void
->useAttributeAsKey('name')
->prototype('scalar')->end()
->end()
->arrayNode('install')
->addDefaultsIfNotSet()
->children()
->arrayNode('admin_translations')
->treatNullLike([])
->scalarPrototype()->end()
->defaultValue(['@CoreShopCoreBundle/Resources/install/pimcore/admin-translations.yml'])
->end()
->end()
->end()
->end()
->end()
->end();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function checkCartAvailability(RequestEvent $event): void
return;
}

$this->session->getFlashBag()->add('coreshop_global_error', 'coreshop.global_error.cart_has_changed');
$this->session->getFlashBag()->add('coreshop_global_error', 'coreshop.ui.global_error.cart_has_changed');
$cart->setNeedsRecalculation(false);
$this->cartManager->persistCart($cart);

Expand Down
Loading

0 comments on commit 7fda4fe

Please sign in to comment.