From a9dd272a3831beadecfc5da9f061898a3a9e5205 Mon Sep 17 00:00:00 2001 From: Martin Grossmann Date: Wed, 29 Apr 2020 07:40:40 +0200 Subject: [PATCH] removed deprecation before v9.0.0 release (#1801) --- config/services.yaml | 4 -- src/Controller/Front/CartController.php | 1 - .../Front/Product/ProductFilterFormType.php | 28 ----------- tests/App/Acceptance/acceptance/CartCest.php | 18 ++++---- .../PageObject/Front/CartBoxPage.php | 16 ------- .../acceptance/PageObject/Front/CartPage.php | 29 +----------- .../Codeception/Helper/NumberFormatHelper.php | 46 ------------------- 7 files changed, 10 insertions(+), 132 deletions(-) diff --git a/config/services.yaml b/config/services.yaml index a2fdbb064b..d002d633d7 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -89,10 +89,6 @@ services: - '%shopsys.domain_images_dir%' tags: ['doctrine.fixture.orm'] - Shopsys\FrameworkBundle\Controller\Admin\PromoCodeController: - arguments: - $useInlineEditation: false - App\Controller\Front\ErrorController: arguments: $environment: '%kernel.environment%' diff --git a/src/Controller/Front/CartController.php b/src/Controller/Front/CartController.php index ea0182b0ce..2670fb884b 100644 --- a/src/Controller/Front/CartController.php +++ b/src/Controller/Front/CartController.php @@ -185,7 +185,6 @@ public function boxDetailAction(Request $request): Response /** * @param \App\Model\Product\Product $product * @param string $type - * @deprecated This action is deprecated since 7.3.0, use App\Controller\Front\CartController:productAction instead */ public function addProductFormAction(Product $product, $type = 'normal') { diff --git a/src/Form/Front/Product/ProductFilterFormType.php b/src/Form/Front/Product/ProductFilterFormType.php index 98a5a8c453..aacb4d2700 100644 --- a/src/Form/Front/Product/ProductFilterFormType.php +++ b/src/Form/Front/Product/ProductFilterFormType.php @@ -4,7 +4,6 @@ namespace App\Form\Front\Product; -use Shopsys\FrameworkBundle\Component\Money\Money; use Shopsys\FrameworkBundle\Form\Constraints\NotNegativeMoneyAmount; use Shopsys\FrameworkBundle\Model\Product\Filter\ProductFilterConfig; use Shopsys\FrameworkBundle\Model\Product\Filter\ProductFilterData; @@ -27,12 +26,9 @@ public function buildForm(FormBuilderInterface $builder, array $options) /** @var \Shopsys\FrameworkBundle\Model\Product\Filter\ProductFilterConfig $config */ $config = $options['product_filter_config']; - $moneyBuilder = $builder->create('money', MoneyType::class); - $builder ->add('minimalPrice', MoneyType::class, [ 'required' => false, - 'attr' => ['placeholder' => $this->transformMoneyToView($config->getPriceRange()->getMinimalPrice(), $moneyBuilder)], 'invalid_message' => 'Please enter price in correct format (positive number with decimal separator)', 'constraints' => [ new NotNegativeMoneyAmount(['message' => 'Price must be greater or equal to zero']), @@ -40,7 +36,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) ]) ->add('maximalPrice', MoneyType::class, [ 'required' => false, - 'attr' => ['placeholder' => $this->transformMoneyToView($config->getPriceRange()->getMaximalPrice(), $moneyBuilder)], 'invalid_message' => 'Please enter price in correct format (positive number with decimal separator)', 'constraints' => [ new NotNegativeMoneyAmount(['message' => 'Price must be greater or equal to zero']), @@ -85,27 +80,4 @@ public function configureOptions(OptionsResolver $resolver) 'csrf_protection' => false, ]); } - - /** - * @deprecated This method will be removed in the next major release, it is used for price range widget placeholders - * It is recommended to edit placeholders in `filterFormMacro` and set values on your own, e.g you can format - * values with price formatter - * - * @param \Shopsys\FrameworkBundle\Component\Money\Money $money - * @param \Symfony\Component\Form\FormBuilderInterface $moneyBuilder - * @return string - */ - protected function transformMoneyToView(Money $money, FormBuilderInterface $moneyBuilder): string - { - foreach ($moneyBuilder->getModelTransformers() as $modelTransformer) { - /** @var \Symfony\Component\Form\DataTransformerInterface $modelTransformer */ - $money = $modelTransformer->transform($money); - } - foreach ($moneyBuilder->getViewTransformers() as $viewTransformer) { - /** @var \Symfony\Component\Form\DataTransformerInterface $viewTransformer */ - $money = $viewTransformer->transform($money); - } - - return $money; - } } diff --git a/tests/App/Acceptance/acceptance/CartCest.php b/tests/App/Acceptance/acceptance/CartCest.php index 7847d268a6..7f27b18c2f 100644 --- a/tests/App/Acceptance/acceptance/CartCest.php +++ b/tests/App/Acceptance/acceptance/CartCest.php @@ -34,11 +34,11 @@ public function testAddingSameProductToCartMakesSum( $productDetailPage->addProductIntoCart(3); $floatingWindowPage->closeFloatingWindow(); - $cartBoxPage->seeCountAndPriceInCartBox(1, '10497'); + $cartBoxPage->seeCountAndPriceRoundedByCurrencyInCartBox(1, '10497'); $productDetailPage->addProductIntoCart(3); $floatingWindowPage->closeFloatingWindow(); - $cartBoxPage->seeCountAndPriceInCartBox(1, '20994'); + $cartBoxPage->seeCountAndPriceRoundedByCurrencyInCartBox(1, '20994'); $me->amOnLocalizedRoute('front_cart'); @@ -69,9 +69,9 @@ public function testAddToCartFromProductListPage( '%unitName%' => $me->getDefaultUnitName(), ]); $floatingWindowPage->closeFloatingWindow(); - $cartBoxPage->seeCountAndPriceInCartBox(1, '119'); + $cartBoxPage->seeCountAndPriceRoundedByCurrencyInCartBox(1, '119'); $me->amOnLocalizedRoute('front_cart'); - $cartPage->assertProductPrice('Defender 2.0 SPK-480', '119'); + $cartPage->assertProductPriceRoundedByCurrency('Defender 2.0 SPK-480', '119'); } /** @@ -97,9 +97,9 @@ public function testAddToCartFromHomepage( '%unitName%' => $me->getDefaultUnitName(), ]); $floatingWindowPage->closeFloatingWindow(); - $cartBoxPage->seeCountAndPriceInCartBox(1, '3499'); + $cartBoxPage->seeCountAndPriceRoundedByCurrencyInCartBox(1, '3499'); $me->amOnLocalizedRoute('front_cart'); - $cartPage->assertProductPrice('22" Sencor SLE 22F46DM4 HELLO KITTY', '3499'); + $cartPage->assertProductPriceRoundedByCurrency('22" Sencor SLE 22F46DM4 HELLO KITTY', '3499'); } /** @@ -125,7 +125,7 @@ public function testAddToCartFromProductDetail( '%unitName%' => $me->getDefaultUnitName(), ]); $floatingWindowPage->closeFloatingWindow(); - $cartBoxPage->seeCountAndPriceInCartBox(1, '10497'); + $cartBoxPage->seeCountAndPriceRoundedByCurrencyInCartBox(1, '10497'); $me->amOnLocalizedRoute('front_cart'); $me->seeTranslationFrontend('22" Sencor SLE 22F46DM4 HELLO KITTY', 'dataFixtures'); } @@ -209,13 +209,13 @@ public function testAddingDistinctProductsToCart( $me->amOnLocalizedRoute('front_product_detail', ['id' => 1]); $productDetailPage->addProductIntoCart(); $floatingWindowPage->closeFloatingWindow(); - $cartBoxPage->seeCountAndPriceInCartBox(1, '3499'); + $cartBoxPage->seeCountAndPriceRoundedByCurrencyInCartBox(1, '3499'); // canon-pixma-ip7250 $me->amOnLocalizedRoute('front_product_detail', ['id' => 142]); $productDetailPage->addProductIntoCart(); $floatingWindowPage->closeFloatingWindow(); - $cartBoxPage->seeCountAndPriceInCartBox(2, '27687'); + $cartBoxPage->seeCountAndPriceRoundedByCurrencyInCartBox(2, '27687'); $me->amOnLocalizedRoute('front_cart'); $cartPage->assertProductIsInCartByName('22" Sencor SLE 22F46DM4 HELLO KITTY'); diff --git a/tests/App/Acceptance/acceptance/PageObject/Front/CartBoxPage.php b/tests/App/Acceptance/acceptance/PageObject/Front/CartBoxPage.php index b26dcbd88d..9f2bf8caf0 100644 --- a/tests/App/Acceptance/acceptance/PageObject/Front/CartBoxPage.php +++ b/tests/App/Acceptance/acceptance/PageObject/Front/CartBoxPage.php @@ -9,22 +9,6 @@ class CartBoxPage extends AbstractPage { - /** - * @deprecated test is deprecated and will be removed in the next major - * - * @param int $expectedCount - * @param string $expectedPrice - */ - public function seeCountAndPriceInCartBox(int $expectedCount, string $expectedPrice): void - { - $convertedPrice = Money::create($this->tester->getPriceWithVatConvertedToDomainDefaultCurrency($expectedPrice)); - $expectedFormattedPriceWithCurrency = $this->tester->getFormattedPriceWithCurrencySymbolOnFrontend($convertedPrice); - $messageId = '{1} %itemsCount% item for %priceWithVat%|[2,Inf] %itemsCount% items for %priceWithVat%'; - $translatedMessageWithTags = tc($messageId, $expectedCount, ['%itemsCount%' => $expectedCount, '%priceWithVat%' => $expectedFormattedPriceWithCurrency], 'messages', $this->tester->getFrontendLocale()); - - $this->tester->seeInCss(strip_tags($translatedMessageWithTags), '.js-cart-info'); - } - /** * @param int $expectedCount * @param string $expectedPrice diff --git a/tests/App/Acceptance/acceptance/PageObject/Front/CartPage.php b/tests/App/Acceptance/acceptance/PageObject/Front/CartPage.php index 8651d615ea..8dd4d8c42c 100644 --- a/tests/App/Acceptance/acceptance/PageObject/Front/CartPage.php +++ b/tests/App/Acceptance/acceptance/PageObject/Front/CartPage.php @@ -21,20 +21,6 @@ public function assertProductQuantity($productName, $quantity) $this->tester->seeInFieldByElement($quantity, $quantityField); } - /** - * @deprecated test is deprecated and will be removed in the next major - * - * @param string $productName - * @param string $price - */ - public function assertProductPrice($productName, $price) - { - $convertedPrice = $this->tester->getPriceWithVatConvertedToDomainDefaultCurrency($price); - $formattedPriceWithCurrency = $this->tester->getFormattedPriceWithCurrencySymbolOnFrontend(Money::create($convertedPrice)); - $productPriceCell = $this->getProductTotalPriceCellByName($productName); - $this->tester->seeInElement($formattedPriceWithCurrency, $productPriceCell); - } - /** * @param string $productName * @param string $price @@ -47,19 +33,6 @@ public function assertProductPriceRoundedByCurrency($productName, $price) $this->tester->seeInElement($formattedPriceWithCurrency, $productPriceCell); } - /** - * @deprecated test is deprecated and will be removed in the next major - * - * @param string $price - */ - public function assertTotalPriceWithVat($price) - { - $formattedPriceWithCurrency = $this->tester->getFormattedPriceWithCurrencySymbolOnFrontend(Money::create($price)); - $orderPriceCell = $this->getTotalProductsPriceCell(); - $message = t('Total price including VAT', [], 'messages', $this->tester->getFrontendLocale()); - $this->tester->seeInElement($message . ': ' . $formattedPriceWithCurrency, $orderPriceCell); - } - /** * @param string $price */ @@ -228,7 +201,7 @@ public function assertTotalPriceWithVatByProducts(array $products, int $discount ); } - $this->assertTotalPriceWithVat($totalPrice->getAmount()); + $this->assertTotalPriceWithVatRoundedByCurrency($totalPrice->getAmount()); } /** diff --git a/tests/App/Test/Codeception/Helper/NumberFormatHelper.php b/tests/App/Test/Codeception/Helper/NumberFormatHelper.php index 00063141d5..3d36c91dcf 100644 --- a/tests/App/Test/Codeception/Helper/NumberFormatHelper.php +++ b/tests/App/Test/Codeception/Helper/NumberFormatHelper.php @@ -78,29 +78,6 @@ public function _before(TestInterface $test): void $this->rounding = $symfonyHelper->grabServiceFromContainer(Rounding::class); } - /** - * @deprecated test is deprecated and will be removed in the next major. - * - * Inspired by formatCurrency() method, {@see \Shopsys\FrameworkBundle\Twig\PriceExtension} - * @param \Shopsys\FrameworkBundle\Component\Money\Money $price - * @return string - */ - public function getFormattedPriceWithCurrencySymbolOnFrontend(Money $price): string - { - $firstDomainDefaultCurrency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId(Domain::FIRST_DOMAIN_ID); - $firstDomainLocale = $this->localizationHelper->getFrontendLocale(); - $currencyFormatter = $this->currencyFormatterFactory->create($firstDomainLocale); - - $intlCurrency = $this->intlCurrencyRepository->get($firstDomainDefaultCurrency->getCode(), $firstDomainLocale); - - $formattedPriceWithCurrencySymbol = $currencyFormatter->format( - $this->rounding->roundPriceWithVat($price)->getAmount(), - $intlCurrency->getCurrencyCode() - ); - - return $this->normalizeSpaces($formattedPriceWithCurrencySymbol); - } - /** * Inspired by formatCurrency() method, {@see \Shopsys\FrameworkBundle\Twig\PriceExtension} * @param \Shopsys\FrameworkBundle\Component\Money\Money $price @@ -122,29 +99,6 @@ public function getFormattedPriceWithCurrencySymbolRoundedByCurrencyOnFrontend(M return $this->normalizeSpaces($formattedPriceWithCurrencySymbol); } - /** - * @deprecated test is deprecated and will be removed in the next major. - * - * Inspired by formatCurrency() method, {@see \Shopsys\FrameworkBundle\Twig\PriceExtension} - * @param \Shopsys\FrameworkBundle\Component\Money\Money $price - * @return string - */ - public function getFormattedPriceOnFrontend(Money $price): string - { - $firstDomainDefaultCurrency = $this->currencyFacade->getDomainDefaultCurrencyByDomainId(Domain::FIRST_DOMAIN_ID); - $firstDomainLocale = $this->localizationHelper->getFrontendLocale(); - $currencyFormatter = $this->currencyFormatterFactory->create($firstDomainLocale); - - $intlCurrency = $this->intlCurrencyRepository->get($firstDomainDefaultCurrency->getCode(), $firstDomainLocale); - - $formattedPriceWithCurrencySymbol = $currencyFormatter->format( - $this->rounding->roundPriceWithVat($price)->getAmount(), - $intlCurrency->getCurrencyCode() - ); - - return $this->normalizeSpaces($formattedPriceWithCurrencySymbol); - } - /** * Inspired by formatCurrency() method, {@see \Shopsys\FrameworkBundle\Twig\PriceExtension} * @param \Shopsys\FrameworkBundle\Component\Money\Money $price