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

[Slug] default generate slugs and use instead of static routes for product and category #1678

Merged
merged 6 commits into from
Jul 15, 2021
2 changes: 1 addition & 1 deletion features/domain/category/category_link.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Feature: In order that a customer can visit the category page
And the site has a category "Shirts"

Scenario: Create URL for product
Then the generated url for object should be "/en/shop/shirts~c%id"
Then the generated url for object should be "/en/shirts"
2 changes: 1 addition & 1 deletion features/domain/product/product_link.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Feature: In order that a customer can visit the product page
Then the product "Shoe" should be priced at "100"

Scenario: Create URL for product
Then the generated url for object should be "/en/shop/shoe~p%id"
Then the generated url for object should be "/en/shoe"
2 changes: 1 addition & 1 deletion features/ui/frontend/product/view_product_via_link.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Feature: Viewing a product details using it's link
Scenario: View product via link
Given the site has a product "T-Shirt"
And the product is active and published and available for store "Austria"
When I open the page "en/shop/t-shirt~p%id%" for this product
When I open the page "en/t-shirt" for this product
Then I should be on the product's detail page
Then I should see the product name "T-Shirt"

7 changes: 2 additions & 5 deletions src/CoreShop/Behat/Context/Cli/InstallerContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ public function commandSuccess()
*/
private function iExecuteCommandAndConfirm($name)
{
try {
$this->tester->setInputs(['y']);
$this->tester->execute(['command' => $name]);
} catch (\Exception $e) {
}
$this->tester->setInputs(['y']);
$this->tester->execute(['command' => $name]);
}
}
2 changes: 0 additions & 2 deletions src/CoreShop/Behat/Context/Domain/LinkGeneratorContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public function __construct(SharedStorageInterface $sharedStorage, LinkGenerator
public function theGeneratedUrlForObjectShouldBe(Concrete $object, $url)
{
$generatedUrl = $this->linkGenerator->generate($object, null, ['_locale' => 'en']);
$url = str_replace('%id', (string)$object->getId(), $url);

Assert::eq(
$generatedUrl,
Expand All @@ -56,7 +55,6 @@ public function theGeneratedUrlForObjectShouldBe(Concrete $object, $url)
public function theGeneratedUrlForObjectWithRouteShouldBe(Concrete $object, $routeName, $url)
{
$generatedUrl = $this->linkGenerator->generate($object, $routeName, ['_locale' => 'en']);
$url = str_replace('%id', (string)$object->getId(), $url);

Assert::eq(
$generatedUrl,
Expand Down
4 changes: 0 additions & 4 deletions src/CoreShop/Behat/Context/Ui/Domain/PaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ public function iOpenCartSummaryPage(PaymentInterface $payment)
* @var Response $result
*/
foreach ($responses as $index => $result) {
echo "Request:" . $requests[$index]->getUri() . PHP_EOL;
echo (string)$result->getBody();
echo PHP_EOL;
//
Assert::eq(
$result->getStatusCode(),
200,
Expand Down
2 changes: 0 additions & 2 deletions src/CoreShop/Behat/Context/Ui/Frontend/ProductContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public function __construct(
*/
public function iOpenPage($url, ProductInterface $product)
{
$url = str_replace('%id%', (string)$product->getId(), $url);

$this->productPage->tryToOpenWithUri($url);
}

Expand Down
5 changes: 1 addition & 4 deletions src/CoreShop/Behat/Page/Frontend/ProductPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@

class ProductPage extends AbstractFrontendPage implements ProductPageInterface
{
public function getRouteName(): string
{
return 'coreshop_product_detail';
}
use SluggablePageTrait;

public function getContent(): string
{
Expand Down
28 changes: 28 additions & 0 deletions src/CoreShop/Behat/Page/Frontend/SluggablePageTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* CoreShop.
*
* This source file is subject to the GNU General Public License version 3 (GPLv3)
* For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt
* files that are distributed with this source code.
*
* @copyright Copyright (c) 2015-2020 Dominik Pfaffenbauer (https://www.pfaffenbauer.at)
* @license https://www.coreshop.org/license GNU General Public License version 3 (GPLv3)
*/

declare(strict_types=1);

namespace CoreShop\Behat\Page\Frontend;

trait SluggablePageTrait
{
public function getRouteName(): string
{
throw new \InvalidArgumentException('Not supported here');
}

protected function getUrl(array $urlParameters = []): string
{
throw new \InvalidArgumentException('Not supported here');
}
}
163 changes: 0 additions & 163 deletions src/CoreShop/Bundle/CoreBundle/Faker/Commerce.php

This file was deleted.

Loading