Skip to content

Commit

Permalink
removed deprecation before v9.0.0 release (#1801)
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmannmartin authored Apr 29, 2020
1 parent aa314e1 commit a9dd272
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 132 deletions.
4 changes: 0 additions & 4 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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%'
Expand Down
1 change: 0 additions & 1 deletion src/Controller/Front/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
{
Expand Down
28 changes: 0 additions & 28 deletions src/Form/Front/Product/ProductFilterFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,20 +26,16 @@ 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']),
],
])
->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']),
Expand Down Expand Up @@ -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;
}
}
18 changes: 9 additions & 9 deletions tests/App/Acceptance/acceptance/CartCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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');
}

/**
Expand All @@ -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');
}

/**
Expand All @@ -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');
}
Expand Down Expand Up @@ -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');
Expand Down
16 changes: 0 additions & 16 deletions tests/App/Acceptance/acceptance/PageObject/Front/CartBoxPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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} <strong class="cart__state">%itemsCount%</strong> item for <strong class="cart__state">%priceWithVat%</strong>|[2,Inf] <strong class="cart__state">%itemsCount%</strong> items for <strong class="cart__state">%priceWithVat%</strong>';
$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
Expand Down
29 changes: 1 addition & 28 deletions tests/App/Acceptance/acceptance/PageObject/Front/CartPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
*/
Expand Down Expand Up @@ -228,7 +201,7 @@ public function assertTotalPriceWithVatByProducts(array $products, int $discount
);
}

$this->assertTotalPriceWithVat($totalPrice->getAmount());
$this->assertTotalPriceWithVatRoundedByCurrency($totalPrice->getAmount());
}

/**
Expand Down
46 changes: 0 additions & 46 deletions tests/App/Test/Codeception/Helper/NumberFormatHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit a9dd272

Please sign in to comment.