diff --git a/app/code/Magento/Paypal/Controller/Adminhtml/Billing/Agreement/Index.php b/app/code/Magento/Paypal/Controller/Adminhtml/Billing/Agreement/Index.php
index b4c68df6e29e0..ca92b6a044fa7 100644
--- a/app/code/Magento/Paypal/Controller/Adminhtml/Billing/Agreement/Index.php
+++ b/app/code/Magento/Paypal/Controller/Adminhtml/Billing/Agreement/Index.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Paypal\Controller\Adminhtml\Billing\Agreement;
-class Index extends \Magento\Paypal\Controller\Adminhtml\Billing\Agreement
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Index extends \Magento\Paypal\Controller\Adminhtml\Billing\Agreement implements HttpGetActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Paypal/Controller/Adminhtml/Paypal/Reports/Index.php b/app/code/Magento/Paypal/Controller/Adminhtml/Paypal/Reports/Index.php
index 91f3e8d9065b9..c2cee0ffbc67a 100644
--- a/app/code/Magento/Paypal/Controller/Adminhtml/Paypal/Reports/Index.php
+++ b/app/code/Magento/Paypal/Controller/Adminhtml/Paypal/Reports/Index.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Paypal\Controller\Adminhtml\Paypal\Reports;
-class Index extends \Magento\Paypal\Controller\Adminhtml\Paypal\Reports
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Index extends \Magento\Paypal\Controller\Adminhtml\Paypal\Reports implements HttpGetActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Paypal/Controller/Express/GetToken.php b/app/code/Magento/Paypal/Controller/Express/GetToken.php
index 7c127803cb0b1..93e9abb4c097e 100644
--- a/app/code/Magento/Paypal/Controller/Express/GetToken.php
+++ b/app/code/Magento/Paypal/Controller/Express/GetToken.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Paypal\Controller\Express;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Checkout\Helper\Data;
use Magento\Checkout\Helper\ExpressRedirect;
use Magento\Checkout\Model\Type\Onepage;
@@ -19,7 +20,7 @@
* Class GetToken
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class GetToken extends AbstractExpress
+class GetToken extends AbstractExpress implements HttpGetActionInterface
{
/**
* Config mode type
diff --git a/app/code/Magento/Paypal/Controller/Express/Start.php b/app/code/Magento/Paypal/Controller/Express/Start.php
index e0a3c5381be59..b381c413071a7 100644
--- a/app/code/Magento/Paypal/Controller/Express/Start.php
+++ b/app/code/Magento/Paypal/Controller/Express/Start.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Paypal\Controller\Express;
-class Start extends \Magento\Paypal\Controller\Express\AbstractExpress\Start
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Start extends \Magento\Paypal\Controller\Express\AbstractExpress\Start implements HttpGetActionInterface
{
/**
* Config mode type
diff --git a/app/code/Magento/Paypal/Controller/Payflowexpress/Start.php b/app/code/Magento/Paypal/Controller/Payflowexpress/Start.php
index a6fbcfd0239b4..4615320c9455f 100644
--- a/app/code/Magento/Paypal/Controller/Payflowexpress/Start.php
+++ b/app/code/Magento/Paypal/Controller/Payflowexpress/Start.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Paypal\Controller\Payflowexpress;
-class Start extends \Magento\Paypal\Controller\Express\AbstractExpress\Start
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Start extends \Magento\Paypal\Controller\Express\AbstractExpress\Start implements HttpGetActionInterface
{
/**
* Config mode type
diff --git a/app/code/Magento/Paypal/Controller/Transparent/RequestSecureToken.php b/app/code/Magento/Paypal/Controller/Transparent/RequestSecureToken.php
index 2efae34a96459..85907c9d371ab 100644
--- a/app/code/Magento/Paypal/Controller/Transparent/RequestSecureToken.php
+++ b/app/code/Magento/Paypal/Controller/Transparent/RequestSecureToken.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Paypal\Controller\Transparent;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Framework\App\Action\Context;
use Magento\Framework\Controller\Result\Json;
use Magento\Framework\Controller\Result\JsonFactory;
@@ -21,7 +22,7 @@
* @package Magento\Paypal\Controller\Transparent
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class RequestSecureToken extends \Magento\Framework\App\Action\Action
+class RequestSecureToken extends \Magento\Framework\App\Action\Action implements HttpPostActionInterface
{
/**
* @var JsonFactory
diff --git a/app/code/Magento/Paypal/Model/Express/Checkout.php b/app/code/Magento/Paypal/Model/Express/Checkout.php
index 16bcac300de97..1300c79368943 100644
--- a/app/code/Magento/Paypal/Model/Express/Checkout.php
+++ b/app/code/Magento/Paypal/Model/Express/Checkout.php
@@ -17,7 +17,7 @@
/**
* Wrapper that performs Paypal Express and Checkout communication
- * Use current Paypal Express method instance
+ *
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -26,6 +26,7 @@ class Checkout
{
/**
* Cache ID prefix for "pal" lookup
+ *
* @var string
*/
const PAL_CACHE_ID = 'paypal_express_checkout_pal';
@@ -367,6 +368,7 @@ public function __construct(
/**
* Checkout with PayPal image URL getter
+ *
* Spares API calls of getting "pal" variable, by putting it into cache per store view
*
* @return string
@@ -599,8 +601,8 @@ public function canSkipOrderReviewStep()
/**
* Update quote when returned from PayPal
- * rewrite billing address by paypal
- * save old billing address for new customer
+ *
+ * Rewrite billing address by paypal, save old billing address for new customer, and
* export shipping address in case address absence
*
* @param string $token
@@ -616,14 +618,15 @@ public function returnFromPaypal($token)
$this->ignoreAddressValidation();
+ // check if we came from the Express Checkout button
+ $isButton = (bool)$quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_BUTTON);
+
// import shipping address
$exportedShippingAddress = $this->_getApi()->getExportedShippingAddress();
if (!$quote->getIsVirtual()) {
$shippingAddress = $quote->getShippingAddress();
if ($shippingAddress) {
- if ($exportedShippingAddress
- && $quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_BUTTON) == 1
- ) {
+ if ($exportedShippingAddress && $isButton) {
$this->_setExportedAddressData($shippingAddress, $exportedShippingAddress);
// PayPal doesn't provide detailed shipping info: prefix, middlename, lastname, suffix
$shippingAddress->setPrefix(null);
@@ -651,12 +654,11 @@ public function returnFromPaypal($token)
}
// import billing address
- $portBillingFromShipping = $quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_BUTTON) == 1
- && $this->_config->getValue(
- 'requireBillingAddress'
- ) != \Magento\Paypal\Model\Config::REQUIRE_BILLING_ADDRESS_ALL
- && !$quote->isVirtual();
- if ($portBillingFromShipping) {
+ $requireBillingAddress = (int)$this->_config->getValue(
+ 'requireBillingAddress'
+ ) === \Magento\Paypal\Model\Config::REQUIRE_BILLING_ADDRESS_ALL;
+
+ if ($isButton && !$requireBillingAddress && !$quote->isVirtual()) {
$billingAddress = clone $shippingAddress;
$billingAddress->unsAddressId()->unsAddressType()->setCustomerAddressId(null);
$data = $billingAddress->getData();
@@ -664,11 +666,17 @@ public function returnFromPaypal($token)
$quote->getBillingAddress()->addData($data);
$quote->getShippingAddress()->setSameAsBilling(1);
} else {
- $billingAddress = $quote->getBillingAddress();
+ $billingAddress = $quote->getBillingAddress()->setCustomerAddressId(null);
}
$exportedBillingAddress = $this->_getApi()->getExportedBillingAddress();
- $this->_setExportedAddressData($billingAddress, $exportedBillingAddress);
+ // Since country is required field for billing and shipping address,
+ // we consider the address information to be empty if country is empty.
+ $isEmptyAddress = ($billingAddress->getCountryId() === null);
+
+ if ($requireBillingAddress || $isEmptyAddress) {
+ $this->_setExportedAddressData($billingAddress, $exportedBillingAddress);
+ }
$billingAddress->setCustomerNote($exportedBillingAddress->getData('note'));
$quote->setBillingAddress($billingAddress);
$quote->setCheckoutMethod($this->getCheckoutMethod());
@@ -904,17 +912,6 @@ public function getCheckoutMethod()
*/
protected function _setExportedAddressData($address, $exportedAddress)
{
- // Exported data is more priority if we came from Express Checkout button
- $isButton = (bool)$this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_BUTTON);
-
- // Since country is required field for billing and shipping address,
- // we consider the address information to be empty if country is empty.
- $isEmptyAddress = ($address->getCountryId() === null);
-
- if (!$isButton && !$isEmptyAddress) {
- return;
- }
-
foreach ($exportedAddress->getExportedKeys() as $key) {
$data = $exportedAddress->getData($key);
if (!empty($data)) {
@@ -951,6 +948,8 @@ protected function _setBillingAgreementRequest()
}
/**
+ * Get api
+ *
* @return \Magento\Paypal\Model\Api\Nvp
*/
protected function _getApi()
@@ -963,8 +962,9 @@ protected function _getApi()
/**
* Attempt to collect address shipping rates and return them for further usage in instant update API
- * Returns empty array if it was impossible to obtain any shipping rate
- * If there are shipping rates obtained, the method must return one of them as default.
+ *
+ * Returns empty array if it was impossible to obtain any shipping rate and
+ * if there are shipping rates obtained, the method must return one of them as default.
*
* @param Address $address
* @param bool $mayReturnEmpty
@@ -1048,8 +1048,8 @@ protected function _prepareShippingOptions(Address $address, $mayReturnEmpty = f
* Compare two shipping options based on their amounts
*
* This function is used as a callback comparison function in shipping options sorting process
- * @see self::_prepareShippingOptions()
*
+ * @see self::_prepareShippingOptions()
* @param \Magento\Framework\DataObject $option1
* @param \Magento\Framework\DataObject $option2
* @return int
@@ -1064,6 +1064,7 @@ protected static function cmpShippingOptions(DataObject $option1, DataObject $op
/**
* Try to find whether the code provided by PayPal corresponds to any of possible shipping rates
+ *
* This method was created only because PayPal has issues with returning the selected code.
* If in future the issue is fixed, we don't need to attempt to match it. It would be enough to set the method code
* before collecting shipping rates
@@ -1089,6 +1090,7 @@ protected function _matchShippingMethodCode(Address $address, $selectedCode)
/**
* Create payment redirect url
+ *
* @param bool|null $button
* @param string $token
* @return void
@@ -1112,6 +1114,7 @@ public function getCustomerSession()
/**
* Set shipping options to api
+ *
* @param \Magento\Paypal\Model\Cart $cart
* @param \Magento\Quote\Model\Quote\Address|null $address
* @return void
diff --git a/app/code/Magento/ProductVideo/Controller/Adminhtml/Product/Gallery/RetrieveImage.php b/app/code/Magento/ProductVideo/Controller/Adminhtml/Product/Gallery/RetrieveImage.php
index 23721cb4b1658..914b5fa271717 100644
--- a/app/code/Magento/ProductVideo/Controller/Adminhtml/Product/Gallery/RetrieveImage.php
+++ b/app/code/Magento/ProductVideo/Controller/Adminhtml/Product/Gallery/RetrieveImage.php
@@ -6,6 +6,7 @@
namespace Magento\ProductVideo\Controller\Adminhtml\Product\Gallery;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\File\Uploader;
@@ -13,7 +14,7 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class RetrieveImage extends \Magento\Backend\App\Action
+class RetrieveImage extends \Magento\Backend\App\Action implements HttpPostActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Quote/Model/MaskedQuoteIdToQuoteId.php b/app/code/Magento/Quote/Model/MaskedQuoteIdToQuoteId.php
index f30d98342beba..37a8fcd494fba 100644
--- a/app/code/Magento/Quote/Model/MaskedQuoteIdToQuoteId.php
+++ b/app/code/Magento/Quote/Model/MaskedQuoteIdToQuoteId.php
@@ -10,6 +10,9 @@
use Magento\Quote\Api\CartRepositoryInterface;
use Magento\Quote\Model\ResourceModel\Quote\QuoteIdMask as QuoteIdMaskResource;
+/**
+ * MaskedQuoteId to QuoteId resolver
+ */
class MaskedQuoteIdToQuoteId implements MaskedQuoteIdToQuoteIdInterface
{
/**
diff --git a/app/code/Magento/Quote/Model/QuoteIdToMaskedQuoteId.php b/app/code/Magento/Quote/Model/QuoteIdToMaskedQuoteId.php
index 5ddadfc22f57d..2e802f47cfefe 100644
--- a/app/code/Magento/Quote/Model/QuoteIdToMaskedQuoteId.php
+++ b/app/code/Magento/Quote/Model/QuoteIdToMaskedQuoteId.php
@@ -8,29 +8,40 @@
namespace Magento\Quote\Model;
use Magento\Quote\Api\CartRepositoryInterface;
+use Magento\Quote\Model\ResourceModel\Quote\QuoteIdMask as QuoteIdMaskResource;
+/**
+ * QuoteId to MaskedQuoteId resolver
+ */
class QuoteIdToMaskedQuoteId implements QuoteIdToMaskedQuoteIdInterface
{
/**
* @var QuoteIdMaskFactory
*/
private $quoteIdMaskFactory;
-
/**
* @var CartRepositoryInterface
*/
private $cartRepository;
+ /**
+ * @var QuoteIdMaskResource
+ */
+ private $quoteIdMaskResource;
+
/**
* @param QuoteIdMaskFactory $quoteIdMaskFactory
* @param CartRepositoryInterface $cartRepository
+ * @param QuoteIdMaskResource $quoteIdMaskResource
*/
public function __construct(
QuoteIdMaskFactory $quoteIdMaskFactory,
- CartRepositoryInterface $cartRepository
+ CartRepositoryInterface $cartRepository,
+ QuoteIdMaskResource $quoteIdMaskResource
) {
$this->quoteIdMaskFactory = $quoteIdMaskFactory;
$this->cartRepository = $cartRepository;
+ $this->quoteIdMaskResource = $quoteIdMaskResource;
}
/**
@@ -42,8 +53,9 @@ public function execute(int $quoteId): string
$this->cartRepository->get($quoteId);
$quoteIdMask = $this->quoteIdMaskFactory->create();
- $quoteIdMask->setQuoteId($quoteId)->save();
+ $this->quoteIdMaskResource->load($quoteIdMask, $quoteId, 'quote_id');
+ $maskedId = $quoteIdMask->getMaskedId() ?? '';
- return $quoteIdMask->getMaskedId();
+ return $maskedId;
}
}
diff --git a/app/code/Magento/Quote/Model/QuoteValidator.php b/app/code/Magento/Quote/Model/QuoteValidator.php
index 04d6d4ecba160..062cf76bcaa1a 100644
--- a/app/code/Magento/Quote/Model/QuoteValidator.php
+++ b/app/code/Magento/Quote/Model/QuoteValidator.php
@@ -6,14 +6,17 @@
namespace Magento\Quote\Model;
-use Magento\Framework\Exception\LocalizedException;
-use Magento\Quote\Model\Quote as QuoteEntity;
use Magento\Directory\Model\AllowedCountries;
use Magento\Framework\App\ObjectManager;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\Message\Error;
+use Magento\Quote\Model\Quote as QuoteEntity;
use Magento\Quote\Model\Quote\Validator\MinimumOrderAmount\ValidationMessage as OrderAmountValidationMessage;
use Magento\Quote\Model\ValidationRules\QuoteValidationRuleInterface;
/**
+ * Class to validate the quote
+ *
* @api
* @since 100.0.2
*/
@@ -72,18 +75,24 @@ public function validateQuoteAmount(QuoteEntity $quote, $amount)
$quote->setHasError(true);
$quote->addMessage(__('This item price or quantity is not valid for checkout.'));
}
+
return $this;
}
/**
- * Validate quote before submit
+ * Validates quote before submit.
*
* @param Quote $quote
* @return $this
- * @throws \Magento\Framework\Exception\LocalizedException
+ * @throws LocalizedException
*/
public function validateBeforeSubmit(QuoteEntity $quote)
{
+ if ($quote->getHasError()) {
+ $errors = $this->getQuoteErrors($quote);
+ throw new LocalizedException(__($errors ?: 'Something went wrong. Please try to place the order again.'));
+ }
+
foreach ($this->quoteValidationRule->validate($quote) as $validationResult) {
if ($validationResult->isValid()) {
continue;
@@ -101,4 +110,22 @@ public function validateBeforeSubmit(QuoteEntity $quote)
return $this;
}
+
+ /**
+ * Parses quote error messages and concatenates them into single string.
+ *
+ * @param Quote $quote
+ * @return string
+ */
+ private function getQuoteErrors(QuoteEntity $quote): string
+ {
+ $errors = array_map(
+ function (Error $error) {
+ return $error->getText();
+ },
+ $quote->getErrors()
+ );
+
+ return implode(PHP_EOL, $errors);
+ }
}
diff --git a/app/code/Magento/QuoteGraphQl/Model/Authorization/IsCartMutationAllowedForCurrentUser.php b/app/code/Magento/QuoteGraphQl/Model/Authorization/IsCartMutationAllowedForCurrentUser.php
new file mode 100644
index 0000000000000..2dec8c278800b
--- /dev/null
+++ b/app/code/Magento/QuoteGraphQl/Model/Authorization/IsCartMutationAllowedForCurrentUser.php
@@ -0,0 +1,67 @@
+userContext = $userContext;
+ $this->cartRepository = $cartRepository;
+ }
+
+ /**
+ * Check that the shopping cart operations are allowed for current user
+ *
+ * @param int $quoteId
+ * @return bool
+ * @throws GraphQlNoSuchEntityException
+ */
+ public function execute(int $quoteId): bool
+ {
+ try {
+ $quote = $this->cartRepository->get($quoteId);
+ } catch (NoSuchEntityException $exception) {
+ throw new GraphQlNoSuchEntityException(__($exception->getMessage()));
+ }
+
+ $customerId = $quote->getCustomerId();
+
+ /* Guest cart, allow operations */
+ if (!$customerId) {
+ return true;
+ }
+
+ /* If the quote belongs to the current customer allow operations */
+ return $customerId == $this->userContext->getUserId();
+ }
+}
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php
index fcf23dd9f682b..78f9638313293 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php
@@ -14,6 +14,7 @@
use Magento\Quote\Api\CartManagementInterface;
use Magento\Quote\Api\GuestCartManagementInterface;
use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface;
+use Magento\Quote\Model\QuoteIdMaskFactory;
/**
* @inheritdoc
@@ -24,7 +25,6 @@ class CreateEmptyCart implements ResolverInterface
* @var CartManagementInterface
*/
private $cartManagement;
-
/**
* @var GuestCartManagementInterface
*/
@@ -40,22 +40,30 @@ class CreateEmptyCart implements ResolverInterface
*/
private $userContext;
+ /**
+ * @var QuoteIdMaskFactory
+ */
+ private $quoteIdMaskFactory;
+
/**
* @param CartManagementInterface $cartManagement
* @param GuestCartManagementInterface $guestCartManagement
* @param UserContextInterface $userContext
* @param QuoteIdToMaskedQuoteIdInterface $quoteIdToMaskedId
+ * @param QuoteIdMaskFactory $quoteIdMaskFactory
*/
public function __construct(
CartManagementInterface $cartManagement,
GuestCartManagementInterface $guestCartManagement,
UserContextInterface $userContext,
- QuoteIdToMaskedQuoteIdInterface $quoteIdToMaskedId
+ QuoteIdToMaskedQuoteIdInterface $quoteIdToMaskedId,
+ QuoteIdMaskFactory $quoteIdMaskFactory
) {
$this->cartManagement = $cartManagement;
$this->guestCartManagement = $guestCartManagement;
$this->userContext = $userContext;
$this->quoteIdToMaskedId = $quoteIdToMaskedId;
+ $this->quoteIdMaskFactory = $quoteIdMaskFactory;
}
/**
@@ -67,7 +75,13 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
if (0 !== $customerId && null !== $customerId) {
$quoteId = $this->cartManagement->createEmptyCartForCustomer($customerId);
- $maskedQuoteId = $this->quoteIdToMaskedId->execute($quoteId);
+ $maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$quoteId);
+
+ if (empty($maskedQuoteId)) {
+ $quoteIdMask = $this->quoteIdMaskFactory->create();
+ $quoteIdMask->setQuoteId($quoteId)->save();
+ $maskedQuoteId = $quoteIdMask->getMaskedId();
+ }
} else {
$maskedQuoteId = $this->guestCartManagement->createEmptyCart();
}
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/Coupon/ApplyCouponToCart.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/Coupon/ApplyCouponToCart.php
new file mode 100644
index 0000000000000..ab57b8ff499c6
--- /dev/null
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/Coupon/ApplyCouponToCart.php
@@ -0,0 +1,110 @@
+couponManagement = $couponManagement;
+ $this->maskedQuoteIdToQuoteId = $maskedQuoteIdToId;
+ $this->isCartMutationAllowedForCurrentUser = $isCartMutationAllowedForCurrentUser;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
+ {
+ if (!isset($args['input']['cart_id'])) {
+ throw new GraphQlInputException(__('Required parameter "cart_id" is missing'));
+ }
+ $maskedCartId = $args['input']['cart_id'];
+
+ if (!isset($args['input']['coupon_code'])) {
+ throw new GraphQlInputException(__('Required parameter "coupon_code" is missing'));
+ }
+ $couponCode = $args['input']['coupon_code'];
+
+ try {
+ $cartId = $this->maskedQuoteIdToQuoteId->execute($maskedCartId);
+ } catch (NoSuchEntityException $exception) {
+ throw new GraphQlNoSuchEntityException(
+ __('Could not find a cart with ID "%masked_cart_id"', ['masked_cart_id' => $maskedCartId])
+ );
+ }
+
+ if (false === $this->isCartMutationAllowedForCurrentUser->execute($cartId)) {
+ throw new GraphQlAuthorizationException(
+ __(
+ 'The current user cannot perform operations on cart "%masked_cart_id"',
+ ['masked_cart_id' => $maskedCartId]
+ )
+ );
+ }
+
+ /* Check current cart does not have coupon code applied */
+ $appliedCouponCode = $this->couponManagement->get($cartId);
+ if (!empty($appliedCouponCode)) {
+ throw new GraphQlInputException(
+ __('A coupon is already applied to the cart. Please remove it to apply another')
+ );
+ }
+
+ try {
+ $this->couponManagement->set($cartId, $couponCode);
+ } catch (NoSuchEntityException $exception) {
+ throw new GraphQlNoSuchEntityException(__($exception->getMessage()));
+ } catch (CouldNotSaveException $exception) {
+ throw new GraphQlInputException(__($exception->getMessage()));
+ }
+
+ $data['cart']['applied_coupon'] = [
+ 'code' => $couponCode,
+ ];
+ return $data;
+ }
+}
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/Coupon/RemoveCouponFromCart.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/Coupon/RemoveCouponFromCart.php
new file mode 100644
index 0000000000000..abb5a0b57519b
--- /dev/null
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/Coupon/RemoveCouponFromCart.php
@@ -0,0 +1,97 @@
+couponManagement = $couponManagement;
+ $this->isCartMutationAllowedForCurrentUser = $isCartMutationAllowedForCurrentUser;
+ $this->maskedQuoteIdToId = $maskedQuoteIdToId;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
+ {
+ if (!isset($args['input']['cart_id'])) {
+ throw new GraphQlInputException(__('Required parameter "cart_id" is missing'));
+ }
+ $maskedCartId = $args['input']['cart_id'];
+
+ try {
+ $cartId = $this->maskedQuoteIdToId->execute($maskedCartId);
+ } catch (NoSuchEntityException $exception) {
+ throw new GraphQlNoSuchEntityException(
+ __('Could not find a cart with ID "%masked_cart_id"', ['masked_cart_id' => $maskedCartId])
+ );
+ }
+
+ if (false === $this->isCartMutationAllowedForCurrentUser->execute($cartId)) {
+ throw new GraphQlAuthorizationException(
+ __(
+ 'The current user cannot perform operations on cart "%masked_cart_id"',
+ ['masked_cart_id' => $maskedCartId]
+ )
+ );
+ }
+
+ try {
+ $this->couponManagement->remove($cartId);
+ } catch (NoSuchEntityException $exception) {
+ throw new GraphQlNoSuchEntityException(__($exception->getMessage()));
+ } catch (CouldNotDeleteException $exception) {
+ throw new GraphQlInputException(__($exception->getMessage()));
+ }
+
+ $data['cart']['applied_coupon'] = [
+ 'code' => '',
+ ];
+ return $data;
+ }
+}
diff --git a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
index 46d1b97d0aea2..06b3328b9e058 100644
--- a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
@@ -3,4 +3,35 @@
type Mutation {
createEmptyCart: String @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\Cart\\CreateEmptyCart") @doc(description:"Creates empty shopping cart for guest or logged in user")
+ applyCouponToCart(input: ApplyCouponToCartInput): ApplyCouponToCartOutput @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\Coupon\\ApplyCouponToCart")
+ removeCouponFromCart(input: RemoveCouponFromCartInput): RemoveCouponFromCartOutput @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\Coupon\\RemoveCouponFromCart")
}
+
+input ApplyCouponToCartInput {
+ cart_id: String!
+ coupon_code: String!
+}
+
+type ApplyCouponToCartOutput {
+ cart: Cart!
+}
+
+type Cart {
+ applied_coupon: AppliedCoupon
+}
+
+type CartAddress {
+ applied_coupon: AppliedCoupon
+}
+
+type AppliedCoupon {
+ code: String!
+}
+
+input RemoveCouponFromCartInput {
+ cart_id: String!
+}
+
+type RemoveCouponFromCartOutput {
+ cart: Cart
+}
\ No newline at end of file
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php b/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php
index be7dfa70efbb4..2ff87237222f0 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Grid/AbstractGrid.php
@@ -3,8 +3,12 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
namespace Magento\Reports\Block\Adminhtml\Grid;
+/**
+ * Backend reports grid
+ */
class AbstractGrid extends \Magento\Backend\Block\Widget\Grid\Extended
{
/**
@@ -90,9 +94,8 @@ protected function _construct()
/**
* Get resource collection name
*
- * @codeCoverageIgnore
- *
* @return string
+ * @codeCoverageIgnore
*/
public function getResourceCollectionName()
{
@@ -100,6 +103,8 @@ public function getResourceCollectionName()
}
/**
+ * Return reports collection
+ *
* @return \Magento\Framework\Data\Collection
*/
public function getCollection()
@@ -111,6 +116,8 @@ public function getCollection()
}
/**
+ * Retrieve array of columns that should be aggregated
+ *
* @return array
*/
protected function _getAggregatedColumns()
@@ -170,12 +177,7 @@ public function addColumn($columnId, $column)
*/
protected function _getStoreIds()
{
- $filterData = $this->getFilterData();
- if ($filterData) {
- $storeIds = explode(',', $filterData->getData('store_ids'));
- } else {
- $storeIds = [];
- }
+ $storeIds = $this->getFilteredStores();
// By default storeIds array contains only allowed stores
$allowedStoreIds = array_keys($this->_storeManager->getStores());
// And then array_intersect with post data for prevent unauthorized stores reports
@@ -191,6 +193,8 @@ protected function _getStoreIds()
}
/**
+ * Apply sorting and filtering to collection
+ *
* @return $this|\Magento\Backend\Block\Widget\Grid
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
@@ -280,6 +284,8 @@ protected function _prepareCollection()
}
/**
+ * Return count totals
+ *
* @return array
*/
public function getCountTotals()
@@ -319,6 +325,8 @@ public function getCountTotals()
}
/**
+ * Retrieve subtotal items
+ *
* @return array
*/
public function getSubTotals()
@@ -360,6 +368,8 @@ public function setStoreIds($storeIds)
}
/**
+ * Return current currency code
+ *
* @return string|\Magento\Directory\Model\Currency $currencyCode
*/
public function getCurrentCurrencyCode()
@@ -399,6 +409,7 @@ protected function _addOrderStatusFilter($collection, $filterData)
/**
* Adds custom filter to resource collection
+ *
* Can be overridden in child classes if custom filter needed
*
* @param \Magento\Reports\Model\ResourceModel\Report\Collection\AbstractCollection $collection
@@ -411,4 +422,35 @@ protected function _addCustomFilter($collection, $filterData)
{
return $this;
}
+
+ /**
+ * Return stores by website, group and store id
+ *
+ * @return array
+ * @throws \Magento\Framework\Exception\LocalizedException
+ */
+ private function getFilteredStores(): array
+ {
+ $storeIds = [];
+
+ $filterData = $this->getFilterData();
+ if ($filterData) {
+ if ($filterData->getWebsite()) {
+ $storeIds = array_keys(
+ $this->_storeManager->getWebsite($filterData->getWebsite())->getStores()
+ );
+ }
+
+ if ($filterData->getGroup()) {
+ $storeIds = array_keys(
+ $this->_storeManager->getGroup($filterData->getGroup())->getStores()
+ );
+ }
+
+ if ($filterData->getData('store_ids')) {
+ $storeIds = explode(',', $filterData->getData('store_ids'));
+ }
+ }
+ return is_array($storeIds) ? $storeIds : [];
+ }
}
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php
index 21836f1a8c276..9f5f784df677f 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Sales/Sales/Grid.php
@@ -6,6 +6,8 @@
namespace Magento\Reports\Block\Adminhtml\Sales\Sales;
+use Magento\Reports\Block\Adminhtml\Grid\Column\Renderer\Currency;
+
/**
* Adminhtml sales report grid block
*
@@ -22,7 +24,8 @@ class Grid extends \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid
protected $_columnGroupBy = 'period';
/**
- * {@inheritdoc}
+ * Reports grid constructor
+ *
* @codeCoverageIgnore
*/
protected function _construct()
@@ -32,17 +35,19 @@ protected function _construct()
}
/**
- * {@inheritdoc}
+ * Return collection name based on report_type
+ *
+ * @return string
*/
public function getResourceCollectionName()
{
- return $this->getFilterData()->getData('report_type') == 'updated_at_order'
+ return $this->getFilterData()->getData('report_type') === 'updated_at_order'
? \Magento\Sales\Model\ResourceModel\Report\Order\Updatedat\Collection::class
: \Magento\Sales\Model\ResourceModel\Report\Order\Collection::class;
}
/**
- * {@inheritdoc}
+ * Initialize reports grid columns
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
@@ -103,9 +108,7 @@ protected function _prepareColumns()
]
);
- if ($this->getFilterData()->getStoreIds()) {
- $this->setStoreIds(explode(',', $this->getFilterData()->getStoreIds()));
- }
+ $this->setStoreIds($this->_getStoreIds());
$currencyCode = $this->getCurrentCurrencyCode();
$rate = $this->getRate($currencyCode);
@@ -118,6 +121,7 @@ protected function _prepareColumns()
'index' => 'total_income_amount',
'total' => 'sum',
'sortable' => false,
+ 'renderer' => Currency::class,
'rate' => $rate,
'header_css_class' => 'col-sales-total',
'column_css_class' => 'col-sales-total'
@@ -133,6 +137,7 @@ protected function _prepareColumns()
'index' => 'total_revenue_amount',
'total' => 'sum',
'sortable' => false,
+ 'renderer' => Currency::class,
'visibility_filter' => ['show_actual_columns'],
'rate' => $rate,
'header_css_class' => 'col-revenue',
@@ -149,6 +154,7 @@ protected function _prepareColumns()
'index' => 'total_profit_amount',
'total' => 'sum',
'sortable' => false,
+ 'renderer' => Currency::class,
'visibility_filter' => ['show_actual_columns'],
'rate' => $rate,
'header_css_class' => 'col-profit',
@@ -165,6 +171,7 @@ protected function _prepareColumns()
'index' => 'total_invoiced_amount',
'total' => 'sum',
'sortable' => false,
+ 'renderer' => Currency::class,
'rate' => $rate,
'header_css_class' => 'col-invoiced',
'column_css_class' => 'col-invoiced'
@@ -180,6 +187,7 @@ protected function _prepareColumns()
'index' => 'total_paid_amount',
'total' => 'sum',
'sortable' => false,
+ 'renderer' => Currency::class,
'visibility_filter' => ['show_actual_columns'],
'rate' => $rate,
'header_css_class' => 'col-paid',
@@ -196,6 +204,7 @@ protected function _prepareColumns()
'index' => 'total_refunded_amount',
'total' => 'sum',
'sortable' => false,
+ 'renderer' => Currency::class,
'rate' => $rate,
'header_css_class' => 'col-refunded',
'column_css_class' => 'col-refunded'
@@ -211,6 +220,7 @@ protected function _prepareColumns()
'index' => 'total_tax_amount',
'total' => 'sum',
'sortable' => false,
+ 'renderer' => Currency::class,
'rate' => $rate,
'header_css_class' => 'col-sales-tax',
'column_css_class' => 'col-sales-tax'
@@ -226,6 +236,7 @@ protected function _prepareColumns()
'index' => 'total_tax_amount_actual',
'total' => 'sum',
'sortable' => false,
+ 'renderer' => Currency::class,
'visibility_filter' => ['show_actual_columns'],
'rate' => $rate,
'header_css_class' => 'col-tax',
@@ -242,6 +253,7 @@ protected function _prepareColumns()
'index' => 'total_shipping_amount',
'total' => 'sum',
'sortable' => false,
+ 'renderer' => Currency::class,
'rate' => $rate,
'header_css_class' => 'col-sales-shipping',
'column_css_class' => 'col-sales-shipping'
@@ -257,6 +269,7 @@ protected function _prepareColumns()
'index' => 'total_shipping_amount_actual',
'total' => 'sum',
'sortable' => false,
+ 'renderer' => Currency::class,
'visibility_filter' => ['show_actual_columns'],
'rate' => $rate,
'header_css_class' => 'col-shipping',
@@ -273,6 +286,7 @@ protected function _prepareColumns()
'index' => 'total_discount_amount',
'total' => 'sum',
'sortable' => false,
+ 'renderer' => Currency::class,
'rate' => $rate,
'header_css_class' => 'col-sales-discount',
'column_css_class' => 'col-sales-discount'
@@ -288,6 +302,7 @@ protected function _prepareColumns()
'index' => 'total_discount_amount_actual',
'total' => 'sum',
'sortable' => false,
+ 'renderer' => Currency::class,
'visibility_filter' => ['show_actual_columns'],
'rate' => $rate,
'header_css_class' => 'col-discount',
@@ -304,6 +319,7 @@ protected function _prepareColumns()
'index' => 'total_canceled_amount',
'total' => 'sum',
'sortable' => false,
+ 'renderer' => Currency::class,
'rate' => $rate,
'header_css_class' => 'col-canceled',
'column_css_class' => 'col-canceled'
diff --git a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php
index f81176b7a1124..5a92b6ab4e79c 100644
--- a/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php
+++ b/app/code/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/Grid.php
@@ -37,6 +37,8 @@ public function __construct(
}
/**
+ * Grid constructor
+ *
* @return void
*/
protected function _construct()
@@ -46,6 +48,8 @@ protected function _construct()
}
/**
+ * Prepare collection
+ *
* @return \Magento\Backend\Block\Widget\Grid
*/
protected function _prepareCollection()
@@ -67,11 +71,16 @@ protected function _prepareCollection()
$this->setCollection($collection);
parent::_prepareCollection();
+ if ($this->_isExport) {
+ $collection->setPageSize(null);
+ }
$this->getCollection()->resolveCustomerNames();
return $this;
}
/**
+ * Add column filter to collection
+ *
* @param array $column
*
* @return $this
@@ -90,6 +99,8 @@ protected function _addColumnFilterToCollection($column)
}
/**
+ * Prepare columns
+ *
* @return \Magento\Backend\Block\Widget\Grid\Extended
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
@@ -223,6 +234,8 @@ protected function _prepareColumns()
}
/**
+ * Get rows url
+ *
* @param \Magento\Framework\DataObject $row
*
* @return string
diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/AbstractReport.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/AbstractReport.php
index 3dbced45e0a69..2fbff13a5b644 100644
--- a/app/code/Magento/Reports/Controller/Adminhtml/Report/AbstractReport.php
+++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/AbstractReport.php
@@ -9,13 +9,18 @@
*
* @author Magento Core Team
*/
+
namespace Magento\Reports\Controller\Adminhtml\Report;
+use Magento\Backend\Helper\Data as BackendHelper;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
/**
+ * Reports api controller
+ *
* @api
* @since 100.0.2
+ * @SuppressWarnings(PHPMD.AllPurposeAction)
*/
abstract class AbstractReport extends \Magento\Backend\App\Action
{
@@ -41,22 +46,30 @@ abstract class AbstractReport extends \Magento\Backend\App\Action
*/
protected $timezone;
+ /**
+ * @var BackendHelper
+ */
+ private $backendHelper;
+
/**
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\App\Response\Http\FileFactory $fileFactory
* @param \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter
* @param TimezoneInterface $timezone
+ * @param BackendHelper|null $backendHelperData
*/
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\App\Response\Http\FileFactory $fileFactory,
\Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter,
- TimezoneInterface $timezone
+ TimezoneInterface $timezone,
+ BackendHelper $backendHelperData = null
) {
parent::__construct($context);
$this->_fileFactory = $fileFactory;
$this->_dateFilter = $dateFilter;
$this->timezone = $timezone;
+ $this->backendHelper = $backendHelperData ?: $this->_objectManager->get(BackendHelper::class);
}
/**
@@ -103,25 +116,7 @@ public function _initReportAction($blocks)
$blocks = [$blocks];
}
- $requestData = $this->_objectManager->get(
- \Magento\Backend\Helper\Data::class
- )->prepareFilterString(
- $this->getRequest()->getParam('filter')
- );
- $inputFilter = new \Zend_Filter_Input(
- ['from' => $this->_dateFilter, 'to' => $this->_dateFilter],
- [],
- $requestData
- );
- $requestData = $inputFilter->getUnescaped();
- $requestData['store_ids'] = $this->getRequest()->getParam('store_ids');
- $params = new \Magento\Framework\DataObject();
-
- foreach ($requestData as $key => $value) {
- if (!empty($value)) {
- $params->setData($key, $value);
- }
- }
+ $params = $this->initFilterData();
foreach ($blocks as $block) {
if ($block) {
@@ -147,7 +142,7 @@ protected function _showLastExecutionTime($flagCode, $refreshCode)
->loadSelf();
$updatedAt = 'undefined';
if ($flag->hasData()) {
- $updatedAt = $this->timezone->formatDate(
+ $updatedAt = $this->timezone->formatDate(
$flag->getLastUpdate(),
\IntlDateFormatter::MEDIUM,
true
@@ -155,17 +150,51 @@ protected function _showLastExecutionTime($flagCode, $refreshCode)
}
$refreshStatsLink = $this->getUrl('reports/report_statistics');
- $directRefreshLink = $this->getUrl('reports/report_statistics/refreshRecent', ['code' => $refreshCode]);
+ $directRefreshLink = $this->getUrl('reports/report_statistics/refreshRecent');
$this->messageManager->addNotice(
__(
'Last updated: %1. To refresh last day\'s statistics, ' .
- 'click here.',
+ 'click here.',
$updatedAt,
$refreshStatsLink,
- $directRefreshLink
+ str_replace(
+ '"',
+ '"',
+ json_encode(['action' => $directRefreshLink, 'data' => ['code' => $refreshCode]])
+ )
)
);
return $this;
}
+
+ /**
+ * Init filter data
+ *
+ * @return \Magento\Framework\DataObject
+ */
+ private function initFilterData(): \Magento\Framework\DataObject
+ {
+ $requestData = $this->backendHelper
+ ->prepareFilterString(
+ $this->getRequest()->getParam('filter')
+ );
+
+ $filterRules = ['from' => $this->_dateFilter, 'to' => $this->_dateFilter];
+ $inputFilter = new \Zend_Filter_Input($filterRules, [], $requestData);
+
+ $requestData = $inputFilter->getUnescaped();
+ $requestData['store_ids'] = $this->getRequest()->getParam('store_ids');
+ $requestData['group'] = $this->getRequest()->getParam('group');
+ $requestData['website'] = $this->getRequest()->getParam('website');
+
+ $params = new \Magento\Framework\DataObject();
+
+ foreach ($requestData as $key => $value) {
+ if (!empty($value)) {
+ $params->setData($key, $value);
+ }
+ }
+ return $params;
+ }
}
diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Customer/Accounts.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Customer/Accounts.php
index ae1c0401add56..f8d0cbe9e6909 100644
--- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Customer/Accounts.php
+++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Customer/Accounts.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Reports\Controller\Adminhtml\Report\Customer;
-class Accounts extends \Magento\Reports\Controller\Adminhtml\Report\Customer
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Accounts extends \Magento\Reports\Controller\Adminhtml\Report\Customer implements HttpGetActionInterface
{
/**
* New accounts action
diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Customer/Orders.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Customer/Orders.php
index 56a594ac24ea2..be46fb6a94c76 100644
--- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Customer/Orders.php
+++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Customer/Orders.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Reports\Controller\Adminhtml\Report\Customer;
-class Orders extends \Magento\Reports\Controller\Adminhtml\Report\Customer
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Orders extends \Magento\Reports\Controller\Adminhtml\Report\Customer implements HttpGetActionInterface
{
/**
* Customers by number of orders action
diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Customer/Totals.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Customer/Totals.php
index 17928872eba97..02f40e5be9807 100644
--- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Customer/Totals.php
+++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Customer/Totals.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Reports\Controller\Adminhtml\Report\Customer;
-class Totals extends \Magento\Reports\Controller\Adminhtml\Report\Customer
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Totals extends \Magento\Reports\Controller\Adminhtml\Report\Customer implements HttpGetActionInterface
{
/**
* Customers by orders total action
diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Downloads.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Downloads.php
index e8df3118caa2f..f2c03d0dc22a5 100644
--- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Downloads.php
+++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Downloads.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Reports\Controller\Adminhtml\Report\Product;
-class Downloads extends \Magento\Reports\Controller\Adminhtml\Report\Product
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Downloads extends \Magento\Reports\Controller\Adminhtml\Report\Product implements HttpGetActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Lowstock.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Lowstock.php
index b5e3602383f7a..266d6a853414d 100644
--- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Lowstock.php
+++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Lowstock.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Reports\Controller\Adminhtml\Report\Product;
-class Lowstock extends \Magento\Reports\Controller\Adminhtml\Report\Product
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Lowstock extends \Magento\Reports\Controller\Adminhtml\Report\Product implements HttpGetActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Sold.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Sold.php
index 19b8258beaa5b..f01c46f4c142d 100644
--- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Sold.php
+++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Sold.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Reports\Controller\Adminhtml\Report\Product;
-class Sold extends \Magento\Reports\Controller\Adminhtml\Report\Product
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Sold extends \Magento\Reports\Controller\Adminhtml\Report\Product implements HttpGetActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Viewed.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Viewed.php
index 07beec5a72738..980540fb1fa0f 100644
--- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Viewed.php
+++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Product/Viewed.php
@@ -6,9 +6,10 @@
*/
namespace Magento\Reports\Controller\Adminhtml\Report\Product;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Reports\Model\Flag;
-class Viewed extends \Magento\Reports\Controller\Adminhtml\Report\Product
+class Viewed extends \Magento\Reports\Controller\Adminhtml\Report\Product implements HttpGetActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Review/Customer.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Review/Customer.php
index 50b1f79abd4f0..481522b86f0dd 100644
--- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Review/Customer.php
+++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Review/Customer.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Reports\Controller\Adminhtml\Report\Review;
-class Customer extends \Magento\Reports\Controller\Adminhtml\Report\Review
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Customer extends \Magento\Reports\Controller\Adminhtml\Report\Review implements HttpGetActionInterface
{
/**
* Customer Reviews Report action
diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Review/Product.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Review/Product.php
index 3d0ebc5f56828..911a313377ca9 100644
--- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Review/Product.php
+++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Review/Product.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Reports\Controller\Adminhtml\Report\Review;
-class Product extends \Magento\Reports\Controller\Adminhtml\Report\Review
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Product extends \Magento\Reports\Controller\Adminhtml\Report\Review implements HttpGetActionInterface
{
/**
* Product reviews report action
diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Bestsellers.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Bestsellers.php
index 60f8cc87f2ab4..eff3796b6d472 100644
--- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Bestsellers.php
+++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Bestsellers.php
@@ -6,9 +6,10 @@
*/
namespace Magento\Reports\Controller\Adminhtml\Report\Sales;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Reports\Model\Flag;
-class Bestsellers extends \Magento\Reports\Controller\Adminhtml\Report\Sales
+class Bestsellers extends \Magento\Reports\Controller\Adminhtml\Report\Sales implements HttpGetActionInterface
{
/**
* Bestsellers report action
diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Coupons.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Coupons.php
index 2e324bceee3c8..d9e83cd77b991 100644
--- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Coupons.php
+++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Coupons.php
@@ -6,9 +6,10 @@
*/
namespace Magento\Reports\Controller\Adminhtml\Report\Sales;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Reports\Model\Flag;
-class Coupons extends \Magento\Reports\Controller\Adminhtml\Report\Sales
+class Coupons extends \Magento\Reports\Controller\Adminhtml\Report\Sales implements HttpGetActionInterface
{
/**
* Coupons report action
diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Invoiced.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Invoiced.php
index f533d597990fc..c26b0f931e6b7 100644
--- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Invoiced.php
+++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Invoiced.php
@@ -6,9 +6,10 @@
*/
namespace Magento\Reports\Controller\Adminhtml\Report\Sales;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Reports\Model\Flag;
-class Invoiced extends \Magento\Reports\Controller\Adminhtml\Report\Sales
+class Invoiced extends \Magento\Reports\Controller\Adminhtml\Report\Sales implements HttpGetActionInterface
{
/**
* Invoice report action
diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Refunded.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Refunded.php
index 85c5fdaed4279..f88e9f64b971a 100644
--- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Refunded.php
+++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Refunded.php
@@ -6,9 +6,10 @@
*/
namespace Magento\Reports\Controller\Adminhtml\Report\Sales;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Reports\Model\Flag;
-class Refunded extends \Magento\Reports\Controller\Adminhtml\Report\Sales
+class Refunded extends \Magento\Reports\Controller\Adminhtml\Report\Sales implements HttpGetActionInterface
{
/**
* Refunds report action
diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Sales.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Sales.php
index d6460864c5c1b..e3f383ab5a743 100644
--- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Sales.php
+++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Sales.php
@@ -6,9 +6,10 @@
*/
namespace Magento\Reports\Controller\Adminhtml\Report\Sales;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Reports\Model\Flag;
-class Sales extends \Magento\Reports\Controller\Adminhtml\Report\Sales
+class Sales extends \Magento\Reports\Controller\Adminhtml\Report\Sales implements HttpGetActionInterface
{
/**
* Sales report action
diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Tax.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Tax.php
index e8ae11088f5a7..2e6ba487f3981 100644
--- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Tax.php
+++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Sales/Tax.php
@@ -6,9 +6,10 @@
*/
namespace Magento\Reports\Controller\Adminhtml\Report\Sales;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Reports\Model\Flag;
-class Tax extends \Magento\Reports\Controller\Adminhtml\Report\Sales
+class Tax extends \Magento\Reports\Controller\Adminhtml\Report\Sales implements HttpGetActionInterface
{
/**
* Tax report action
diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/Abandoned.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/Abandoned.php
index e03f2f6556010..3f0567c05a93d 100644
--- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/Abandoned.php
+++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/Abandoned.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Reports\Controller\Adminhtml\Report\Shopcart;
-class Abandoned extends \Magento\Reports\Controller\Adminhtml\Report\Shopcart
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Abandoned extends \Magento\Reports\Controller\Adminhtml\Report\Shopcart implements HttpGetActionInterface
{
/**
* Abandoned carts action
diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/Product.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/Product.php
index 65db66f2d2e0c..b41c901fe8576 100644
--- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/Product.php
+++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Shopcart/Product.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Reports\Controller\Adminhtml\Report\Shopcart;
-class Product extends \Magento\Reports\Controller\Adminhtml\Report\Shopcart
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Product extends \Magento\Reports\Controller\Adminhtml\Report\Shopcart implements HttpGetActionInterface
{
/**
* Products in carts action
diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics/Index.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics/Index.php
index d9f9de39657d1..61ec31337db58 100644
--- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics/Index.php
+++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics/Index.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Reports\Controller\Adminhtml\Report\Statistics;
-class Index extends \Magento\Reports\Controller\Adminhtml\Report\Statistics
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Index extends \Magento\Reports\Controller\Adminhtml\Report\Statistics implements HttpGetActionInterface
{
/**
* Refresh statistics action
diff --git a/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics/RefreshRecent.php b/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics/RefreshRecent.php
index 1f0f6e8e40535..66123938243d9 100644
--- a/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics/RefreshRecent.php
+++ b/app/code/Magento/Reports/Controller/Adminhtml/Report/Statistics/RefreshRecent.php
@@ -6,7 +6,12 @@
*/
namespace Magento\Reports\Controller\Adminhtml\Report\Statistics;
-class RefreshRecent extends \Magento\Reports\Controller\Adminhtml\Report\Statistics
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
+
+/**
+ * Refresh recent stats.
+ */
+class RefreshRecent extends \Magento\Reports\Controller\Adminhtml\Report\Statistics implements HttpPostActionInterface
{
/**
* Refresh statistics for last 25 hours
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/Edit.php b/app/code/Magento/Review/Controller/Adminhtml/Product/Edit.php
index a39b22ec080c6..7d922f30cd98b 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Product/Edit.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Product/Edit.php
@@ -5,10 +5,11 @@
*/
namespace Magento\Review\Controller\Adminhtml\Product;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Review\Controller\Adminhtml\Product as ProductController;
use Magento\Framework\Controller\ResultFactory;
-class Edit extends ProductController
+class Edit extends ProductController implements HttpGetActionInterface
{
/**
* @return \Magento\Backend\Model\View\Result\Page
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/Index.php b/app/code/Magento/Review/Controller/Adminhtml/Product/Index.php
index 0dce5b238838d..94c80f89f8d8c 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Product/Index.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Product/Index.php
@@ -5,10 +5,11 @@
*/
namespace Magento\Review\Controller\Adminhtml\Product;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Review\Controller\Adminhtml\Product as ProductController;
use Magento\Framework\Controller\ResultFactory;
-class Index extends ProductController
+class Index extends ProductController implements HttpGetActionInterface
{
/**
* @return \Magento\Framework\Controller\ResultInterface
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/JsonProductInfo.php b/app/code/Magento/Review/Controller/Adminhtml/Product/JsonProductInfo.php
index c6e9cc81d5814..bfd4b5e747043 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Product/JsonProductInfo.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Product/JsonProductInfo.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Review\Controller\Adminhtml\Product;
+use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Review\Controller\Adminhtml\Product as ProductController;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Registry;
@@ -14,7 +15,7 @@
use Magento\Framework\DataObject;
use Magento\Framework\Controller\ResultFactory;
-class JsonProductInfo extends ProductController
+class JsonProductInfo extends ProductController implements HttpGetActionInterface
{
/**
* @var \Magento\Catalog\Api\ProductRepositoryInterface
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/NewAction.php b/app/code/Magento/Review/Controller/Adminhtml/Product/NewAction.php
index 5ac3a6a057246..2709b5ce64b37 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Product/NewAction.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Product/NewAction.php
@@ -5,10 +5,11 @@
*/
namespace Magento\Review\Controller\Adminhtml\Product;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Review\Controller\Adminhtml\Product as ProductController;
use Magento\Framework\Controller\ResultFactory;
-class NewAction extends ProductController
+class NewAction extends ProductController implements HttpGetActionInterface
{
/**
* @return \Magento\Backend\Model\View\Result\Page
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/Post.php b/app/code/Magento/Review/Controller/Adminhtml/Product/Post.php
index 1f21a52077bb7..b62fcc7326eec 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Product/Post.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Product/Post.php
@@ -5,12 +5,13 @@
*/
namespace Magento\Review\Controller\Adminhtml\Product;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Review\Controller\Adminhtml\Product as ProductController;
use Magento\Framework\Controller\ResultFactory;
use Magento\Store\Model\Store;
use Magento\Framework\Exception\LocalizedException;
-class Post extends ProductController
+class Post extends ProductController implements HttpPostActionInterface
{
/**
* @return \Magento\Backend\Model\View\Result\Redirect
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/ProductGrid.php b/app/code/Magento/Review/Controller/Adminhtml/Product/ProductGrid.php
index f1b25c3613d49..e4057be14af2f 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Product/ProductGrid.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Product/ProductGrid.php
@@ -5,6 +5,8 @@
*/
namespace Magento\Review\Controller\Adminhtml\Product;
+use Magento\Framework\App\Action\HttpGetActionInterface;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Review\Controller\Adminhtml\Product as ProductController;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Registry;
@@ -13,7 +15,7 @@
use Magento\Framework\View\LayoutFactory;
use Magento\Framework\Controller\ResultFactory;
-class ProductGrid extends ProductController
+class ProductGrid extends ProductController implements HttpPostActionInterface, HttpGetActionInterface
{
/**
* @var \Magento\Framework\View\LayoutFactory
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/RatingItems.php b/app/code/Magento/Review/Controller/Adminhtml/Product/RatingItems.php
index 5b0ab217e7191..1da8e4abbd6b0 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Product/RatingItems.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Product/RatingItems.php
@@ -5,6 +5,8 @@
*/
namespace Magento\Review\Controller\Adminhtml\Product;
+use Magento\Framework\App\Action\HttpGetActionInterface;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Review\Controller\Adminhtml\Product as ProductController;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Registry;
@@ -13,7 +15,7 @@
use Magento\Framework\View\LayoutFactory;
use Magento\Framework\Controller\ResultFactory;
-class RatingItems extends ProductController
+class RatingItems extends ProductController implements HttpPostActionInterface, HttpGetActionInterface
{
/**
* @var \Magento\Framework\View\LayoutFactory
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/Save.php b/app/code/Magento/Review/Controller/Adminhtml/Product/Save.php
index 7159b1825dc4d..35187e46933bc 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Product/Save.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Product/Save.php
@@ -5,11 +5,12 @@
*/
namespace Magento\Review\Controller\Adminhtml\Product;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Review\Controller\Adminhtml\Product as ProductController;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Exception\LocalizedException;
-class Save extends ProductController
+class Save extends ProductController implements HttpPostActionInterface
{
/**
* @return \Magento\Backend\Model\View\Result\Redirect
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Rating/Delete.php b/app/code/Magento/Review/Controller/Adminhtml/Rating/Delete.php
index 5535c3de26e43..b25db6e498fe0 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Rating/Delete.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Rating/Delete.php
@@ -5,10 +5,11 @@
*/
namespace Magento\Review\Controller\Adminhtml\Rating;
+use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Review\Controller\Adminhtml\Rating as RatingController;
use Magento\Framework\Controller\ResultFactory;
-class Delete extends RatingController
+class Delete extends RatingController implements HttpPostActionInterface
{
/**
* @return \Magento\Backend\Model\View\Result\Redirect
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Rating/Edit.php b/app/code/Magento/Review/Controller/Adminhtml/Rating/Edit.php
index 1b65966b77054..90dac026cfd64 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Rating/Edit.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Rating/Edit.php
@@ -5,10 +5,11 @@
*/
namespace Magento\Review\Controller\Adminhtml\Rating;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Review\Controller\Adminhtml\Rating as RatingController;
use Magento\Framework\Controller\ResultFactory;
-class Edit extends RatingController
+class Edit extends RatingController implements HttpGetActionInterface
{
/**
* @return \Magento\Backend\Model\View\Result\Page
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Rating/Index.php b/app/code/Magento/Review/Controller/Adminhtml/Rating/Index.php
index b719a29950570..ff9ab4d50eac4 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Rating/Index.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Rating/Index.php
@@ -5,10 +5,11 @@
*/
namespace Magento\Review\Controller\Adminhtml\Rating;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Review\Controller\Adminhtml\Rating as RatingController;
use Magento\Framework\Controller\ResultFactory;
-class Index extends RatingController
+class Index extends RatingController implements HttpGetActionInterface
{
/**
* @return \Magento\Backend\Model\View\Result\Page
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Rating/NewAction.php b/app/code/Magento/Review/Controller/Adminhtml/Rating/NewAction.php
index 18ff73ad31c5e..92d20aeec3eb7 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Rating/NewAction.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Rating/NewAction.php
@@ -5,10 +5,11 @@
*/
namespace Magento\Review\Controller\Adminhtml\Rating;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Review\Controller\Adminhtml\Rating as RatingController;
use Magento\Framework\Controller\ResultFactory;
-class NewAction extends RatingController
+class NewAction extends RatingController implements HttpGetActionInterface
{
/**
* @return \Magento\Backend\Model\View\Result\Forward
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Rating/Save.php b/app/code/Magento/Review/Controller/Adminhtml/Rating/Save.php
index 62cca9c824e54..5dd464f7eb611 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Rating/Save.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Rating/Save.php
@@ -5,10 +5,11 @@
*/
namespace Magento\Review\Controller\Adminhtml\Rating;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Review\Controller\Adminhtml\Rating as RatingController;
use Magento\Framework\Controller\ResultFactory;
-class Save extends RatingController
+class Save extends RatingController implements HttpPostActionInterface
{
/**
* Save rating
diff --git a/app/code/Magento/Review/Controller/Product/ListAjax.php b/app/code/Magento/Review/Controller/Product/ListAjax.php
index a309b5f0626a4..d923814c7dce5 100644
--- a/app/code/Magento/Review/Controller/Product/ListAjax.php
+++ b/app/code/Magento/Review/Controller/Product/ListAjax.php
@@ -11,8 +11,9 @@
use Magento\Framework\View\Result\Layout;
use Magento\Review\Controller\Product as ProductController;
use Magento\Framework\Controller\ResultFactory;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
-class ListAjax extends ProductController
+class ListAjax extends ProductController implements HttpGetActionInterface
{
/**
* Show list of product's reviews
diff --git a/app/code/Magento/Review/Controller/Product/Post.php b/app/code/Magento/Review/Controller/Product/Post.php
index be18f8fe25bbe..32838eb6acbbb 100644
--- a/app/code/Magento/Review/Controller/Product/Post.php
+++ b/app/code/Magento/Review/Controller/Product/Post.php
@@ -5,11 +5,12 @@
*/
namespace Magento\Review\Controller\Product;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Review\Controller\Product as ProductController;
use Magento\Framework\Controller\ResultFactory;
use Magento\Review\Model\Review;
-class Post extends ProductController
+class Post extends ProductController implements HttpPostActionInterface
{
/**
* Submit new review action
diff --git a/app/code/Magento/Robots/Block/Data.php b/app/code/Magento/Robots/Block/Data.php
index 0e492eb73732d..460225d3ed71c 100644
--- a/app/code/Magento/Robots/Block/Data.php
+++ b/app/code/Magento/Robots/Block/Data.php
@@ -11,9 +11,11 @@
use Magento\Robots\Model\Config\Value;
use Magento\Robots\Model\Robots;
use Magento\Store\Model\StoreResolver;
+use Magento\Store\Model\StoreManagerInterface;
/**
* Robots Block Class.
+ *
* Prepares base content for robots.txt and implements Page Cache functionality.
*
* @api
@@ -27,24 +29,29 @@ class Data extends AbstractBlock implements IdentityInterface
private $robots;
/**
- * @var StoreResolver
+ * @var StoreManagerInterface
*/
- private $storeResolver;
+ private $storeManager;
/**
* @param Context $context
* @param Robots $robots
* @param StoreResolver $storeResolver
+ * @param StoreManagerInterface|null $storeManager
* @param array $data
+ *
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __construct(
Context $context,
Robots $robots,
StoreResolver $storeResolver,
+ StoreManagerInterface $storeManager = null,
array $data = []
) {
$this->robots = $robots;
- $this->storeResolver = $storeResolver;
+ $this->storeManager = $storeManager ?: \Magento\Framework\App\ObjectManager::getInstance()
+ ->get(StoreManagerInterface::class);
parent::__construct($context, $data);
}
@@ -69,7 +76,7 @@ protected function _toHtml()
public function getIdentities()
{
return [
- Value::CACHE_TAG . '_' . $this->storeResolver->getCurrentStoreId(),
+ Value::CACHE_TAG . '_' . $this->storeManager->getStore()->getId(),
];
}
}
diff --git a/app/code/Magento/Robots/Model/Config/Value.php b/app/code/Magento/Robots/Model/Config/Value.php
index 83c21d6602fca..c4e17e55f1262 100644
--- a/app/code/Magento/Robots/Model/Config/Value.php
+++ b/app/code/Magento/Robots/Model/Config/Value.php
@@ -14,9 +14,11 @@
use Magento\Framework\Model\ResourceModel\AbstractResource;
use Magento\Framework\Registry;
use Magento\Store\Model\StoreResolver;
+use Magento\Store\Model\StoreManagerInterface;
/**
* Backend model for design/search_engine_robots/custom_instructions configuration value.
+ *
* Required to implement Page Cache functionality.
*
* @api
@@ -38,9 +40,9 @@ class Value extends ConfigValue implements IdentityInterface
protected $_cacheTag = true;
/**
- * @var StoreResolver
+ * @var StoreManagerInterface
*/
- private $storeResolver;
+ private $storeManager;
/**
* @param Context $context
@@ -48,9 +50,12 @@ class Value extends ConfigValue implements IdentityInterface
* @param ScopeConfigInterface $config
* @param TypeListInterface $cacheTypeList
* @param StoreResolver $storeResolver
+ * @param StoreManagerInterface|null $storeManager
* @param AbstractResource|null $resource
* @param AbstractDb|null $resourceCollection
* @param array $data
+ *
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __construct(
Context $context,
@@ -58,11 +63,13 @@ public function __construct(
ScopeConfigInterface $config,
TypeListInterface $cacheTypeList,
StoreResolver $storeResolver,
+ StoreManagerInterface $storeManager = null,
AbstractResource $resource = null,
AbstractDb $resourceCollection = null,
array $data = []
) {
- $this->storeResolver = $storeResolver;
+ $this->storeManager = $storeManager ?: \Magento\Framework\App\ObjectManager::getInstance()
+ ->get(StoreManagerInterface::class);
parent::__construct(
$context,
@@ -84,7 +91,7 @@ public function __construct(
public function getIdentities()
{
return [
- self::CACHE_TAG . '_' . $this->storeResolver->getCurrentStoreId(),
+ self::CACHE_TAG . '_' . $this->storeManager->getStore()->getId(),
];
}
}
diff --git a/app/code/Magento/Robots/Test/Unit/Block/DataTest.php b/app/code/Magento/Robots/Test/Unit/Block/DataTest.php
index 10d2595832a48..95aa97fc8f677 100644
--- a/app/code/Magento/Robots/Test/Unit/Block/DataTest.php
+++ b/app/code/Magento/Robots/Test/Unit/Block/DataTest.php
@@ -27,6 +27,11 @@ class DataTest extends \PHPUnit\Framework\TestCase
*/
private $storeResolver;
+ /**
+ * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $storeManager;
+
/**
* @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
@@ -65,10 +70,14 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
+ $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
+ ->getMockForAbstractClass();
+
$this->block = new \Magento\Robots\Block\Data(
$this->context,
$this->robots,
- $this->storeResolver
+ $this->storeResolver,
+ $this->storeManager
);
}
@@ -97,8 +106,14 @@ public function testGetIdentities()
{
$storeId = 1;
- $this->storeResolver->expects($this->once())
- ->method('getCurrentStoreId')
+ $storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)->getMock();
+
+ $this->storeManager->expects($this->once())
+ ->method('getStore')
+ ->willReturn($storeMock);
+
+ $storeMock->expects($this->once())
+ ->method('getId')
->willReturn($storeId);
$expected = [
diff --git a/app/code/Magento/Robots/Test/Unit/Model/Config/ValueTest.php b/app/code/Magento/Robots/Test/Unit/Model/Config/ValueTest.php
index fc0c55ccef147..44e843e7de936 100644
--- a/app/code/Magento/Robots/Test/Unit/Model/Config/ValueTest.php
+++ b/app/code/Magento/Robots/Test/Unit/Model/Config/ValueTest.php
@@ -37,6 +37,11 @@ class ValueTest extends \PHPUnit\Framework\TestCase
*/
private $storeResolver;
+ /**
+ * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $storeManager;
+
protected function setUp()
{
$this->context = $this->getMockBuilder(\Magento\Framework\Model\Context::class)
@@ -57,12 +62,16 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
+ $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
+ ->getMockForAbstractClass();
+
$this->model = new \Magento\Robots\Model\Config\Value(
$this->context,
$this->registry,
$this->scopeConfig,
$this->typeList,
- $this->storeResolver
+ $this->storeResolver,
+ $this->storeManager
);
}
@@ -73,8 +82,14 @@ public function testGetIdentities()
{
$storeId = 1;
- $this->storeResolver->expects($this->once())
- ->method('getCurrentStoreId')
+ $storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)->getMockForAbstractClass();
+
+ $this->storeManager->expects($this->once())
+ ->method('getStore')
+ ->willReturn($storeMock);
+
+ $storeMock->expects($this->once())
+ ->method('getId')
->willReturn($storeId);
$expected = [
diff --git a/app/code/Magento/Sales/Block/Status/Grid/Column/Unassign.php b/app/code/Magento/Sales/Block/Status/Grid/Column/Unassign.php
index b413951d9d4f3..f989deb0ae7c0 100644
--- a/app/code/Magento/Sales/Block/Status/Grid/Column/Unassign.php
+++ b/app/code/Magento/Sales/Block/Status/Grid/Column/Unassign.php
@@ -5,12 +5,35 @@
*/
namespace Magento\Sales\Block\Status\Grid\Column;
+use Magento\Framework\App\ObjectManager;
+use \Magento\Backend\Block\Template\Context;
+use Magento\Framework\Serialize\Serializer\Json;
+
/**
* @api
* @since 100.0.2
*/
class Unassign extends \Magento\Backend\Block\Widget\Grid\Column
{
+ /**
+ * @var Json
+ */
+ private $json;
+
+ /**
+ * @inheritDoc
+ *
+ * @param Json|null $json
+ */
+ public function __construct(
+ Context $context,
+ array $data = [],
+ ?Json $json = null
+ ) {
+ parent::__construct($context, $data);
+ $this->json = $json ?? ObjectManager::getInstance()->get(Json::class);
+ }
+
/**
* Add decorated action to column
*
@@ -36,9 +59,16 @@ public function decorateAction($value, $row, $column, $isExport)
$cell = '';
$state = $row->getState();
if (!empty($state)) {
- $url = $this->getUrl('*/*/unassign', ['status' => $row->getStatus(), 'state' => $row->getState()]);
+ $url = $this->getUrl('*/*/unassign');
$label = __('Unassign');
- $cell = '' . $label . '';
+ $cell = '' . $label . '';
}
return $cell;
}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/Index.php b/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/Index.php
index b29c1ea3700ee..165c9e894de78 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/Index.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Creditmemo/Index.php
@@ -5,7 +5,10 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Creditmemo;
-class Index extends \Magento\Sales\Controller\Adminhtml\Creditmemo\AbstractCreditmemo\Index
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+use Magento\Sales\Controller\Adminhtml\Creditmemo\AbstractCreditmemo\Index as AbstractIndex;
+
+class Index extends AbstractIndex implements HttpGetActionInterface
{
/**
* Index page
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/Index.php b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/Index.php
index 429a388d9392f..bc53f752801ba 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/Index.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/Index.php
@@ -6,6 +6,8 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Invoice;
-class Index extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\Index
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Index extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\Index implements HttpGetActionInterface
{
}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/View.php b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/View.php
index 62add99ab5976..3b52199943230 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/View.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/View.php
@@ -6,6 +6,8 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Invoice;
-class View extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\View
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class View extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\View implements HttpGetActionInterface
{
}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Cancel.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Cancel.php
index 7e41c7417b38d..f96d221a7d3b3 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Cancel.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Cancel.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Order;
-class Cancel extends \Magento\Sales\Controller\Adminhtml\Order
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
+
+class Cancel extends \Magento\Sales\Controller\Adminhtml\Order implements HttpPostActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/CommentsHistory.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/CommentsHistory.php
index 8496c4f28d8bc..4acef74b810da 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/CommentsHistory.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/CommentsHistory.php
@@ -6,16 +6,20 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Order;
+use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Backend\App\Action;
+use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Sales\Api\OrderManagementInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
use Psr\Log\LoggerInterface;
+use Magento\Sales\Controller\Adminhtml\Order as OrderAction;
/**
- * Class CommentsHistory
+ * Comments History tab, needs to be accessible by POST becuase of tabs mechanism.
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class CommentsHistory extends \Magento\Sales\Controller\Adminhtml\Order
+class CommentsHistory extends OrderAction implements HttpGetActionInterface, HttpPostActionInterface
{
/**
* @var \Magento\Framework\View\LayoutFactory
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Index.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Index.php
index ce3a36729de95..035dc7877897d 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Index.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Index.php
@@ -5,7 +5,9 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Order\Create;
-class Index extends \Magento\Sales\Controller\Adminhtml\Order\Create
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Index extends \Magento\Sales\Controller\Adminhtml\Order\Create implements HttpGetActionInterface
{
/**
* Index page
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/LoadBlock.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/LoadBlock.php
index bc4eb3cfba423..1e13e282cae3a 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/LoadBlock.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/LoadBlock.php
@@ -5,12 +5,15 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Order\Create;
+use Magento\Framework\App\Action\HttpGetActionInterface;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Backend\App\Action;
use Magento\Backend\Model\View\Result\ForwardFactory;
use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\Controller\Result\RawFactory;
+use Magento\Sales\Controller\Adminhtml\Order\Create as CreateAction;
-class LoadBlock extends \Magento\Sales\Controller\Adminhtml\Order\Create
+class LoadBlock extends CreateAction implements HttpPostActionInterface, HttpGetActionInterface
{
/**
* @var RawFactory
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Save.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Save.php
index 929e23075e070..4348984d0403b 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Save.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Save.php
@@ -6,9 +6,10 @@
namespace Magento\Sales\Controller\Adminhtml\Order\Create;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Framework\Exception\PaymentException;
-class Save extends \Magento\Sales\Controller\Adminhtml\Order\Create
+class Save extends \Magento\Sales\Controller\Adminhtml\Order\Create implements HttpPostActionInterface
{
/**
* Saving quote and create order
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/ShowUpdateResult.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/ShowUpdateResult.php
index 01119c3aa88a1..24aedf56ec5a1 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/ShowUpdateResult.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/ShowUpdateResult.php
@@ -5,12 +5,13 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Order\Create;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Backend\App\Action;
use Magento\Backend\Model\View\Result\ForwardFactory;
use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\Controller\Result\RawFactory;
-class ShowUpdateResult extends \Magento\Sales\Controller\Adminhtml\Order\Create
+class ShowUpdateResult extends \Magento\Sales\Controller\Adminhtml\Order\Create implements HttpGetActionInterface
{
/**
* @var RawFactory
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Start.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Start.php
index ee88b3361cc83..bc75bc4a5787f 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Start.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Create/Start.php
@@ -5,9 +5,10 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Order\Create;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Backend\App\Action;
-class Start extends \Magento\Sales\Controller\Adminhtml\Order\Create
+class Start extends \Magento\Sales\Controller\Adminhtml\Order\Create implements HttpGetActionInterface
{
/**
* Start order create action
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/NewAction.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/NewAction.php
index 03910f2ecccfe..3ac3abda82cd1 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/NewAction.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/NewAction.php
@@ -5,9 +5,10 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Order\Creditmemo;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Backend\App\Action;
-class NewAction extends \Magento\Backend\App\Action
+class NewAction extends \Magento\Backend\App\Action implements HttpGetActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php
index 2a2445d2b2ae0..91ae3b7d4e058 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Save.php
@@ -5,11 +5,12 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Order\Creditmemo;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Backend\App\Action;
use Magento\Sales\Model\Order;
use Magento\Sales\Model\Order\Email\Sender\CreditmemoSender;
-class Save extends \Magento\Backend\App\Action
+class Save extends \Magento\Backend\App\Action implements HttpPostActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Start.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Start.php
index 10ba7e425b651..3dc4aa6dcd500 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Start.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/Start.php
@@ -5,7 +5,9 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Order\Creditmemo;
-class Start extends \Magento\Backend\App\Action
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Start extends \Magento\Backend\App\Action implements HttpGetActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQty.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQty.php
index bfd95666e7c48..d49fa8b8dc608 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQty.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Creditmemo/UpdateQty.php
@@ -5,9 +5,10 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Order\Creditmemo;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Backend\App\Action;
-class UpdateQty extends \Magento\Backend\App\Action
+class UpdateQty extends \Magento\Backend\App\Action implements HttpPostActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Index.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Index.php
index 13a86befec0a5..d5dc11719237c 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Index.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Index.php
@@ -5,7 +5,9 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Order;
-class Index extends \Magento\Sales\Controller\Adminhtml\Order
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Index extends \Magento\Sales\Controller\Adminhtml\Order implements HttpGetActionInterface
{
/**
* Orders grid
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/NewAction.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/NewAction.php
index 2d7826807a6c3..3295b244f323e 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/NewAction.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/NewAction.php
@@ -7,12 +7,13 @@
namespace Magento\Sales\Controller\Adminhtml\Order\Invoice;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Backend\App\Action;
use Magento\Framework\Registry;
use Magento\Framework\View\Result\PageFactory;
use Magento\Sales\Model\Service\InvoiceService;
-class NewAction extends \Magento\Backend\App\Action
+class NewAction extends \Magento\Backend\App\Action implements HttpGetActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php
index 71338c818c418..ab74a64b6fcf3 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php
@@ -7,6 +7,7 @@
namespace Magento\Sales\Controller\Adminhtml\Order\Invoice;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Backend\App\Action;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Registry;
@@ -19,7 +20,7 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class Save extends \Magento\Backend\App\Action
+class Save extends \Magento\Backend\App\Action implements HttpPostActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Start.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Start.php
index ca97ee3b3349b..4648656a3253f 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Start.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Start.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Order\Invoice;
-class Start extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\View
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Start extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\View implements HttpGetActionInterface
{
/**
* Start create invoice action
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQty.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQty.php
index 78fb4aff3f275..c94afa3cc8057 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQty.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/UpdateQty.php
@@ -7,20 +7,21 @@
namespace Magento\Sales\Controller\Adminhtml\Order\Invoice;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Framework\Exception\LocalizedException;
-use Magento\Backend\App\Action;
use Magento\Framework\Controller\Result\JsonFactory;
use Magento\Framework\View\Result\PageFactory;
use Magento\Framework\Controller\Result\RawFactory;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Registry;
use Magento\Sales\Model\Service\InvoiceService;
+use Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\View as AbstractView;
/**
* Class UpdateQty
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class UpdateQty extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\View
+class UpdateQty extends AbstractView implements HttpPostActionInterface
{
/**
* @var JsonFactory
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/View.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/View.php
index 78a413d5636e8..da700aae2f78a 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/View.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/View.php
@@ -6,11 +6,12 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Order\Invoice;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Framework\View\Result\PageFactory;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Registry;
-class View extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\View
+class View extends \Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice\View implements HttpGetActionInterface
{
/**
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/MassCancel.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/MassCancel.php
index 32cf6dbfc7c35..deb20a989a260 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/MassCancel.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/MassCancel.php
@@ -5,13 +5,14 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Order;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
use Magento\Backend\App\Action\Context;
use Magento\Ui\Component\MassAction\Filter;
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory;
use Magento\Sales\Api\OrderManagementInterface;
-class MassCancel extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction
+class MassCancel extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction implements HttpPostActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Assign.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Assign.php
index 982ee53cb0ff2..211ded865b4e4 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Assign.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Assign.php
@@ -6,11 +6,12 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Order\Status;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Framework\Registry;
use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
-class Assign extends \Magento\Sales\Controller\Adminhtml\Order\Status
+class Assign extends \Magento\Sales\Controller\Adminhtml\Order\Status implements HttpGetActionInterface
{
/**
* @var PageFactory
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/AssignPost.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/AssignPost.php
index 3b98d206d5f66..28a8e1cb02a14 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/AssignPost.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/AssignPost.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Order\Status;
-class AssignPost extends \Magento\Sales\Controller\Adminhtml\Order\Status
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
+
+class AssignPost extends \Magento\Sales\Controller\Adminhtml\Order\Status implements HttpPostActionInterface
{
/**
* Save status assignment to state
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Index.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Index.php
index 110402ee27070..3755dca9da950 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Index.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Index.php
@@ -6,11 +6,12 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Order\Status;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Framework\Registry;
use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
-class Index extends \Magento\Sales\Controller\Adminhtml\Order\Status
+class Index extends \Magento\Sales\Controller\Adminhtml\Order\Status implements HttpGetActionInterface
{
/**
* @var PageFactory
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Save.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Save.php
index bd0ad771815b1..4645588a7522c 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Save.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Save.php
@@ -6,25 +6,32 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Order\Status;
-class Save extends \Magento\Sales\Controller\Adminhtml\Order\Status
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
+use Magento\Framework\Filter\FilterManager;
+use Magento\Sales\Model\Order\Status;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\Controller\Result\Redirect;
+use Magento\Sales\Controller\Adminhtml\Order\Status as StatusAction;
+
+class Save extends StatusAction implements HttpPostActionInterface
{
/**
* Save status form processing
*
- * @return \Magento\Backend\Model\View\Result\Redirect
+ * @return Redirect
*/
public function execute()
{
$data = $this->getRequest()->getPostValue();
$isNew = $this->getRequest()->getParam('is_new');
- /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
+ /** @var Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
if ($data) {
$statusCode = $this->getRequest()->getParam('status');
//filter tags in labels/status
- /** @var $filterManager \Magento\Framework\Filter\FilterManager */
- $filterManager = $this->_objectManager->get(\Magento\Framework\Filter\FilterManager::class);
+ /** @var $filterManager FilterManager */
+ $filterManager = $this->_objectManager->get(FilterManager::class);
if ($isNew) {
$statusCode = $data['status'] = $filterManager->stripTags($data['status']);
}
@@ -37,7 +44,7 @@ public function execute()
$label = $filterManager->stripTags($label);
}
- $status = $this->_objectManager->create(\Magento\Sales\Model\Order\Status::class)->load($statusCode);
+ $status = $this->_objectManager->create(Status::class)->load($statusCode);
// check if status exist
if ($isNew && $status->getStatus()) {
$this->messageManager
@@ -52,7 +59,7 @@ public function execute()
$status->save();
$this->messageManager->addSuccessMessage(__('You saved the order status.'));
return $resultRedirect->setPath('sales/*/');
- } catch (\Magento\Framework\Exception\LocalizedException $e) {
+ } catch (LocalizedException $e) {
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addExceptionMessage(
@@ -67,11 +74,11 @@ public function execute()
}
/**
- * @param \Magento\Backend\Model\View\Result\Redirect $resultRedirect
+ * @param Redirect $resultRedirect
* @param bool $isNew
- * @return \Magento\Backend\Model\View\Result\Redirect
+ * @return Redirect
*/
- private function getRedirect(\Magento\Backend\Model\View\Result\Redirect $resultRedirect, $isNew)
+ private function getRedirect(Redirect $resultRedirect, $isNew)
{
if ($isNew) {
return $resultRedirect->setPath('sales/*/new');
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Unassign.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Unassign.php
index 2723d483dd38b..16bb275a88ec1 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Unassign.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Status/Unassign.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Order\Status;
-class Unassign extends \Magento\Sales\Controller\Adminhtml\Order\Status
+use Magento\Framework\App\Action\HttpPostActionInterface;
+
+class Unassign extends \Magento\Sales\Controller\Adminhtml\Order\Status implements HttpPostActionInterface
{
/**
* @return \Magento\Backend\Model\View\Result\Redirect
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Shipment/Index.php b/app/code/Magento/Sales/Controller/Adminhtml/Shipment/Index.php
index c7f560c52fb66..59d8a68a7446d 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Shipment/Index.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Shipment/Index.php
@@ -6,6 +6,9 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Shipment;
-class Index extends \Magento\Sales\Controller\Adminhtml\Shipment\AbstractShipment\Index
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+use Magento\Sales\Controller\Adminhtml\Shipment\AbstractShipment\Index as AbstractIndex;
+
+class Index extends AbstractIndex implements HttpGetActionInterface
{
}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Transactions/Index.php b/app/code/Magento/Sales/Controller/Adminhtml/Transactions/Index.php
index 750781e99197c..a7327050064ae 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Transactions/Index.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Transactions/Index.php
@@ -6,9 +6,10 @@
*/
namespace Magento\Sales\Controller\Adminhtml\Transactions;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Backend\Model\View\Result\Page;
-class Index extends \Magento\Sales\Controller\Adminhtml\Transactions
+class Index extends \Magento\Sales\Controller\Adminhtml\Transactions implements HttpGetActionInterface
{
/**
* @return Page
diff --git a/app/code/Magento/Sales/Controller/Order/Creditmemo.php b/app/code/Magento/Sales/Controller/Order/Creditmemo.php
index 2a7fd3e9849e5..74aae3e1f8417 100644
--- a/app/code/Magento/Sales/Controller/Order/Creditmemo.php
+++ b/app/code/Magento/Sales/Controller/Order/Creditmemo.php
@@ -6,8 +6,10 @@
*/
namespace Magento\Sales\Controller\Order;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Sales\Controller\OrderInterface;
+use Magento\Sales\Controller\AbstractController\Creditmemo as AbstractCreditmemo;
-class Creditmemo extends \Magento\Sales\Controller\AbstractController\Creditmemo implements OrderInterface
+class Creditmemo extends AbstractCreditmemo implements OrderInterface, HttpGetActionInterface
{
}
diff --git a/app/code/Magento/Sales/Controller/Order/History.php b/app/code/Magento/Sales/Controller/Order/History.php
index 23e8208d8b198..37de159845856 100644
--- a/app/code/Magento/Sales/Controller/Order/History.php
+++ b/app/code/Magento/Sales/Controller/Order/History.php
@@ -6,11 +6,12 @@
*/
namespace Magento\Sales\Controller\Order;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Sales\Controller\OrderInterface;
use Magento\Framework\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
-class History extends \Magento\Framework\App\Action\Action implements OrderInterface
+class History extends \Magento\Framework\App\Action\Action implements OrderInterface, HttpGetActionInterface
{
/**
* @var PageFactory
diff --git a/app/code/Magento/Sales/Controller/Order/View.php b/app/code/Magento/Sales/Controller/Order/View.php
index d68b9481c8619..21a5706a4448f 100644
--- a/app/code/Magento/Sales/Controller/Order/View.php
+++ b/app/code/Magento/Sales/Controller/Order/View.php
@@ -6,8 +6,9 @@
*/
namespace Magento\Sales\Controller\Order;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Sales\Controller\OrderInterface;
-class View extends \Magento\Sales\Controller\AbstractController\View implements OrderInterface
+class View extends \Magento\Sales\Controller\AbstractController\View implements OrderInterface, HttpGetActionInterface
{
}
diff --git a/app/code/Magento/Sales/Model/Order.php b/app/code/Magento/Sales/Model/Order.php
index 7372d9715c725..9f30342ed331f 100644
--- a/app/code/Magento/Sales/Model/Order.php
+++ b/app/code/Magento/Sales/Model/Order.php
@@ -16,7 +16,7 @@
use Magento\Sales\Model\ResourceModel\Order\Address\Collection;
use Magento\Sales\Model\ResourceModel\Order\Creditmemo\Collection as CreditmemoCollection;
use Magento\Sales\Model\ResourceModel\Order\Invoice\Collection as InvoiceCollection;
-use Magento\Sales\Model\ResourceModel\Order\Item\Collection as ImportCollection;
+use Magento\Sales\Model\ResourceModel\Order\Item\Collection as ItemCollection;
use Magento\Sales\Model\ResourceModel\Order\Payment\Collection as PaymentCollection;
use Magento\Sales\Model\ResourceModel\Order\Shipment\Collection as ShipmentCollection;
use Magento\Sales\Model\ResourceModel\Order\Shipment\Track\Collection as TrackCollection;
@@ -564,6 +564,7 @@ public function canCancel()
/**
* Getter whether the payment can be voided
+ *
* @return bool
*/
public function canVoidPayment()
@@ -880,7 +881,7 @@ protected function _placePayment()
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getPayment()
{
@@ -1008,6 +1009,7 @@ public function addStatusToHistory($status, $comment = '', $isCustomerNotified =
/**
* Add a comment to order
+ *
* Different or default status may be specified
*
* @param string $comment
@@ -1023,6 +1025,7 @@ public function addStatusHistoryComment($comment, $status = false)
/**
* Add a comment to order status history
+ *
* Different or default status may be specified
*
* @param string $comment
@@ -1088,6 +1091,8 @@ public function place()
}
/**
+ * Hold order
+ *
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
@@ -1233,6 +1238,8 @@ public function getShippingMethod($asObject = false)
/*********************** ADDRESSES ***************************/
/**
+ * Returns address collection instance
+ *
* @return Collection
*/
public function getAddressesCollection()
@@ -1247,6 +1254,8 @@ public function getAddressesCollection()
}
/**
+ * Returns address by id
+ *
* @param mixed $addressId
* @return false
*/
@@ -1261,6 +1270,8 @@ public function getAddressById($addressId)
}
/**
+ * Add address to order
+ *
* @param \Magento\Sales\Model\Order\Address $address
* @return $this
*/
@@ -1275,9 +1286,11 @@ public function addAddress(\Magento\Sales\Model\Order\Address $address)
}
/**
+ * Returns items collection
+ *
* @param array $filterByTypes
* @param bool $nonChildrenOnly
- * @return ImportCollection
+ * @return ItemCollection
*/
public function getItemsCollection($filterByTypes = [], $nonChildrenOnly = false)
{
@@ -1302,7 +1315,7 @@ public function getItemsCollection($filterByTypes = [], $nonChildrenOnly = false
* Get random items collection without related children
*
* @param int $limit
- * @return ImportCollection
+ * @return ItemCollection
*/
public function getParentItemsRandomCollection($limit = 1)
{
@@ -1314,7 +1327,7 @@ public function getParentItemsRandomCollection($limit = 1)
*
* @param int $limit
* @param bool $nonChildrenOnly
- * @return ImportCollection
+ * @return ItemCollection
*/
protected function _getItemsRandomCollection($limit, $nonChildrenOnly = false)
{
@@ -1347,6 +1360,8 @@ protected function _getItemsRandomCollection($limit, $nonChildrenOnly = false)
}
/**
+ * Returns all order items
+ *
* @return \Magento\Sales\Model\Order\Item[]
*/
public function getAllItems()
@@ -1361,6 +1376,8 @@ public function getAllItems()
}
/**
+ * Returns all visible items
+ *
* @return array
*/
public function getAllVisibleItems()
@@ -1392,6 +1409,8 @@ public function getItemById($itemId)
}
/**
+ * Returns Item By QuoteItem Id
+ *
* @param mixed $quoteItemId
* @return \Magento\Framework\DataObject|null
*/
@@ -1406,6 +1425,8 @@ public function getItemByQuoteItemId($quoteItemId)
}
/**
+ * Add item to order
+ *
* @param \Magento\Sales\Model\Order\Item $item
* @return $this
*/
@@ -1421,6 +1442,8 @@ public function addItem(\Magento\Sales\Model\Order\Item $item)
/*********************** PAYMENTS ***************************/
/**
+ * Returns payment collection
+ *
* @return PaymentCollection
*/
public function getPaymentsCollection()
@@ -1435,6 +1458,8 @@ public function getPaymentsCollection()
}
/**
+ * Returns all payments
+ *
* @return array
*/
public function getAllPayments()
@@ -1449,6 +1474,8 @@ public function getAllPayments()
}
/**
+ * Returns payment by id
+ *
* @param mixed $paymentId
* @return Payment|false
*/
@@ -1463,7 +1490,7 @@ public function getPaymentById($paymentId)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setPayment(\Magento\Sales\Api\Data\OrderPaymentInterface $payment = null)
{
@@ -1530,6 +1557,8 @@ public function getVisibleStatusHistory()
}
/**
+ * Returns status history by id
+ *
* @param mixed $statusId
* @return string|false
*/
@@ -1545,6 +1574,7 @@ public function getStatusHistoryById($statusId)
/**
* Set the order status history object and the order object to each other
+ *
* Adds the object to the status history collection, which is automatically saved when the order is saved.
* See the entity_id attribute backend model.
* Or the history record can be saved standalone after this.
@@ -1564,6 +1594,8 @@ public function addStatusHistory(\Magento\Sales\Model\Order\Status\History $hist
}
/**
+ * Returns real order id
+ *
* @return string
*/
public function getRealOrderId()
@@ -1592,9 +1624,9 @@ public function getOrderCurrency()
/**
* Get formatted price value including order currency rate to order website currency
*
- * @param float $price
- * @param bool $addBrackets
- * @return string
+ * @param float $price
+ * @param bool $addBrackets
+ * @return string
*/
public function formatPrice($price, $addBrackets = false)
{
@@ -1602,6 +1634,8 @@ public function formatPrice($price, $addBrackets = false)
}
/**
+ * Format price precision
+ *
* @param float $price
* @param int $precision
* @param bool $addBrackets
@@ -1615,8 +1649,8 @@ public function formatPricePrecision($price, $precision, $addBrackets = false)
/**
* Retrieve text formatted price value including order rate
*
- * @param float $price
- * @return string
+ * @param float $price
+ * @return string
*/
public function formatPriceTxt($price)
{
@@ -1637,6 +1671,8 @@ public function getBaseCurrency()
}
/**
+ * Format base price
+ *
* @param float $price
* @return string
*/
@@ -1646,6 +1682,8 @@ public function formatBasePrice($price)
}
/**
+ * Format Base Price Precision
+ *
* @param float $price
* @param int $precision
* @return string
@@ -1656,6 +1694,8 @@ public function formatBasePricePrecision($price, $precision)
}
/**
+ * Is Currency Different
+ *
* @return bool
*/
public function isCurrencyDifferent()
@@ -1688,6 +1728,8 @@ public function getBaseTotalDue()
}
/**
+ * Returns object data
+ *
* @param string $key
* @param null|string|int $index
* @return mixed
@@ -1828,6 +1870,8 @@ public function getRelatedObjects()
}
/**
+ * Returns customer name
+ *
* @return string
*/
public function getCustomerName()
@@ -1855,8 +1899,8 @@ public function addRelatedObject(\Magento\Framework\Model\AbstractModel $object)
/**
* Get formatted order created date in store timezone
*
- * @param string $format date format type (short|medium|long|full)
- * @return string
+ * @param string $format date format type (short|medium|long|full)
+ * @return string
*/
public function getCreatedAtFormatted($format)
{
@@ -1870,6 +1914,8 @@ public function getCreatedAtFormatted($format)
}
/**
+ * Returns email customer note
+ *
* @return string
*/
public function getEmailCustomerNote()
@@ -1881,6 +1927,8 @@ public function getEmailCustomerNote()
}
/**
+ * Returns store group name
+ *
* @return string
*/
public function getStoreGroupName()
@@ -1894,7 +1942,8 @@ public function getStoreGroupName()
/**
* Resets all data in object
- * so after another load it will be complete new object
+ *
+ * So after another load it will be complete new object
*
* @return $this
*/
@@ -1918,6 +1967,8 @@ public function reset()
}
/**
+ * Get order is not virtual
+ *
* @return bool
* @SuppressWarnings(PHPMD.BooleanGetMethodName)
*/
@@ -1960,6 +2011,8 @@ public function getIncrementId()
}
/**
+ * Returns order items
+ *
* @return \Magento\Sales\Api\Data\OrderItemInterface[]
*/
public function getItems()
@@ -1974,7 +2027,7 @@ public function getItems()
}
/**
- * {@inheritdoc}
+ * @inheritdoc
* @codeCoverageIgnore
*/
public function setItems($items)
@@ -1983,6 +2036,8 @@ public function setItems($items)
}
/**
+ * Returns order addresses
+ *
* @return \Magento\Sales\Api\Data\OrderAddressInterface[]
*/
public function getAddresses()
@@ -1997,6 +2052,8 @@ public function getAddresses()
}
/**
+ * Returns status history
+ *
* @return \Magento\Sales\Api\Data\OrderStatusHistoryInterface[]|null
*/
public function getStatusHistories()
@@ -2011,7 +2068,7 @@ public function getStatusHistories()
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*
* @return \Magento\Sales\Api\Data\OrderExtensionInterface|null
*/
@@ -2021,7 +2078,7 @@ public function getExtensionAttributes()
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*
* @param \Magento\Sales\Api\Data\OrderExtensionInterface $extensionAttributes
* @return $this
@@ -2504,7 +2561,7 @@ public function getCreatedAt()
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setCreatedAt($createdAt)
{
@@ -3322,7 +3379,7 @@ public function getXForwardedFor()
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setStatusHistories(array $statusHistories = null)
{
@@ -3330,7 +3387,7 @@ public function setStatusHistories(array $statusHistories = null)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setStatus($status)
{
@@ -3338,7 +3395,7 @@ public function setStatus($status)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setCouponCode($code)
{
@@ -3346,7 +3403,7 @@ public function setCouponCode($code)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setProtectCode($code)
{
@@ -3354,7 +3411,7 @@ public function setProtectCode($code)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setShippingDescription($description)
{
@@ -3362,7 +3419,7 @@ public function setShippingDescription($description)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setIsVirtual($isVirtual)
{
@@ -3370,7 +3427,7 @@ public function setIsVirtual($isVirtual)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setStoreId($id)
{
@@ -3378,7 +3435,7 @@ public function setStoreId($id)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setCustomerId($id)
{
@@ -3386,7 +3443,7 @@ public function setCustomerId($id)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseDiscountAmount($amount)
{
@@ -3394,7 +3451,7 @@ public function setBaseDiscountAmount($amount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseDiscountCanceled($baseDiscountCanceled)
{
@@ -3402,7 +3459,7 @@ public function setBaseDiscountCanceled($baseDiscountCanceled)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseDiscountInvoiced($baseDiscountInvoiced)
{
@@ -3410,7 +3467,7 @@ public function setBaseDiscountInvoiced($baseDiscountInvoiced)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseDiscountRefunded($baseDiscountRefunded)
{
@@ -3418,7 +3475,7 @@ public function setBaseDiscountRefunded($baseDiscountRefunded)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseGrandTotal($amount)
{
@@ -3426,7 +3483,7 @@ public function setBaseGrandTotal($amount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseShippingAmount($amount)
{
@@ -3434,7 +3491,7 @@ public function setBaseShippingAmount($amount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseShippingCanceled($baseShippingCanceled)
{
@@ -3442,7 +3499,7 @@ public function setBaseShippingCanceled($baseShippingCanceled)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseShippingInvoiced($baseShippingInvoiced)
{
@@ -3450,7 +3507,7 @@ public function setBaseShippingInvoiced($baseShippingInvoiced)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseShippingRefunded($baseShippingRefunded)
{
@@ -3458,7 +3515,7 @@ public function setBaseShippingRefunded($baseShippingRefunded)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseShippingTaxAmount($amount)
{
@@ -3466,7 +3523,7 @@ public function setBaseShippingTaxAmount($amount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseShippingTaxRefunded($baseShippingTaxRefunded)
{
@@ -3474,7 +3531,7 @@ public function setBaseShippingTaxRefunded($baseShippingTaxRefunded)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseSubtotal($amount)
{
@@ -3482,7 +3539,7 @@ public function setBaseSubtotal($amount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseSubtotalCanceled($baseSubtotalCanceled)
{
@@ -3490,7 +3547,7 @@ public function setBaseSubtotalCanceled($baseSubtotalCanceled)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseSubtotalInvoiced($baseSubtotalInvoiced)
{
@@ -3498,7 +3555,7 @@ public function setBaseSubtotalInvoiced($baseSubtotalInvoiced)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseSubtotalRefunded($baseSubtotalRefunded)
{
@@ -3506,7 +3563,7 @@ public function setBaseSubtotalRefunded($baseSubtotalRefunded)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseTaxAmount($amount)
{
@@ -3514,7 +3571,7 @@ public function setBaseTaxAmount($amount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseTaxCanceled($baseTaxCanceled)
{
@@ -3522,7 +3579,7 @@ public function setBaseTaxCanceled($baseTaxCanceled)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseTaxInvoiced($baseTaxInvoiced)
{
@@ -3530,7 +3587,7 @@ public function setBaseTaxInvoiced($baseTaxInvoiced)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseTaxRefunded($baseTaxRefunded)
{
@@ -3538,7 +3595,7 @@ public function setBaseTaxRefunded($baseTaxRefunded)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseToGlobalRate($rate)
{
@@ -3546,7 +3603,7 @@ public function setBaseToGlobalRate($rate)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseToOrderRate($rate)
{
@@ -3554,7 +3611,7 @@ public function setBaseToOrderRate($rate)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseTotalCanceled($baseTotalCanceled)
{
@@ -3562,7 +3619,7 @@ public function setBaseTotalCanceled($baseTotalCanceled)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseTotalInvoiced($baseTotalInvoiced)
{
@@ -3570,7 +3627,7 @@ public function setBaseTotalInvoiced($baseTotalInvoiced)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseTotalInvoicedCost($baseTotalInvoicedCost)
{
@@ -3578,7 +3635,7 @@ public function setBaseTotalInvoicedCost($baseTotalInvoicedCost)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseTotalOfflineRefunded($baseTotalOfflineRefunded)
{
@@ -3586,7 +3643,7 @@ public function setBaseTotalOfflineRefunded($baseTotalOfflineRefunded)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseTotalOnlineRefunded($baseTotalOnlineRefunded)
{
@@ -3594,7 +3651,7 @@ public function setBaseTotalOnlineRefunded($baseTotalOnlineRefunded)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseTotalPaid($baseTotalPaid)
{
@@ -3602,7 +3659,7 @@ public function setBaseTotalPaid($baseTotalPaid)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseTotalQtyOrdered($baseTotalQtyOrdered)
{
@@ -3610,7 +3667,7 @@ public function setBaseTotalQtyOrdered($baseTotalQtyOrdered)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseTotalRefunded($baseTotalRefunded)
{
@@ -3618,7 +3675,7 @@ public function setBaseTotalRefunded($baseTotalRefunded)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setDiscountAmount($amount)
{
@@ -3626,7 +3683,7 @@ public function setDiscountAmount($amount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setDiscountCanceled($discountCanceled)
{
@@ -3634,7 +3691,7 @@ public function setDiscountCanceled($discountCanceled)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setDiscountInvoiced($discountInvoiced)
{
@@ -3642,7 +3699,7 @@ public function setDiscountInvoiced($discountInvoiced)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setDiscountRefunded($discountRefunded)
{
@@ -3650,7 +3707,7 @@ public function setDiscountRefunded($discountRefunded)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setGrandTotal($amount)
{
@@ -3658,7 +3715,7 @@ public function setGrandTotal($amount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setShippingAmount($amount)
{
@@ -3666,7 +3723,7 @@ public function setShippingAmount($amount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setShippingCanceled($shippingCanceled)
{
@@ -3674,7 +3731,7 @@ public function setShippingCanceled($shippingCanceled)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setShippingInvoiced($shippingInvoiced)
{
@@ -3682,7 +3739,7 @@ public function setShippingInvoiced($shippingInvoiced)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setShippingRefunded($shippingRefunded)
{
@@ -3690,7 +3747,7 @@ public function setShippingRefunded($shippingRefunded)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setShippingTaxAmount($amount)
{
@@ -3698,7 +3755,7 @@ public function setShippingTaxAmount($amount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setShippingTaxRefunded($shippingTaxRefunded)
{
@@ -3706,7 +3763,7 @@ public function setShippingTaxRefunded($shippingTaxRefunded)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setStoreToBaseRate($rate)
{
@@ -3714,7 +3771,7 @@ public function setStoreToBaseRate($rate)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setStoreToOrderRate($rate)
{
@@ -3722,7 +3779,7 @@ public function setStoreToOrderRate($rate)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setSubtotal($amount)
{
@@ -3730,7 +3787,7 @@ public function setSubtotal($amount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setSubtotalCanceled($subtotalCanceled)
{
@@ -3738,7 +3795,7 @@ public function setSubtotalCanceled($subtotalCanceled)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setSubtotalInvoiced($subtotalInvoiced)
{
@@ -3746,7 +3803,7 @@ public function setSubtotalInvoiced($subtotalInvoiced)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setSubtotalRefunded($subtotalRefunded)
{
@@ -3754,7 +3811,7 @@ public function setSubtotalRefunded($subtotalRefunded)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setTaxAmount($amount)
{
@@ -3762,7 +3819,7 @@ public function setTaxAmount($amount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setTaxCanceled($taxCanceled)
{
@@ -3770,7 +3827,7 @@ public function setTaxCanceled($taxCanceled)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setTaxInvoiced($taxInvoiced)
{
@@ -3778,7 +3835,7 @@ public function setTaxInvoiced($taxInvoiced)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setTaxRefunded($taxRefunded)
{
@@ -3786,7 +3843,7 @@ public function setTaxRefunded($taxRefunded)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setTotalCanceled($totalCanceled)
{
@@ -3794,7 +3851,7 @@ public function setTotalCanceled($totalCanceled)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setTotalInvoiced($totalInvoiced)
{
@@ -3802,7 +3859,7 @@ public function setTotalInvoiced($totalInvoiced)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setTotalOfflineRefunded($totalOfflineRefunded)
{
@@ -3810,7 +3867,7 @@ public function setTotalOfflineRefunded($totalOfflineRefunded)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setTotalOnlineRefunded($totalOnlineRefunded)
{
@@ -3818,7 +3875,7 @@ public function setTotalOnlineRefunded($totalOnlineRefunded)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setTotalPaid($totalPaid)
{
@@ -3826,7 +3883,7 @@ public function setTotalPaid($totalPaid)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setTotalQtyOrdered($totalQtyOrdered)
{
@@ -3834,7 +3891,7 @@ public function setTotalQtyOrdered($totalQtyOrdered)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setTotalRefunded($totalRefunded)
{
@@ -3842,7 +3899,7 @@ public function setTotalRefunded($totalRefunded)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setCanShipPartially($flag)
{
@@ -3850,7 +3907,7 @@ public function setCanShipPartially($flag)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setCanShipPartiallyItem($flag)
{
@@ -3858,7 +3915,7 @@ public function setCanShipPartiallyItem($flag)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setCustomerIsGuest($customerIsGuest)
{
@@ -3866,7 +3923,7 @@ public function setCustomerIsGuest($customerIsGuest)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setCustomerNoteNotify($customerNoteNotify)
{
@@ -3874,7 +3931,7 @@ public function setCustomerNoteNotify($customerNoteNotify)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBillingAddressId($id)
{
@@ -3882,7 +3939,7 @@ public function setBillingAddressId($id)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setCustomerGroupId($id)
{
@@ -3890,7 +3947,7 @@ public function setCustomerGroupId($id)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setEditIncrement($editIncrement)
{
@@ -3898,7 +3955,7 @@ public function setEditIncrement($editIncrement)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setEmailSent($emailSent)
{
@@ -3906,7 +3963,7 @@ public function setEmailSent($emailSent)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setForcedShipmentWithInvoice($forcedShipmentWithInvoice)
{
@@ -3914,7 +3971,7 @@ public function setForcedShipmentWithInvoice($forcedShipmentWithInvoice)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setPaymentAuthExpiration($paymentAuthExpiration)
{
@@ -3922,7 +3979,7 @@ public function setPaymentAuthExpiration($paymentAuthExpiration)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setQuoteAddressId($id)
{
@@ -3930,7 +3987,7 @@ public function setQuoteAddressId($id)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setQuoteId($id)
{
@@ -3938,7 +3995,7 @@ public function setQuoteId($id)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setAdjustmentNegative($adjustmentNegative)
{
@@ -3946,7 +4003,7 @@ public function setAdjustmentNegative($adjustmentNegative)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setAdjustmentPositive($adjustmentPositive)
{
@@ -3954,7 +4011,7 @@ public function setAdjustmentPositive($adjustmentPositive)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseAdjustmentNegative($baseAdjustmentNegative)
{
@@ -3962,7 +4019,7 @@ public function setBaseAdjustmentNegative($baseAdjustmentNegative)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseAdjustmentPositive($baseAdjustmentPositive)
{
@@ -3970,7 +4027,7 @@ public function setBaseAdjustmentPositive($baseAdjustmentPositive)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseShippingDiscountAmount($amount)
{
@@ -3978,7 +4035,7 @@ public function setBaseShippingDiscountAmount($amount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseSubtotalInclTax($amount)
{
@@ -3986,7 +4043,7 @@ public function setBaseSubtotalInclTax($amount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseTotalDue($baseTotalDue)
{
@@ -3994,7 +4051,7 @@ public function setBaseTotalDue($baseTotalDue)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setPaymentAuthorizationAmount($amount)
{
@@ -4002,7 +4059,7 @@ public function setPaymentAuthorizationAmount($amount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setShippingDiscountAmount($amount)
{
@@ -4010,7 +4067,7 @@ public function setShippingDiscountAmount($amount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setSubtotalInclTax($amount)
{
@@ -4018,7 +4075,7 @@ public function setSubtotalInclTax($amount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setTotalDue($totalDue)
{
@@ -4026,7 +4083,7 @@ public function setTotalDue($totalDue)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setWeight($weight)
{
@@ -4034,7 +4091,7 @@ public function setWeight($weight)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setCustomerDob($customerDob)
{
@@ -4042,7 +4099,7 @@ public function setCustomerDob($customerDob)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setIncrementId($id)
{
@@ -4050,7 +4107,7 @@ public function setIncrementId($id)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setAppliedRuleIds($appliedRuleIds)
{
@@ -4058,7 +4115,7 @@ public function setAppliedRuleIds($appliedRuleIds)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseCurrencyCode($code)
{
@@ -4066,7 +4123,7 @@ public function setBaseCurrencyCode($code)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setCustomerEmail($customerEmail)
{
@@ -4074,7 +4131,7 @@ public function setCustomerEmail($customerEmail)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setCustomerFirstname($customerFirstname)
{
@@ -4082,7 +4139,7 @@ public function setCustomerFirstname($customerFirstname)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setCustomerLastname($customerLastname)
{
@@ -4090,7 +4147,7 @@ public function setCustomerLastname($customerLastname)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setCustomerMiddlename($customerMiddlename)
{
@@ -4098,7 +4155,7 @@ public function setCustomerMiddlename($customerMiddlename)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setCustomerPrefix($customerPrefix)
{
@@ -4106,7 +4163,7 @@ public function setCustomerPrefix($customerPrefix)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setCustomerSuffix($customerSuffix)
{
@@ -4114,7 +4171,7 @@ public function setCustomerSuffix($customerSuffix)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setCustomerTaxvat($customerTaxvat)
{
@@ -4122,7 +4179,7 @@ public function setCustomerTaxvat($customerTaxvat)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setDiscountDescription($description)
{
@@ -4130,7 +4187,7 @@ public function setDiscountDescription($description)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setExtCustomerId($id)
{
@@ -4138,7 +4195,7 @@ public function setExtCustomerId($id)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setExtOrderId($id)
{
@@ -4146,7 +4203,7 @@ public function setExtOrderId($id)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setGlobalCurrencyCode($code)
{
@@ -4154,7 +4211,7 @@ public function setGlobalCurrencyCode($code)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setHoldBeforeState($holdBeforeState)
{
@@ -4162,7 +4219,7 @@ public function setHoldBeforeState($holdBeforeState)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setHoldBeforeStatus($holdBeforeStatus)
{
@@ -4170,7 +4227,7 @@ public function setHoldBeforeStatus($holdBeforeStatus)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setOrderCurrencyCode($code)
{
@@ -4178,7 +4235,7 @@ public function setOrderCurrencyCode($code)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setOriginalIncrementId($id)
{
@@ -4186,7 +4243,7 @@ public function setOriginalIncrementId($id)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setRelationChildId($id)
{
@@ -4194,7 +4251,7 @@ public function setRelationChildId($id)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setRelationChildRealId($realId)
{
@@ -4202,7 +4259,7 @@ public function setRelationChildRealId($realId)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setRelationParentId($id)
{
@@ -4210,7 +4267,7 @@ public function setRelationParentId($id)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setRelationParentRealId($realId)
{
@@ -4218,7 +4275,7 @@ public function setRelationParentRealId($realId)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setRemoteIp($remoteIp)
{
@@ -4226,7 +4283,7 @@ public function setRemoteIp($remoteIp)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setStoreCurrencyCode($code)
{
@@ -4234,7 +4291,7 @@ public function setStoreCurrencyCode($code)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setStoreName($storeName)
{
@@ -4242,7 +4299,7 @@ public function setStoreName($storeName)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setXForwardedFor($xForwardedFor)
{
@@ -4250,7 +4307,7 @@ public function setXForwardedFor($xForwardedFor)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setCustomerNote($customerNote)
{
@@ -4258,7 +4315,7 @@ public function setCustomerNote($customerNote)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setUpdatedAt($timestamp)
{
@@ -4266,7 +4323,7 @@ public function setUpdatedAt($timestamp)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setTotalItemCount($totalItemCount)
{
@@ -4274,7 +4331,7 @@ public function setTotalItemCount($totalItemCount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setCustomerGender($customerGender)
{
@@ -4282,7 +4339,7 @@ public function setCustomerGender($customerGender)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setDiscountTaxCompensationAmount($amount)
{
@@ -4290,7 +4347,7 @@ public function setDiscountTaxCompensationAmount($amount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseDiscountTaxCompensationAmount($amount)
{
@@ -4298,7 +4355,7 @@ public function setBaseDiscountTaxCompensationAmount($amount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setShippingDiscountTaxCompensationAmount($amount)
{
@@ -4306,7 +4363,7 @@ public function setShippingDiscountTaxCompensationAmount($amount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseShippingDiscountTaxCompensationAmnt($amnt)
{
@@ -4314,7 +4371,7 @@ public function setBaseShippingDiscountTaxCompensationAmnt($amnt)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setDiscountTaxCompensationInvoiced($discountTaxCompensationInvoiced)
{
@@ -4322,7 +4379,7 @@ public function setDiscountTaxCompensationInvoiced($discountTaxCompensationInvoi
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseDiscountTaxCompensationInvoiced($baseDiscountTaxCompensationInvoiced)
{
@@ -4333,7 +4390,7 @@ public function setBaseDiscountTaxCompensationInvoiced($baseDiscountTaxCompensat
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setDiscountTaxCompensationRefunded($discountTaxCompensationRefunded)
{
@@ -4344,7 +4401,7 @@ public function setDiscountTaxCompensationRefunded($discountTaxCompensationRefun
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseDiscountTaxCompensationRefunded($baseDiscountTaxCompensationRefunded)
{
@@ -4355,7 +4412,7 @@ public function setBaseDiscountTaxCompensationRefunded($baseDiscountTaxCompensat
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setShippingInclTax($amount)
{
@@ -4363,7 +4420,7 @@ public function setShippingInclTax($amount)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function setBaseShippingInclTax($amount)
{
diff --git a/app/code/Magento/Sales/Model/Order/Status.php b/app/code/Magento/Sales/Model/Order/Status.php
index 288955705425f..4b33f4b4d9251 100644
--- a/app/code/Magento/Sales/Model/Order/Status.php
+++ b/app/code/Magento/Sales/Model/Order/Status.php
@@ -12,6 +12,7 @@
* Class Status
*
* @method string getStatus()
+ * @method $this setStatus(string $status)
* @method string getLabel()
*/
class Status extends \Magento\Sales\Model\AbstractModel
diff --git a/app/code/Magento/Sales/Test/Unit/Model/ValidatorResultMergerTest.php b/app/code/Magento/Sales/Test/Unit/Model/ValidatorResultMergerTest.php
new file mode 100644
index 0000000000000..4236890a2a37d
--- /dev/null
+++ b/app/code/Magento/Sales/Test/Unit/Model/ValidatorResultMergerTest.php
@@ -0,0 +1,87 @@
+validatorResultFactoryMock = $this->getMockBuilder(ValidatorResultInterfaceFactory::class)
+ ->setMethods(['create'])->disableOriginalConstructor()->getMock();
+ $this->objectManager = new ObjectManager($this);
+ $this->validatorResultMerger = $this->objectManager->getObject(
+ ValidatorResultMerger::class,
+ [
+ 'validatorResultInterfaceFactory' => $this->validatorResultFactoryMock,
+ ]
+ );
+ }
+
+ /**
+ * Test merge method
+ *
+ * @return void
+ */
+ public function testMerge()
+ {
+ $validatorResultMock = $this->createMock(ValidatorResultInterface::class);
+ $orderValidationResultMock = $this->createMock(ValidatorResultInterface::class);
+ $creditmemoValidationResultMock = $this->createMock(ValidatorResultInterface::class);
+ $itemsValidationMessages = [['test04', 'test05'], ['test06']];
+ $this->validatorResultFactoryMock->expects($this->once())->method('create')
+ ->willReturn($validatorResultMock);
+ $orderValidationResultMock->expects($this->once())->method('getMessages')->willReturn(['test01', 'test02']);
+ $creditmemoValidationResultMock->expects($this->once())->method('getMessages')->willReturn(['test03']);
+
+ $validatorResultMock->expects($this->at(0))->method('addMessage')->with('test01');
+ $validatorResultMock->expects($this->at(1))->method('addMessage')->with('test02');
+ $validatorResultMock->expects($this->at(2))->method('addMessage')->with('test03');
+ $validatorResultMock->expects($this->at(3))->method('addMessage')->with('test04');
+ $validatorResultMock->expects($this->at(4))->method('addMessage')->with('test05');
+ $validatorResultMock->expects($this->at(5))->method('addMessage')->with('test06');
+ $expected = $validatorResultMock;
+ $actual = $this->validatorResultMerger->merge(
+ $orderValidationResultMock,
+ $creditmemoValidationResultMock,
+ ...$itemsValidationMessages
+ );
+ $this->assertEquals($expected, $actual);
+ }
+}
diff --git a/app/code/Magento/Sales/Test/Unit/Model/ValidatorResultTest.php b/app/code/Magento/Sales/Test/Unit/Model/ValidatorResultTest.php
new file mode 100644
index 0000000000000..f4ab2d4f48e6f
--- /dev/null
+++ b/app/code/Magento/Sales/Test/Unit/Model/ValidatorResultTest.php
@@ -0,0 +1,75 @@
+objectManager = new ObjectManager($this);
+ $this->validatorResult = $this->objectManager->getObject(ValidatorResult::class);
+ }
+
+ /**
+ * Test addMessage method
+ *
+ * @return void
+ */
+ public function testAddMessages()
+ {
+ $messageFirst = 'Sample message 01.';
+ $messageSecond = 'Sample messages 02.';
+ $messageThird = 'Sample messages 03.';
+ $expected = [$messageFirst, $messageSecond, $messageThird];
+ $this->validatorResult->addMessage($messageFirst);
+ $this->validatorResult->addMessage($messageSecond);
+ $this->validatorResult->addMessage($messageThird);
+ $actual = $this->validatorResult->getMessages();
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * Test hasMessages method
+ *
+ * @return void
+ */
+ public function testHasMessages()
+ {
+ $this->assertFalse($this->validatorResult->hasMessages());
+ $messageFirst = 'Sample message 01.';
+ $messageSecond = 'Sample messages 02.';
+ $this->validatorResult->addMessage($messageFirst);
+ $this->validatorResult->addMessage($messageSecond);
+ $this->assertTrue($this->validatorResult->hasMessages());
+ }
+}
diff --git a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/DeleteButton.php b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/DeleteButton.php
index 0cb286056d825..bee7573c1fe2a 100644
--- a/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/DeleteButton.php
+++ b/app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/DeleteButton.php
@@ -26,7 +26,7 @@ public function getButtonData()
'class' => 'delete',
'on_click' => 'deleteConfirm(\'' . __(
'Are you sure you want to delete this?'
- ) . '\', \'' . $this->urlBuilder->getUrl('*/*/delete', ['id' => $ruleId]) . '\')',
+ ) . '\', \'' . $this->urlBuilder->getUrl('*/*/delete', ['id' => $ruleId]) . '\', {data: {}})',
'sort_order' => 20,
];
}
diff --git a/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Delete.php b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Delete.php
index 28993e159499b..45b717fb9bd2d 100644
--- a/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Delete.php
+++ b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Delete.php
@@ -6,7 +6,9 @@
*/
namespace Magento\SalesRule\Controller\Adminhtml\Promo\Quote;
-class Delete extends \Magento\SalesRule\Controller\Adminhtml\Promo\Quote
+use Magento\Framework\App\Action\HttpPostActionInterface;
+
+class Delete extends \Magento\SalesRule\Controller\Adminhtml\Promo\Quote implements HttpPostActionInterface
{
/**
* Delete promo quote action
diff --git a/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Edit.php b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Edit.php
index 717c71fde4837..3255ee0f2b724 100644
--- a/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Edit.php
+++ b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Edit.php
@@ -6,7 +6,9 @@
*/
namespace Magento\SalesRule\Controller\Adminhtml\Promo\Quote;
-class Edit extends \Magento\SalesRule\Controller\Adminhtml\Promo\Quote
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Edit extends \Magento\SalesRule\Controller\Adminhtml\Promo\Quote implements HttpGetActionInterface
{
/**
* @var \Magento\Framework\View\Result\PageFactory
diff --git a/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Index.php b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Index.php
index 0c11ee3785a08..4f3c712049e43 100644
--- a/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Index.php
+++ b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/Index.php
@@ -6,7 +6,9 @@
*/
namespace Magento\SalesRule\Controller\Adminhtml\Promo\Quote;
-class Index extends \Magento\SalesRule\Controller\Adminhtml\Promo\Quote
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Index extends \Magento\SalesRule\Controller\Adminhtml\Promo\Quote implements HttpGetActionInterface
{
/**
* Index action
diff --git a/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/NewAction.php b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/NewAction.php
index ecf39605a8709..5adef0552bc8b 100644
--- a/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/NewAction.php
+++ b/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/NewAction.php
@@ -6,7 +6,9 @@
*/
namespace Magento\SalesRule\Controller\Adminhtml\Promo\Quote;
-class NewAction extends \Magento\SalesRule\Controller\Adminhtml\Promo\Quote
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class NewAction extends \Magento\SalesRule\Controller\Adminhtml\Promo\Quote implements HttpGetActionInterface
{
/**
* New promo quote action
diff --git a/app/code/Magento/SalesRule/Test/Unit/Block/Adminhtml/Promo/Quote/Edit/DeleteButtonTest.php b/app/code/Magento/SalesRule/Test/Unit/Block/Adminhtml/Promo/Quote/Edit/DeleteButtonTest.php
index fb01476ed6b34..7812444c68694 100644
--- a/app/code/Magento/SalesRule/Test/Unit/Block/Adminhtml/Promo/Quote/Edit/DeleteButtonTest.php
+++ b/app/code/Magento/SalesRule/Test/Unit/Block/Adminhtml/Promo/Quote/Edit/DeleteButtonTest.php
@@ -25,13 +25,16 @@ class DeleteButtonTest extends \PHPUnit\Framework\TestCase
*/
protected $registryMock;
+ /**
+ * @inheritDoc
+ */
protected function setUp()
{
$this->urlBuilderMock = $this->createMock(\Magento\Framework\UrlInterface::class);
$this->registryMock = $this->createMock(\Magento\Framework\Registry::class);
$contextMock = $this->createMock(\Magento\Backend\Block\Widget\Context::class);
- $contextMock->expects($this->once())->method('getUrlBuilder')->willReturn($this->urlBuilderMock);
+ $contextMock->expects($this->any())->method('getUrlBuilder')->willReturn($this->urlBuilderMock);
$this->model = (new ObjectManager($this))->getObject(
\Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\DeleteButton::class,
@@ -42,33 +45,9 @@ protected function setUp()
);
}
- public function testGetButtonData()
- {
- $ruleId = 42;
- $deleteUrl = 'http://magento.com/rule/delete/' . $ruleId;
- $ruleMock = new \Magento\Framework\DataObject(['id' => $ruleId]);
-
- $this->registryMock->expects($this->once())
- ->method('registry')
- ->with(RegistryConstants::CURRENT_SALES_RULE)
- ->willReturn($ruleMock);
- $this->urlBuilderMock->expects($this->once())
- ->method('getUrl')
- ->with('*/*/delete', ['id' => $ruleId])
- ->willReturn($deleteUrl);
-
- $data = [
- 'label' => __('Delete'),
- 'class' => 'delete',
- 'on_click' => 'deleteConfirm(\'' . __(
- 'Are you sure you want to delete this?'
- ) . '\', \'' . $deleteUrl . '\')',
- 'sort_order' => 20,
- ];
-
- $this->assertEquals($data, $this->model->getButtonData());
- }
-
+ /**
+ * Test empty response without a present rule.
+ */
public function testGetButtonDataWithoutRule()
{
$this->assertEquals([], $this->model->getButtonData());
diff --git a/app/code/Magento/Search/Controller/Adminhtml/Term/Delete.php b/app/code/Magento/Search/Controller/Adminhtml/Term/Delete.php
index c7adf32da0fb0..ce3dfcc601fa4 100644
--- a/app/code/Magento/Search/Controller/Adminhtml/Term/Delete.php
+++ b/app/code/Magento/Search/Controller/Adminhtml/Term/Delete.php
@@ -5,10 +5,11 @@
*/
namespace Magento\Search\Controller\Adminhtml\Term;
+use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Search\Controller\Adminhtml\Term as TermController;
use Magento\Framework\Controller\ResultFactory;
-class Delete extends TermController
+class Delete extends TermController implements HttpPostActionInterface
{
/**
* @return \Magento\Backend\Model\View\Result\Redirect
diff --git a/app/code/Magento/Search/Controller/Adminhtml/Term/Edit.php b/app/code/Magento/Search/Controller/Adminhtml/Term/Edit.php
index 3ee0ea240377f..cd1ef7553c7ec 100644
--- a/app/code/Magento/Search/Controller/Adminhtml/Term/Edit.php
+++ b/app/code/Magento/Search/Controller/Adminhtml/Term/Edit.php
@@ -5,12 +5,13 @@
*/
namespace Magento\Search\Controller\Adminhtml\Term;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Search\Controller\Adminhtml\Term as TermController;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Registry;
use Magento\Framework\Controller\ResultFactory;
-class Edit extends TermController
+class Edit extends TermController implements HttpGetActionInterface
{
/**
* Core registry
diff --git a/app/code/Magento/Search/Controller/Adminhtml/Term/Index.php b/app/code/Magento/Search/Controller/Adminhtml/Term/Index.php
index f7d0b86590721..c097cc08489f9 100644
--- a/app/code/Magento/Search/Controller/Adminhtml/Term/Index.php
+++ b/app/code/Magento/Search/Controller/Adminhtml/Term/Index.php
@@ -5,9 +5,10 @@
*/
namespace Magento\Search\Controller\Adminhtml\Term;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Search\Controller\Adminhtml\Term as TermController;
-class Index extends TermController
+class Index extends TermController implements HttpGetActionInterface
{
/**
* @return \Magento\Backend\Model\View\Result\Page
diff --git a/app/code/Magento/Search/Controller/Adminhtml/Term/MassDelete.php b/app/code/Magento/Search/Controller/Adminhtml/Term/MassDelete.php
index f6874078f2f64..84e475b7275ae 100644
--- a/app/code/Magento/Search/Controller/Adminhtml/Term/MassDelete.php
+++ b/app/code/Magento/Search/Controller/Adminhtml/Term/MassDelete.php
@@ -5,10 +5,11 @@
*/
namespace Magento\Search\Controller\Adminhtml\Term;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Search\Controller\Adminhtml\Term as TermController;
use Magento\Framework\Controller\ResultFactory;
-class MassDelete extends TermController
+class MassDelete extends TermController implements HttpPostActionInterface
{
/**
* @return \Magento\Backend\Model\View\Result\Redirect
diff --git a/app/code/Magento/Search/Controller/Adminhtml/Term/NewAction.php b/app/code/Magento/Search/Controller/Adminhtml/Term/NewAction.php
index 8565c03724c65..49805400713fc 100644
--- a/app/code/Magento/Search/Controller/Adminhtml/Term/NewAction.php
+++ b/app/code/Magento/Search/Controller/Adminhtml/Term/NewAction.php
@@ -5,10 +5,11 @@
*/
namespace Magento\Search\Controller\Adminhtml\Term;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Search\Controller\Adminhtml\Term as TermController;
use Magento\Framework\Controller\ResultFactory;
-class NewAction extends TermController
+class NewAction extends TermController implements HttpGetActionInterface
{
/**
* @return \Magento\Backend\Model\View\Result\Forward
diff --git a/app/code/Magento/Search/Controller/Adminhtml/Term/Report.php b/app/code/Magento/Search/Controller/Adminhtml/Term/Report.php
index fb4964717e565..b0ce066f12709 100644
--- a/app/code/Magento/Search/Controller/Adminhtml/Term/Report.php
+++ b/app/code/Magento/Search/Controller/Adminhtml/Term/Report.php
@@ -5,10 +5,11 @@
*/
namespace Magento\Search\Controller\Adminhtml\Term;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Reports\Controller\Adminhtml\Index as ReportsIndexController;
use Magento\Framework\Controller\ResultFactory;
-class Report extends ReportsIndexController
+class Report extends ReportsIndexController implements HttpGetActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Search/Controller/Adminhtml/Term/Save.php b/app/code/Magento/Search/Controller/Adminhtml/Term/Save.php
index cd9b1347ed1ed..39ae07f0d3531 100644
--- a/app/code/Magento/Search/Controller/Adminhtml/Term/Save.php
+++ b/app/code/Magento/Search/Controller/Adminhtml/Term/Save.php
@@ -5,13 +5,14 @@
*/
namespace Magento\Search\Controller\Adminhtml\Term;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Controller\ResultFactory;
use Magento\Search\Model\QueryFactory;
use Magento\Search\Controller\Adminhtml\Term as TermController;
use Magento\Framework\Exception\LocalizedException;
-class Save extends TermController
+class Save extends TermController implements HttpPostActionInterface
{
/**
* @var QueryFactory
diff --git a/app/code/Magento/Search/Controller/Ajax/Suggest.php b/app/code/Magento/Search/Controller/Ajax/Suggest.php
index 307f4df163243..6eab0949145b7 100644
--- a/app/code/Magento/Search/Controller/Ajax/Suggest.php
+++ b/app/code/Magento/Search/Controller/Ajax/Suggest.php
@@ -5,12 +5,13 @@
*/
namespace Magento\Search\Controller\Ajax;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Search\Model\AutocompleteInterface;
use Magento\Framework\Controller\ResultFactory;
-class Suggest extends Action
+class Suggest extends Action implements HttpGetActionInterface
{
/**
* @var \Magento\Search\Model\AutocompleteInterface
diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/NewAction.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/NewAction.php
index be0555fbcda40..7231bc8b9c6e0 100644
--- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/NewAction.php
+++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/NewAction.php
@@ -6,10 +6,11 @@
*/
namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Backend\App\Action;
use Magento\Framework\App\ObjectManager;
-class NewAction extends \Magento\Backend\App\Action
+class NewAction extends \Magento\Backend\App\Action implements HttpGetActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Save.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Save.php
index 4804efcc76ecc..8bd64ccf82d88 100644
--- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Save.php
+++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Save.php
@@ -6,6 +6,7 @@
*/
namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Backend\App\Action;
use Magento\Sales\Model\Order\Shipment\Validation\QuantityValidator;
@@ -13,7 +14,7 @@
* Class Save
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class Save extends \Magento\Backend\App\Action
+class Save extends \Magento\Backend\App\Action implements HttpPostActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Start.php b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Start.php
index ac15c0accd1c3..8a874ddc79526 100644
--- a/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Start.php
+++ b/app/code/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Start.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Shipping\Controller\Adminhtml\Order\Shipment;
-class Start extends \Magento\Backend\App\Action
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Start extends \Magento\Backend\App\Action implements HttpGetActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Sitemap/Block/Robots.php b/app/code/Magento/Sitemap/Block/Robots.php
index 410bc02da3630..ac99b2ab1cd4a 100644
--- a/app/code/Magento/Sitemap/Block/Robots.php
+++ b/app/code/Magento/Sitemap/Block/Robots.php
@@ -22,11 +22,6 @@
*/
class Robots extends AbstractBlock implements IdentityInterface
{
- /**
- * @var StoreResolver
- */
- private $storeResolver;
-
/**
* @var CollectionFactory
*/
@@ -49,6 +44,8 @@ class Robots extends AbstractBlock implements IdentityInterface
* @param SitemapHelper $sitemapHelper
* @param StoreManagerInterface $storeManager
* @param array $data
+ *
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __construct(
Context $context,
@@ -58,7 +55,6 @@ public function __construct(
StoreManagerInterface $storeManager,
array $data = []
) {
- $this->storeResolver = $storeResolver;
$this->sitemapCollectionFactory = $sitemapCollectionFactory;
$this->sitemapHelper = $sitemapHelper;
$this->storeManager = $storeManager;
@@ -78,8 +74,7 @@ public function __construct(
*/
protected function _toHtml()
{
- $defaultStoreId = $this->storeResolver->getCurrentStoreId();
- $defaultStore = $this->storeManager->getStore($defaultStoreId);
+ $defaultStore = $this->storeManager->getDefaultStoreView();
/** @var \Magento\Store\Model\Website $website */
$website = $this->storeManager->getWebsite($defaultStore->getWebsiteId());
@@ -138,7 +133,7 @@ protected function getSitemapLinks(array $storeIds)
public function getIdentities()
{
return [
- Value::CACHE_TAG . '_' . $this->storeResolver->getCurrentStoreId(),
+ Value::CACHE_TAG . '_' . $this->storeManager->getDefaultStoreView()->getId(),
];
}
}
diff --git a/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Index.php b/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Index.php
index 5f2cc805de0fc..e6823c6070a1b 100644
--- a/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Index.php
+++ b/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Index.php
@@ -6,9 +6,10 @@
*/
namespace Magento\Sitemap\Controller\Adminhtml\Sitemap;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Backend\App\Action;
-class Index extends \Magento\Sitemap\Controller\Adminhtml\Sitemap
+class Index extends \Magento\Sitemap\Controller\Adminhtml\Sitemap implements HttpGetActionInterface
{
/**
* Index action
diff --git a/app/code/Magento/Sitemap/Model/Config/Backend/Robots.php b/app/code/Magento/Sitemap/Model/Config/Backend/Robots.php
index d69b8e6d44815..7a6d28259bfed 100644
--- a/app/code/Magento/Sitemap/Model/Config/Backend/Robots.php
+++ b/app/code/Magento/Sitemap/Model/Config/Backend/Robots.php
@@ -15,9 +15,11 @@
use Magento\Framework\Registry;
use Magento\Robots\Model\Config\Value as RobotsValue;
use Magento\Store\Model\StoreResolver;
+use Magento\Store\Model\StoreManagerInterface;
/**
* Backend model for sitemap/search_engines/submission_robots configuration value.
+ *
* Required to implement Page Cache functionality.
*/
class Robots extends Value implements IdentityInterface
@@ -30,9 +32,9 @@ class Robots extends Value implements IdentityInterface
protected $_cacheTag = true;
/**
- * @var StoreResolver
+ * @var StoreManagerInterface
*/
- private $storeResolver;
+ private $storeManager;
/**
* @param Context $context
@@ -40,9 +42,12 @@ class Robots extends Value implements IdentityInterface
* @param ScopeConfigInterface $config
* @param TypeListInterface $cacheTypeList
* @param StoreResolver $storeResolver
+ * @param StoreManagerInterface|null $storeManager
* @param AbstractResource|null $resource
* @param AbstractDb|null $resourceCollection
* @param array $data
+ *
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __construct(
Context $context,
@@ -50,11 +55,13 @@ public function __construct(
ScopeConfigInterface $config,
TypeListInterface $cacheTypeList,
StoreResolver $storeResolver,
+ StoreManagerInterface $storeManager = null,
AbstractResource $resource = null,
AbstractDb $resourceCollection = null,
array $data = []
) {
- $this->storeResolver = $storeResolver;
+ $this->storeManager = $storeManager ?: \Magento\Framework\App\ObjectManager::getInstance()
+ ->get(StoreManagerInterface::class);
parent::__construct(
$context,
@@ -75,7 +82,7 @@ public function __construct(
public function getIdentities()
{
return [
- RobotsValue::CACHE_TAG . '_' . $this->storeResolver->getCurrentStoreId(),
+ RobotsValue::CACHE_TAG . '_' . $this->storeManager->getStore()->getId(),
];
}
}
diff --git a/app/code/Magento/Sitemap/Test/Unit/Block/RobotsTest.php b/app/code/Magento/Sitemap/Test/Unit/Block/RobotsTest.php
index 6fcd247ab1f0f..b7cfd2028b75f 100644
--- a/app/code/Magento/Sitemap/Test/Unit/Block/RobotsTest.php
+++ b/app/code/Magento/Sitemap/Test/Unit/Block/RobotsTest.php
@@ -5,6 +5,8 @@
*/
namespace Magento\Sitemap\Test\Unit\Block;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
@@ -77,6 +79,7 @@ protected function setUp()
$this->sitemapCollectionFactory = $this->getMockBuilder(
\Magento\Sitemap\Model\ResourceModel\Sitemap\CollectionFactory::class
)
+ ->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
@@ -109,12 +112,17 @@ public function testToHtmlRobotsSubmissionIsDisabled()
$this->initEventManagerMock($expected);
$this->scopeConfigMock->expects($this->once())->method('getValue')->willReturn(false);
- $this->storeResolver->expects($this->once())
- ->method('getCurrentStoreId')
- ->willReturn($defaultStoreId);
-
$storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
->getMockForAbstractClass();
+
+ $storeMock->expects($this->once())
+ ->method('getWebsiteId')
+ ->willReturn($defaultWebsiteId);
+
+ $this->storeManager->expects($this->once())
+ ->method('getDefaultStoreView')
+ ->willReturn($storeMock);
+
$storeMock->expects($this->any())
->method('getWebsiteId')
->willReturn($defaultWebsiteId);
@@ -126,10 +134,6 @@ public function testToHtmlRobotsSubmissionIsDisabled()
->method('getStoreIds')
->willReturn([$defaultStoreId]);
- $this->storeManager->expects($this->once())
- ->method('getStore')
- ->with($defaultStoreId)
- ->willReturn($storeMock);
$this->storeManager->expects($this->once())
->method('getWebsite')
->with($defaultWebsiteId)
@@ -165,12 +169,13 @@ public function testAfterGetDataRobotsSubmissionIsEnabled()
$this->initEventManagerMock($expected);
$this->scopeConfigMock->expects($this->once())->method('getValue')->willReturn(false);
- $this->storeResolver->expects($this->once())
- ->method('getCurrentStoreId')
- ->willReturn($defaultStoreId);
-
$storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
->getMockForAbstractClass();
+
+ $this->storeManager->expects($this->once())
+ ->method('getDefaultStoreView')
+ ->willReturn($storeMock);
+
$storeMock->expects($this->any())
->method('getWebsiteId')
->willReturn($defaultWebsiteId);
@@ -182,10 +187,6 @@ public function testAfterGetDataRobotsSubmissionIsEnabled()
->method('getStoreIds')
->willReturn([$defaultStoreId, $secondStoreId]);
- $this->storeManager->expects($this->once())
- ->method('getStore')
- ->with($defaultStoreId)
- ->willReturn($storeMock);
$this->storeManager->expects($this->once())
->method('getWebsite')
->with($defaultWebsiteId)
@@ -228,8 +229,14 @@ public function testGetIdentities()
{
$storeId = 1;
- $this->storeResolver->expects($this->once())
- ->method('getCurrentStoreId')
+ $storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)->getMockForAbstractClass();
+
+ $this->storeManager->expects($this->once())
+ ->method('getDefaultStoreView')
+ ->willReturn($storeMock);
+
+ $storeMock->expects($this->once())
+ ->method('getId')
->willReturn($storeId);
$expected = [
diff --git a/app/code/Magento/Sitemap/Test/Unit/Model/Config/Backend/RobotsTest.php b/app/code/Magento/Sitemap/Test/Unit/Model/Config/Backend/RobotsTest.php
index f3c2f90de286b..cbf353d0a93c7 100644
--- a/app/code/Magento/Sitemap/Test/Unit/Model/Config/Backend/RobotsTest.php
+++ b/app/code/Magento/Sitemap/Test/Unit/Model/Config/Backend/RobotsTest.php
@@ -37,6 +37,11 @@ class RobotsTest extends \PHPUnit\Framework\TestCase
*/
private $storeResolver;
+ /**
+ * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $storeManager;
+
protected function setUp()
{
$this->context = $this->getMockBuilder(\Magento\Framework\Model\Context::class)
@@ -57,12 +62,16 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
+ $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
+ ->getMockForAbstractClass();
+
$this->model = new \Magento\Sitemap\Model\Config\Backend\Robots(
$this->context,
$this->registry,
$this->scopeConfig,
$this->typeList,
- $this->storeResolver
+ $this->storeResolver,
+ $this->storeManager
);
}
@@ -73,8 +82,14 @@ public function testGetIdentities()
{
$storeId = 1;
- $this->storeResolver->expects($this->once())
- ->method('getCurrentStoreId')
+ $storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)->getMock();
+
+ $this->storeManager->expects($this->once())
+ ->method('getStore')
+ ->willReturn($storeMock);
+
+ $storeMock->expects($this->once())
+ ->method('getId')
->willReturn($storeId);
$expected = [
diff --git a/app/code/Magento/Store/Api/StoreResolverInterface.php b/app/code/Magento/Store/Api/StoreResolverInterface.php
index 7eb28729ec239..7c32e321fa6c4 100644
--- a/app/code/Magento/Store/Api/StoreResolverInterface.php
+++ b/app/code/Magento/Store/Api/StoreResolverInterface.php
@@ -8,8 +8,8 @@
/**
* Store resolver interface
*
- * @api
- * @since 100.0.2
+ * @deprecated
+ * @see \Magento\Store\Model\StoreManagerInterface
*/
interface StoreResolverInterface
{
diff --git a/app/code/Magento/Store/App/Action/Plugin/Context.php b/app/code/Magento/Store/App/Action/Plugin/Context.php
index 6ec6cf01bc71c..0d34179d3c63e 100644
--- a/app/code/Magento/Store/App/Action/Plugin/Context.php
+++ b/app/code/Magento/Store/App/Action/Plugin/Context.php
@@ -9,10 +9,8 @@
use Magento\Framework\App\Http\Context as HttpContext;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Exception\NotFoundException;
-use Magento\Framework\Phrase;
use Magento\Store\Api\Data\StoreInterface;
use Magento\Store\Api\StoreCookieManagerInterface;
-use Magento\Store\Api\StoreResolverInterface;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\App\Action\AbstractAction;
use Magento\Framework\App\RequestInterface;
@@ -80,7 +78,7 @@ public function beforeDispatch(
/** @var string|array|null $storeCode */
$storeCode = $request->getParam(
- StoreResolverInterface::PARAM_NAME,
+ \Magento\Store\Model\StoreManagerInterface::PARAM_NAME,
$this->storeCookieManager->getStoreCodeFromCookie()
);
if (is_array($storeCode)) {
@@ -106,7 +104,7 @@ public function beforeDispatch(
/**
* Take action in case of invalid store requested.
*
- * @param \Throwable|null $previousException
+ * @param \Throwable|null $previousException
* @return void
* @throws NotFoundException
*/
diff --git a/app/code/Magento/Store/App/Request/PathInfoProcessor.php b/app/code/Magento/Store/App/Request/PathInfoProcessor.php
index 3fa78dc94aa35..fad0d07c3a0a7 100644
--- a/app/code/Magento/Store/App/Request/PathInfoProcessor.php
+++ b/app/code/Magento/Store/App/Request/PathInfoProcessor.php
@@ -3,56 +3,75 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Store\App\Request;
+declare(strict_types=1);
-use Magento\Framework\Exception\NoSuchEntityException;
-use Magento\Store\Model\Store;
+namespace Magento\Store\App\Request;
+/**
+ * Processes the path and looks for the store in the url and removes it and modifies the path accordingly.
+ */
class PathInfoProcessor implements \Magento\Framework\App\Request\PathInfoProcessorInterface
{
/**
- * @var \Magento\Store\Model\StoreManagerInterface
+ * @var StorePathInfoValidator
*/
- private $storeManager;
+ private $storePathInfoValidator;
/**
- * @param \Magento\Store\Model\StoreManagerInterface $storeManager
+ * @var \Magento\Framework\App\Config\ReinitableConfigInterface
*/
- public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager)
- {
- $this->storeManager = $storeManager;
+ private $config;
+
+ /**
+ * @param \Magento\Store\App\Request\StorePathInfoValidator $storePathInfoValidator
+ * @param \Magento\Framework\App\Config\ReinitableConfigInterface $config
+ */
+ public function __construct(
+ \Magento\Store\App\Request\StorePathInfoValidator $storePathInfoValidator,
+ \Magento\Framework\App\Config\ReinitableConfigInterface $config
+ ) {
+ $this->storePathInfoValidator = $storePathInfoValidator;
+ $this->config = $config;
}
/**
- * Process path info
+ * Process path info and remove store from pathInfo.
+ *
+ * This method also sets request to no route if store is not valid and store is present in url config is enabled
*
* @param \Magento\Framework\App\RequestInterface $request
* @param string $pathInfo
* @return string
*/
- public function process(\Magento\Framework\App\RequestInterface $request, $pathInfo)
+ public function process(\Magento\Framework\App\RequestInterface $request, $pathInfo) : string
{
- $pathParts = explode('/', ltrim($pathInfo, '/'), 2);
- $storeCode = $pathParts[0];
-
- try {
- /** @var \Magento\Store\Api\Data\StoreInterface $store */
- $store = $this->storeManager->getStore($storeCode);
- } catch (NoSuchEntityException $e) {
- return $pathInfo;
- }
-
- if ($store->isUseStoreInUrl()) {
- if (!$request->isDirectAccessFrontendName($storeCode) && $storeCode != Store::ADMIN_CODE) {
- $this->storeManager->setCurrentStore($store->getCode());
- $pathInfo = '/' . (isset($pathParts[1]) ? $pathParts[1] : '');
- return $pathInfo;
- } elseif (!empty($storeCode)) {
- $request->setActionName('noroute');
- return $pathInfo;
+ //can store code be used in url
+ if ((bool)$this->config->getValue(\Magento\Store\Model\Store::XML_PATH_STORE_IN_URL)) {
+ $storeCode = $this->storePathInfoValidator->getValidStoreCode($request, $pathInfo);
+ if (!empty($storeCode)) {
+ if (!$request->isDirectAccessFrontendName($storeCode)) {
+ $pathInfo = $this->trimStoreCodeFromPathInfo($pathInfo, $storeCode);
+ } else {
+ //no route in case we're trying to access a store that has the same code as a direct access
+ $request->setActionName(\Magento\Framework\App\Router\Base::NO_ROUTE);
+ }
}
- return $pathInfo;
}
return $pathInfo;
}
+
+ /**
+ * Trim store code from path info string if exists
+ *
+ * @param string $pathInfo
+ * @param string $storeCode
+ * @return string
+ */
+ private function trimStoreCodeFromPathInfo(string $pathInfo, string $storeCode) : ?string
+ {
+ if (substr($pathInfo, 0, strlen('/' . $storeCode)) == '/'. $storeCode) {
+ $pathInfo = substr($pathInfo, strlen($storeCode)+1);
+ }
+ return empty($pathInfo) ? '/' : $pathInfo;
+ }
}
diff --git a/app/code/Magento/Store/App/Request/StorePathInfoValidator.php b/app/code/Magento/Store/App/Request/StorePathInfoValidator.php
new file mode 100644
index 0000000000000..0b66ba7586009
--- /dev/null
+++ b/app/code/Magento/Store/App/Request/StorePathInfoValidator.php
@@ -0,0 +1,102 @@
+config = $config;
+ $this->storeRepository = $storeRepository;
+ $this->pathInfo = $pathInfo;
+ }
+
+ /**
+ * Get store code from path info validate if config value. If path info is empty the try to calculate from request.
+ *
+ * @param \Magento\Framework\App\Request\Http $request
+ * @param string $pathInfo
+ * @return string|null
+ */
+ public function getValidStoreCode(
+ \Magento\Framework\App\Request\Http $request,
+ string $pathInfo = ''
+ ) : ?string {
+ if (empty($pathInfo)) {
+ $pathInfo = $this->pathInfo->getPathInfo(
+ $request->getRequestUri(),
+ $request->getBaseUrl()
+ );
+ }
+ $storeCode = $this->getStoreCode($pathInfo);
+ if (!empty($storeCode)
+ && $storeCode != Store::ADMIN_CODE
+ && (bool)$this->config->getValue(\Magento\Store\Model\Store::XML_PATH_STORE_IN_URL)
+ ) {
+ try {
+ $this->storeRepository->getActiveStoreByCode($storeCode);
+
+ if ((bool)$this->config->getValue(
+ \Magento\Store\Model\Store::XML_PATH_STORE_IN_URL,
+ \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ $storeCode
+ )) {
+ return $storeCode;
+ }
+ } catch (NoSuchEntityException $e) {
+ //return null;
+ } catch (\Magento\Store\Model\StoreIsInactiveException $e) {
+ //return null;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get store code from path info string
+ *
+ * @param string $pathInfo
+ * @return string
+ */
+ private function getStoreCode(string $pathInfo) : string
+ {
+ $pathParts = explode('/', ltrim($pathInfo, '/'), 2);
+ return current($pathParts);
+ }
+}
diff --git a/app/code/Magento/Store/App/Response/Redirect.php b/app/code/Magento/Store/App/Response/Redirect.php
index 534c6be41c937..3ad6a86db6908 100644
--- a/app/code/Magento/Store/App/Response/Redirect.php
+++ b/app/code/Magento/Store/App/Response/Redirect.php
@@ -7,8 +7,9 @@
*/
namespace Magento\Store\App\Response;
-use Magento\Store\Api\StoreResolverInterface;
-
+/**
+ * Class Redirect computes redirect urls responses.
+ */
class Redirect implements \Magento\Framework\App\Response\RedirectInterface
{
/**
@@ -76,6 +77,8 @@ public function __construct(
}
/**
+ * Get the referrer url.
+ *
* @return string
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
@@ -164,10 +167,7 @@ public function success($defaultUrl)
}
/**
- * {@inheritdoc}
- *
- * @param array $arguments
- * @return array
+ * @inheritdoc
*/
public function updatePathParams(array $arguments)
{
@@ -248,10 +248,10 @@ protected function normalizeRefererQueryParts($refererQuery)
$store = $this->_storeManager->getStore();
if ($store
- && !empty($refererQuery[StoreResolverInterface::PARAM_NAME])
- && ($refererQuery[StoreResolverInterface::PARAM_NAME] !== $store->getCode())
+ && !empty($refererQuery[\Magento\Store\Model\StoreManagerInterface::PARAM_NAME])
+ && ($refererQuery[\Magento\Store\Model\StoreManagerInterface::PARAM_NAME] !== $store->getCode())
) {
- $refererQuery[StoreResolverInterface::PARAM_NAME] = $store->getCode();
+ $refererQuery[\Magento\Store\Model\StoreManagerInterface::PARAM_NAME] = $store->getCode();
}
return $refererQuery;
diff --git a/app/code/Magento/Store/Block/Switcher.php b/app/code/Magento/Store/Block/Switcher.php
index 58a7ba3c1c283..f15349f11066d 100644
--- a/app/code/Magento/Store/Block/Switcher.php
+++ b/app/code/Magento/Store/Block/Switcher.php
@@ -10,7 +10,6 @@
namespace Magento\Store\Block;
use Magento\Directory\Helper\Data;
-use Magento\Store\Api\StoreResolverInterface;
use Magento\Store\Model\Group;
use Magento\Store\Model\Store;
use Magento\Framework\App\ActionInterface;
@@ -18,6 +17,8 @@
use Magento\Framework\Url\Helper\Data as UrlHelper;
/**
+ * Switcher block
+ *
* @api
* @since 100.0.2
*/
@@ -39,8 +40,6 @@ class Switcher extends \Magento\Framework\View\Element\Template
private $urlHelper;
/**
- * Constructs
- *
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Framework\Data\Helper\PostHelper $postDataHelper
* @param array $data
@@ -58,6 +57,8 @@ public function __construct(
}
/**
+ * Get current website Id.
+ *
* @return int|null|string
*/
public function getCurrentWebsiteId()
@@ -66,6 +67,8 @@ public function getCurrentWebsiteId()
}
/**
+ * Get current group Id.
+ *
* @return int|null|string
*/
public function getCurrentGroupId()
@@ -74,6 +77,8 @@ public function getCurrentGroupId()
}
/**
+ * Get current Store Id.
+ *
* @return int
*/
public function getCurrentStoreId()
@@ -82,6 +87,8 @@ public function getCurrentStoreId()
}
/**
+ * Get raw groups.
+ *
* @return array
*/
public function getRawGroups()
@@ -99,6 +106,8 @@ public function getRawGroups()
}
/**
+ * Get raw stores.
+ *
* @return array
*/
public function getRawStores()
@@ -170,6 +179,8 @@ public function getGroups()
}
/**
+ * Get stores.
+ *
* @return \Magento\Store\Model\Store[]
*/
public function getStores()
@@ -189,6 +200,8 @@ public function getStores()
}
/**
+ * Get current store code.
+ *
* @return string
*/
public function getCurrentStoreCode()
@@ -197,6 +210,8 @@ public function getCurrentStoreCode()
}
/**
+ * Is store in url.
+ *
* @return bool
*/
public function isStoreInUrl()
@@ -208,7 +223,7 @@ public function isStoreInUrl()
}
/**
- * Get store code
+ * Get store code.
*
* @return string
*/
@@ -218,7 +233,7 @@ public function getStoreCode()
}
/**
- * Get store name
+ * Get store name.
*
* @return null|string
*/
@@ -228,7 +243,7 @@ public function getStoreName()
}
/**
- * Returns target store post data
+ * Returns target store post data.
*
* @param Store $store
* @param array $data
@@ -237,7 +252,7 @@ public function getStoreName()
*/
public function getTargetStorePostData(Store $store, $data = [])
{
- $data[\Magento\Store\Api\StoreResolverInterface::PARAM_NAME] = $store->getCode();
+ $data[\Magento\Store\Model\StoreManagerInterface::PARAM_NAME] = $store->getCode();
$data['___from_store'] = $this->_storeManager->getStore()->getCode();
$urlOnTargetStore = $store->getCurrentUrl(false);
diff --git a/app/code/Magento/Store/Controller/Store/SwitchAction.php b/app/code/Magento/Store/Controller/Store/SwitchAction.php
index df946b45d60e5..de721869c5aba 100644
--- a/app/code/Magento/Store/Controller/Store/SwitchAction.php
+++ b/app/code/Magento/Store/Controller/Store/SwitchAction.php
@@ -15,13 +15,13 @@
use Magento\Store\Api\StoreCookieManagerInterface;
use Magento\Store\Api\StoreRepositoryInterface;
use Magento\Store\Model\StoreIsInactiveException;
-use Magento\Store\Model\StoreResolver;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Store\Model\StoreSwitcher;
use Magento\Store\Model\StoreSwitcherInterface;
/**
* Handles store switching url and makes redirect.
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class SwitchAction extends Action
@@ -81,13 +81,15 @@ public function __construct(
}
/**
+ * Execute action
+ *
* @return void
* @throws StoreSwitcher\CannotSwitchStoreException
*/
public function execute()
{
$targetStoreCode = $this->_request->getParam(
- StoreResolver::PARAM_NAME,
+ \Magento\Store\Model\StoreManagerInterface::PARAM_NAME,
$this->storeCookieManager->getStoreCodeFromCookie()
);
$fromStoreCode = $this->_request->getParam('___from_store');
diff --git a/app/code/Magento/Store/Model/Argument/Interpreter/ServiceUrl.php b/app/code/Magento/Store/Model/Argument/Interpreter/ServiceUrl.php
index cfa13e65ea42a..4d4021f5528ad 100644
--- a/app/code/Magento/Store/Model/Argument/Interpreter/ServiceUrl.php
+++ b/app/code/Magento/Store/Model/Argument/Interpreter/ServiceUrl.php
@@ -6,8 +6,8 @@
namespace Magento\Store\Model\Argument\Interpreter;
use Magento\Framework\Data\Argument\InterpreterInterface;
-use Magento\Store\Api\StoreResolverInterface;
use Magento\Store\Model\StoreRepository;
+use Magento\Store\Model\StoreManagerInterface;
/**
* Interpreter that builds Service URL by input path and optional parameters
@@ -25,9 +25,9 @@ class ServiceUrl implements InterpreterInterface
private $service;
/**
- * @var StoreResolverInterface
+ * @var StoreManagerInterface
*/
- private $storeResolver;
+ private $storeManager;
/**
* @var string
@@ -41,21 +41,21 @@ class ServiceUrl implements InterpreterInterface
/**
* @param \Magento\Framework\Url $url
- * @param StoreResolverInterface $storeResolver
+ * @param StoreManagerInterface $storeManager
* @param StoreRepository $storeRepository
* @param string $service
* @param string $version
*/
public function __construct(
\Magento\Framework\Url $url,
- StoreResolverInterface $storeResolver,
+ StoreManagerInterface $storeManager,
StoreRepository $storeRepository,
$service = "rest",
$version = "V1"
) {
$this->url = $url;
$this->service = $service;
- $this->storeResolver = $storeResolver;
+ $this->storeManager = $storeManager;
$this->version = $version;
$this->storeRepository = $storeRepository;
}
@@ -67,14 +67,16 @@ public function __construct(
*/
private function getServiceUrl()
{
- $store = $this->storeRepository->getById($this->storeResolver->getCurrentStoreId());
+ $store = $this->storeRepository->getById($this->storeManager->getStore()->getId());
return $this->url->getUrl(
$this->service . "/" . $store->getCode() . "/" . $this->version
);
}
/**
- * {@inheritdoc}
+ * Compute and return effective value of an argument
+ *
+ * @param array $data
* @return string
* @throws \InvalidArgumentException
*/
diff --git a/app/code/Magento/Store/Model/Plugin/StoreCookie.php b/app/code/Magento/Store/Model/Plugin/StoreCookie.php
index 9fca86ab71762..7aa2c91652e86 100644
--- a/app/code/Magento/Store/Model/Plugin/StoreCookie.php
+++ b/app/code/Magento/Store/Model/Plugin/StoreCookie.php
@@ -12,8 +12,6 @@
use Magento\Store\Model\StoreIsInactiveException;
use Magento\Framework\Exception\NoSuchEntityException;
use \InvalidArgumentException;
-use Magento\Store\Api\StoreResolverInterface;
-use Magento\Framework\App\ObjectManager;
/**
* Class StoreCookie
@@ -35,27 +33,19 @@ class StoreCookie
*/
protected $storeRepository;
- /**
- * @var StoreResolverInterface
- */
- private $storeResolver;
-
/**
* @param StoreManagerInterface $storeManager
* @param StoreCookieManagerInterface $storeCookieManager
* @param StoreRepositoryInterface $storeRepository
- * @param StoreResolverInterface $storeResolver
*/
public function __construct(
StoreManagerInterface $storeManager,
StoreCookieManagerInterface $storeCookieManager,
- StoreRepositoryInterface $storeRepository,
- StoreResolverInterface $storeResolver = null
+ StoreRepositoryInterface $storeRepository
) {
$this->storeManager = $storeManager;
$this->storeCookieManager = $storeCookieManager;
$this->storeRepository = $storeRepository;
- $this->storeResolver = $storeResolver ?: ObjectManager::getInstance()->get(StoreResolverInterface::class);
}
/**
diff --git a/app/code/Magento/Store/Model/StoreManagerInterface.php b/app/code/Magento/Store/Model/StoreManagerInterface.php
index 220155c47f6df..f440515f23e0b 100644
--- a/app/code/Magento/Store/Model/StoreManagerInterface.php
+++ b/app/code/Magento/Store/Model/StoreManagerInterface.php
@@ -21,6 +21,11 @@ interface StoreManagerInterface
*/
const CONTEXT_STORE = 'store';
+ /**
+ * The store GET Param name
+ */
+ const PARAM_NAME = '___store';
+
/**
* Allow or disallow single store mode
*
diff --git a/app/code/Magento/Store/Model/StoreResolver.php b/app/code/Magento/Store/Model/StoreResolver.php
index 3f449f10c6d42..aafdd15138981 100644
--- a/app/code/Magento/Store/Model/StoreResolver.php
+++ b/app/code/Magento/Store/Model/StoreResolver.php
@@ -3,10 +3,13 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Store\Model;
+declare(strict_types=1);
-use Magento\Framework\Serialize\SerializerInterface;
+namespace Magento\Store\Model;
+/**
+ * Class used to resolve store from url path or get parameters or cookie.
+ */
class StoreResolver implements \Magento\Store\Api\StoreResolverInterface
{
/**
@@ -25,12 +28,12 @@ class StoreResolver implements \Magento\Store\Api\StoreResolverInterface
protected $storeCookieManager;
/**
- * @var \Magento\Framework\Cache\FrontendInterface
+ * @deprecated
*/
protected $cache;
/**
- * @var \Magento\Store\Model\StoreResolver\ReaderList
+ * @deprecated
*/
protected $readerList;
@@ -45,56 +48,70 @@ class StoreResolver implements \Magento\Store\Api\StoreResolverInterface
protected $scopeCode;
/**
- * @var \Magento\Framework\App\RequestInterface
+ * @var \Magento\Framework\App\Request\Http
*/
protected $request;
/**
- * @var \Magento\Framework\Serialize\SerializerInterface
+ * @var StoresData
+ */
+ private $storesData;
+
+ /**
+ * @var \Magento\Store\App\Request\StorePathInfoValidator
*/
- private $serializer;
+ private $storePathInfoValidator;
/**
* @param \Magento\Store\Api\StoreRepositoryInterface $storeRepository
* @param \Magento\Store\Api\StoreCookieManagerInterface $storeCookieManager
- * @param \Magento\Framework\App\RequestInterface $request
- * @param \Magento\Framework\Cache\FrontendInterface $cache
- * @param \Magento\Store\Model\StoreResolver\ReaderList $readerList
- * @param string $runMode
- * @param null $scopeCode
+ * @param \Magento\Framework\App\Request\Http $request
+ * @param \Magento\Store\Model\StoresData $storesData
+ * @param \Magento\Store\App\Request\StorePathInfoValidator $storePathInfoValidator
+ * @param string|null $runMode
+ * @param string|null $scopeCode
*/
public function __construct(
\Magento\Store\Api\StoreRepositoryInterface $storeRepository,
\Magento\Store\Api\StoreCookieManagerInterface $storeCookieManager,
- \Magento\Framework\App\RequestInterface $request,
- \Magento\Framework\Cache\FrontendInterface $cache,
- \Magento\Store\Model\StoreResolver\ReaderList $readerList,
+ \Magento\Framework\App\Request\Http $request,
+ \Magento\Store\Model\StoresData $storesData,
+ \Magento\Store\App\Request\StorePathInfoValidator $storePathInfoValidator,
$runMode = ScopeInterface::SCOPE_STORE,
$scopeCode = null
) {
$this->storeRepository = $storeRepository;
$this->storeCookieManager = $storeCookieManager;
$this->request = $request;
- $this->cache = $cache;
- $this->readerList = $readerList;
+ $this->storePathInfoValidator = $storePathInfoValidator;
+ $this->storesData = $storesData;
$this->runMode = $scopeCode ? $runMode : ScopeInterface::SCOPE_WEBSITE;
$this->scopeCode = $scopeCode;
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getCurrentStoreId()
{
list($stores, $defaultStoreId) = $this->getStoresData();
- $storeCode = $this->request->getParam(self::PARAM_NAME, $this->storeCookieManager->getStoreCodeFromCookie());
+ $storeCode = $this->storePathInfoValidator->getValidStoreCode($this->request);
+
+ if (!$storeCode) {
+ $storeCode = $this->request->getParam(
+ \Magento\Store\Model\StoreManagerInterface::PARAM_NAME,
+ $this->storeCookieManager->getStoreCodeFromCookie()
+ );
+ }
+
if (is_array($storeCode)) {
if (!isset($storeCode['_data']['code'])) {
throw new \InvalidArgumentException(__('Invalid store parameter.'));
}
$storeCode = $storeCode['_data']['code'];
}
+
if ($storeCode) {
try {
$store = $this->getRequestedStoreByCode($storeCode);
@@ -116,28 +133,21 @@ public function getCurrentStoreId()
*
* @return array
*/
- protected function getStoresData()
+ protected function getStoresData() : array
{
- $cacheKey = 'resolved_stores_' . md5($this->runMode . $this->scopeCode);
- $cacheData = $this->cache->load($cacheKey);
- if ($cacheData) {
- $storesData = $this->getSerializer()->unserialize($cacheData);
- } else {
- $storesData = $this->readStoresData();
- $this->cache->save($this->getSerializer()->serialize($storesData), $cacheKey, [self::CACHE_TAG]);
- }
- return $storesData;
+ return $this->storesData->getStoresData($this->runMode, $this->scopeCode);
}
/**
* Read stores data. First element is allowed store ids, second is default store id
*
* @return array
+ * @deprecated
+ * @see \Magento\Store\Model\StoreResolver::getStoresData
*/
- protected function readStoresData()
+ protected function readStoresData() : array
{
- $reader = $this->readerList->getReader($this->runMode);
- return [$reader->getAllowedStoreIds($this->scopeCode), $reader->getDefaultStoreId($this->scopeCode)];
+ return $this->getStoresData();
}
/**
@@ -147,7 +157,7 @@ protected function readStoresData()
* @return \Magento\Store\Api\Data\StoreInterface
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
- protected function getRequestedStoreByCode($storeCode)
+ protected function getRequestedStoreByCode($storeCode) : \Magento\Store\Api\Data\StoreInterface
{
try {
$store = $this->storeRepository->getActiveStoreByCode($storeCode);
@@ -165,7 +175,7 @@ protected function getRequestedStoreByCode($storeCode)
* @return \Magento\Store\Api\Data\StoreInterface
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
- protected function getDefaultStoreById($id)
+ protected function getDefaultStoreById($id) : \Magento\Store\Api\Data\StoreInterface
{
try {
$store = $this->storeRepository->getActiveStoreById($id);
@@ -175,19 +185,4 @@ protected function getDefaultStoreById($id)
return $store;
}
-
- /**
- * Get serializer
- *
- * @return \Magento\Framework\Serialize\SerializerInterface
- * @deprecated 100.2.0
- */
- private function getSerializer()
- {
- if ($this->serializer === null) {
- $this->serializer = \Magento\Framework\App\ObjectManager::getInstance()
- ->get(SerializerInterface::class);
- }
- return $this->serializer;
- }
}
diff --git a/app/code/Magento/Store/Model/StoreResolver/Website.php b/app/code/Magento/Store/Model/StoreResolver/Website.php
index 29f85716fea29..e314538099c8f 100644
--- a/app/code/Magento/Store/Model/StoreResolver/Website.php
+++ b/app/code/Magento/Store/Model/StoreResolver/Website.php
@@ -5,6 +5,9 @@
*/
namespace Magento\Store\Model\StoreResolver;
+/**
+ * Reader implementation for website.
+ */
class Website implements ReaderInterface
{
/**
@@ -38,22 +41,25 @@ public function __construct(
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getAllowedStoreIds($scopeCode)
{
$stores = [];
$website = $scopeCode ? $this->websiteRepository->get($scopeCode) : $this->websiteRepository->getDefault();
foreach ($this->storeRepository->getList() as $store) {
- if ($store->isActive() && $store->getWebsiteId() == $website->getId()) {
- $stores[] = $store->getId();
+ if ($store->getIsActive()) {
+ if (($scopeCode && $store->getWebsiteId() == $website->getId()) || (!$scopeCode)) {
+ $stores[$store->getId()] = $store->getId();
+ }
}
}
+ sort($stores);
return $stores;
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getDefaultStoreId($scopeCode)
{
diff --git a/app/code/Magento/Store/Model/StoresData.php b/app/code/Magento/Store/Model/StoresData.php
new file mode 100644
index 0000000000000..b3d00bc97cd2e
--- /dev/null
+++ b/app/code/Magento/Store/Model/StoresData.php
@@ -0,0 +1,77 @@
+cache = $cache;
+ $this->readerList = $readerList;
+ $this->serializer = $serializer;
+ }
+
+ /**
+ * Get stores data
+ *
+ * @param string $runMode
+ * @param string|null $scopeCode
+ * @return array
+ */
+ public function getStoresData(string $runMode, string $scopeCode = null) : array
+ {
+ $cacheKey = 'resolved_stores_' . md5($runMode . $scopeCode);
+ $cacheData = $this->cache->load($cacheKey);
+ if ($cacheData) {
+ $storesData = $this->serializer->unserialize($cacheData);
+ } else {
+ $reader = $this->readerList->getReader($runMode);
+ $storesData = [$reader->getAllowedStoreIds($scopeCode), $reader->getDefaultStoreId($scopeCode)];
+ $this->cache->save(
+ $this->serializer->serialize($storesData),
+ $cacheKey,
+ [
+ self::CACHE_TAG,
+ \Magento\Store\Model\Store::CACHE_TAG
+ ]
+ );
+ }
+ return $storesData;
+ }
+}
diff --git a/app/code/Magento/Store/Test/Unit/App/Request/PathInfoProcessorTest.php b/app/code/Magento/Store/Test/Unit/App/Request/PathInfoProcessorTest.php
index 4a9b7d798c325..5d0f11b8a98d4 100644
--- a/app/code/Magento/Store/Test/Unit/App/Request/PathInfoProcessorTest.php
+++ b/app/code/Magento/Store/Test/Unit/App/Request/PathInfoProcessorTest.php
@@ -12,45 +12,83 @@ class PathInfoProcessorTest extends \PHPUnit\Framework\TestCase
/**
* @var \Magento\Store\App\Request\PathInfoProcessor
*/
- protected $_model;
+ private $model;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
- protected $_storeManagerMock;
+ private $requestMock;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
- protected $_requestMock;
+ private $validatorConfigMock;
+
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
+ private $processorConfigMock;
+
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
+ private $pathInfoMock;
+
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
+ private $storeRepositoryMock;
+
+ /**
+ * @var \PHPUnit_Framework_MockObject_MockObject
+ */
+ private $storePathInfoValidator;
/**
* @var string
*/
- protected $_pathInfo = '/storeCode/node_one/';
+ protected $pathInfo = '/storeCode/node_one/';
protected function setUp()
{
- $this->_requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class)
+ $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class)
+ ->disableOriginalConstructor()->getMock();
+
+ $this->validatorConfigMock = $this->createMock(\Magento\Framework\App\Config\ReinitableConfigInterface::class);
+
+ $this->processorConfigMock = $this->createMock(\Magento\Framework\App\Config\ReinitableConfigInterface::class);
+
+ $this->storeRepositoryMock = $this->createMock(\Magento\Store\Api\StoreRepositoryInterface::class);
+
+ $this->pathInfoMock = $this->getMockBuilder(\Magento\Framework\App\Request\PathInfo ::class)
->disableOriginalConstructor()->getMock();
- $this->_storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManager::class);
- $this->_model = new \Magento\Store\App\Request\PathInfoProcessor($this->_storeManagerMock);
+
+ $this->storePathInfoValidator = new \Magento\Store\App\Request\StorePathInfoValidator(
+ $this->validatorConfigMock,
+ $this->storeRepositoryMock,
+ $this->pathInfoMock
+ );
+
+ $this->model = new \Magento\Store\App\Request\PathInfoProcessor(
+ $this->storePathInfoValidator,
+ $this->validatorConfigMock
+ );
}
public function testProcessIfStoreExistsAndIsNotDirectAccessToFrontName()
{
+ $this->validatorConfigMock->expects($this->any())->method('getValue')->willReturn(true);
+
$store = $this->createMock(\Magento\Store\Model\Store::class);
- $this->_storeManagerMock->expects(
- $this->once()
+ $this->storeRepositoryMock->expects(
+ $this->atLeastOnce()
)->method(
- 'getStore'
+ 'getActiveStoreByCode'
)->with(
'storeCode'
)->willReturn($store);
- $store->expects($this->once())->method('getCode')->will($this->returnValue('storeCode'));
- $store->expects($this->once())->method('isUseStoreInUrl')->will($this->returnValue(true));
- $this->_requestMock->expects(
- $this->once()
+ $this->requestMock->expects(
+ $this->atLeastOnce()
)->method(
'isDirectAccessFrontendName'
)->with(
@@ -58,67 +96,69 @@ public function testProcessIfStoreExistsAndIsNotDirectAccessToFrontName()
)->will(
$this->returnValue(false)
);
- $this->_storeManagerMock->expects($this->once())->method('setCurrentStore')->with('storeCode');
- $this->assertEquals('/node_one/', $this->_model->process($this->_requestMock, $this->_pathInfo));
+ $this->assertEquals('/node_one/', $this->model->process($this->requestMock, $this->pathInfo));
}
public function testProcessIfStoreExistsAndDirectAccessToFrontName()
{
- $store = $this->createMock(\Magento\Store\Model\Store::class);
- $this->_storeManagerMock->expects(
- $this->once()
+ $this->validatorConfigMock->expects($this->atLeastOnce())->method('getValue')->willReturn(true);
+
+ $this->storeRepositoryMock->expects(
+ $this->any()
)->method(
- 'getStore'
- )->with(
- 'storeCode'
- )->willReturn($store);
- $store->expects($this->once())->method('isUseStoreInUrl')->will($this->returnValue(true));
- $this->_requestMock->expects(
- $this->once()
+ 'getActiveStoreByCode'
+ );
+ $this->requestMock->expects(
+ $this->atLeastOnce()
)->method(
'isDirectAccessFrontendName'
)->with(
'storeCode'
- )->will(
- $this->returnValue(true)
- );
- $this->_requestMock->expects($this->once())->method('setActionName')->with('noroute');
- $this->assertEquals($this->_pathInfo, $this->_model->process($this->_requestMock, $this->_pathInfo));
+ )->willReturn(true);
+ $this->requestMock->expects($this->once())->method('setActionName')->with('noroute');
+ $this->assertEquals($this->pathInfo, $this->model->process($this->requestMock, $this->pathInfo));
}
public function testProcessIfStoreIsEmpty()
{
+ $this->validatorConfigMock->expects($this->any())->method('getValue')->willReturn(true);
+
$path = '/0/node_one/';
- $store = $this->createMock(\Magento\Store\Model\Store::class);
- $this->_storeManagerMock->expects(
- $this->once()
+ $this->storeRepositoryMock->expects(
+ $this->never()
)->method(
- 'getStore'
- )->with(
- '0'
- )->willReturn($store);
- $store->expects($this->once())->method('isUseStoreInUrl')->will($this->returnValue(true));
- $this->_requestMock->expects(
- $this->once()
+ 'getActiveStoreByCode'
+ );
+ $this->requestMock->expects(
+ $this->never()
)->method(
'isDirectAccessFrontendName'
- )->with(
- '0'
- )->will(
- $this->returnValue(true)
);
- $this->_requestMock->expects($this->never())->method('setActionName');
- $this->assertEquals($path, $this->_model->process($this->_requestMock, $path));
+ $this->requestMock->expects($this->never())->method('setActionName');
+ $this->assertEquals($path, $this->model->process($this->requestMock, $path));
}
public function testProcessIfStoreCodeIsNotExist()
{
- $store = $this->createMock(\Magento\Store\Model\Store::class);
- $this->_storeManagerMock->expects($this->once())->method('getStore')->with('storeCode')
+ $this->validatorConfigMock->expects($this->atLeastOnce())->method('getValue')->willReturn(true);
+
+ $this->storeRepositoryMock->expects($this->once())->method('getActiveStoreByCode')->with('storeCode')
->willThrowException(new NoSuchEntityException());
- $store->expects($this->never())->method('isUseStoreInUrl');
- $this->_requestMock->expects($this->never())->method('isDirectAccessFrontendName');
+ $this->requestMock->expects($this->never())->method('isDirectAccessFrontendName');
+
+ $this->assertEquals($this->pathInfo, $this->model->process($this->requestMock, $this->pathInfo));
+ }
+
+ public function testProcessIfStoreUrlNotEnabled()
+ {
+ $this->validatorConfigMock->expects($this->at(0))->method('getValue')->willReturn(true);
+
+ $this->validatorConfigMock->expects($this->at(1))->method('getValue')->willReturn(true);
+
+ $this->validatorConfigMock->expects($this->at(2))->method('getValue')->willReturn(false);
+
+ $this->storeRepositoryMock->expects($this->once())->method('getActiveStoreByCode')->willReturn(1);
- $this->assertEquals($this->_pathInfo, $this->_model->process($this->_requestMock, $this->_pathInfo));
+ $this->assertEquals($this->pathInfo, $this->model->process($this->requestMock, $this->pathInfo));
}
}
diff --git a/app/code/Magento/Store/Test/Unit/Model/Plugin/StoreCookieTest.php b/app/code/Magento/Store/Test/Unit/Model/Plugin/StoreCookieTest.php
index 0454c0096a6ab..9f4be98ab5580 100644
--- a/app/code/Magento/Store/Test/Unit/Model/Plugin/StoreCookieTest.php
+++ b/app/code/Magento/Store/Test/Unit/Model/Plugin/StoreCookieTest.php
@@ -54,11 +54,6 @@ class StoreCookieTest extends \PHPUnit\Framework\TestCase
*/
protected $storeRepositoryMock;
- /**
- * @var \Magento\Store\Api\StoreResolverInterface|\PHPUnit_Framework_MockObject_MockObject
- */
- protected $storeResolverMock;
-
/**
* Set up
*/
@@ -94,18 +89,12 @@ protected function setUp()
->setMethods([])
->getMock();
- $this->storeResolverMock = $this->getMockBuilder(\Magento\Store\Api\StoreResolverInterface::class)
- ->disableOriginalConstructor()
- ->setMethods([])
- ->getMock();
-
$this->plugin = (new ObjectManager($this))->getObject(
\Magento\Store\Model\Plugin\StoreCookie::class,
[
'storeManager' => $this->storeManagerMock,
'storeCookieManager' => $this->storeCookieManagerMock,
- 'storeRepository' => $this->storeRepositoryMock,
- 'storeResolver' => $this->storeResolverMock
+ 'storeRepository' => $this->storeRepositoryMock
]
);
}
diff --git a/app/code/Magento/Store/etc/di.xml b/app/code/Magento/Store/etc/di.xml
index 3d740bfee2093..be005264b7bbf 100644
--- a/app/code/Magento/Store/etc/di.xml
+++ b/app/code/Magento/Store/etc/di.xml
@@ -102,11 +102,15 @@
- Magento\Framework\App\Cache\Type\Config
Magento\Store\Model\StoreManager::PARAM_RUN_TYPE
Magento\Store\Model\StoreManager::PARAM_RUN_CODE
+
+
+ Magento\Framework\App\Cache\Type\Config
+
+
Magento\Store\Model\StoreManager::PARAM_RUN_TYPE
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rate/Index.php b/app/code/Magento/Tax/Controller/Adminhtml/Rate/Index.php
index b91eef7b6f70e..565af0e0bf93b 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rate/Index.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rate/Index.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Tax\Controller\Adminhtml\Rate;
-class Index extends \Magento\Tax\Controller\Adminhtml\Rate
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Index extends \Magento\Tax\Controller\Adminhtml\Rate implements HttpGetActionInterface
{
/**
* Show Main Grid
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rule/Delete.php b/app/code/Magento/Tax/Controller/Adminhtml/Rule/Delete.php
index 71b6d7bf39396..1e46f0ea3d24a 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rule/Delete.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rule/Delete.php
@@ -6,9 +6,10 @@
*/
namespace Magento\Tax\Controller\Adminhtml\Rule;
+use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\Controller\ResultFactory;
-class Delete extends \Magento\Tax\Controller\Adminhtml\Rule
+class Delete extends \Magento\Tax\Controller\Adminhtml\Rule implements HttpPostActionInterface
{
/**
* @return \Magento\Backend\Model\View\Result\Redirect
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rule/Edit.php b/app/code/Magento/Tax/Controller/Adminhtml/Rule/Edit.php
index dc0f518802520..740d7e8afe62c 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rule/Edit.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rule/Edit.php
@@ -6,9 +6,10 @@
*/
namespace Magento\Tax\Controller\Adminhtml\Rule;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Framework\Controller\ResultFactory;
-class Edit extends \Magento\Tax\Controller\Adminhtml\Rule
+class Edit extends \Magento\Tax\Controller\Adminhtml\Rule implements HttpGetActionInterface
{
/**
* @return \Magento\Backend\Model\View\Result\Page|\Magento\Backend\Model\View\Result\Redirect
diff --git a/app/code/Magento/Tax/Controller/Adminhtml/Rule/Index.php b/app/code/Magento/Tax/Controller/Adminhtml/Rule/Index.php
index ddf6099a4f832..fd774777e3ef4 100644
--- a/app/code/Magento/Tax/Controller/Adminhtml/Rule/Index.php
+++ b/app/code/Magento/Tax/Controller/Adminhtml/Rule/Index.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Tax\Controller\Adminhtml\Rule;
-class Index extends \Magento\Tax\Controller\Adminhtml\Rule
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Index extends \Magento\Tax\Controller\Adminhtml\Rule implements HttpGetActionInterface
{
/**
* @return \Magento\Backend\Model\View\Result\Page
diff --git a/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ImportExport.php b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ImportExport.php
index 929c9db01a298..4264f5c3b7765 100644
--- a/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ImportExport.php
+++ b/app/code/Magento/TaxImportExport/Controller/Adminhtml/Rate/ImportExport.php
@@ -5,9 +5,10 @@
*/
namespace Magento\TaxImportExport\Controller\Adminhtml\Rate;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Framework\Controller\ResultFactory;
-class ImportExport extends \Magento\TaxImportExport\Controller\Adminhtml\Rate
+class ImportExport extends \Magento\TaxImportExport\Controller\Adminhtml\Rate implements HttpGetActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Theme/Controller/Adminhtml/System/Design/Theme/Index.php b/app/code/Magento/Theme/Controller/Adminhtml/System/Design/Theme/Index.php
index d51fd658075f1..1a136cca4d62a 100644
--- a/app/code/Magento/Theme/Controller/Adminhtml/System/Design/Theme/Index.php
+++ b/app/code/Magento/Theme/Controller/Adminhtml/System/Design/Theme/Index.php
@@ -6,11 +6,13 @@
*/
namespace Magento\Theme\Controller\Adminhtml\System\Design\Theme;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
/**
* Class Index
* @deprecated 100.2.0
*/
-class Index extends \Magento\Theme\Controller\Adminhtml\System\Design\Theme
+class Index extends \Magento\Theme\Controller\Adminhtml\System\Design\Theme implements HttpGetActionInterface
{
/**
* Index action
diff --git a/app/code/Magento/Ui/Controller/Adminhtml/Bookmark/Save.php b/app/code/Magento/Ui/Controller/Adminhtml/Bookmark/Save.php
index 60d374fbf26ca..b45880c1ce726 100644
--- a/app/code/Magento/Ui/Controller/Adminhtml/Bookmark/Save.php
+++ b/app/code/Magento/Ui/Controller/Adminhtml/Bookmark/Save.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Ui\Controller\Adminhtml\Bookmark;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Authorization\Model\UserContextInterface;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Json\DecoderInterface;
@@ -20,7 +21,7 @@
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class Save extends AbstractAction
+class Save extends AbstractAction implements HttpPostActionInterface
{
/**
* Identifier for current bookmark
diff --git a/app/code/Magento/Ui/Controller/Adminhtml/Index/Render.php b/app/code/Magento/Ui/Controller/Adminhtml/Index/Render.php
index fb99cef8e53cc..b983e56b8aee2 100644
--- a/app/code/Magento/Ui/Controller/Adminhtml/Index/Render.php
+++ b/app/code/Magento/Ui/Controller/Adminhtml/Index/Render.php
@@ -14,6 +14,11 @@
use Magento\Framework\Escaper;
use Magento\Framework\Controller\Result\JsonFactory;
+/**
+ * Render a component.
+ *
+ * @SuppressWarnings(PHPMD.AllPurposeAction)
+ */
class Render extends AbstractAction
{
/**
diff --git a/app/code/Magento/Ui/Controller/Adminhtml/Index/Render/Handle.php b/app/code/Magento/Ui/Controller/Adminhtml/Index/Render/Handle.php
index cc028a455456d..d1254790cb8eb 100644
--- a/app/code/Magento/Ui/Controller/Adminhtml/Index/Render/Handle.php
+++ b/app/code/Magento/Ui/Controller/Adminhtml/Index/Render/Handle.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Ui\Controller\Adminhtml\Index\Render;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Framework\View\Element\Template;
use Magento\Ui\Component\Control\ActionPool;
use Magento\Ui\Component\Wrapper\UiComponent;
@@ -13,7 +14,7 @@
/**
* Class Handle
*/
-class Handle extends AbstractAction
+class Handle extends AbstractAction implements HttpGetActionInterface
{
/**
* Render UI component by namespace in handle context
diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/actions.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/actions.js
index be7a1a13fbd61..c75f7797cf0f3 100644
--- a/app/code/Magento/Ui/view/base/web/js/grid/columns/actions.js
+++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/actions.js
@@ -11,8 +11,9 @@ define([
'mageUtils',
'uiRegistry',
'./column',
- 'Magento_Ui/js/modal/confirm'
-], function (_, utils, registry, Column, confirm) {
+ 'Magento_Ui/js/modal/confirm',
+ 'mage/dataPost'
+], function (_, utils, registry, Column, confirm, dataPost) {
'use strict';
return Column.extend({
@@ -267,7 +268,14 @@ define([
* @param {Object} action - Action's data.
*/
defaultCallback: function (actionIndex, recordId, action) {
- window.location.href = action.href;
+ if (action.post) {
+ dataPost().postData({
+ action: action.href,
+ data: {}
+ });
+ } else {
+ window.location.href = action.href;
+ }
},
/**
diff --git a/app/code/Magento/UrlRewrite/Block/Edit.php b/app/code/Magento/UrlRewrite/Block/Edit.php
index 115c5db43a70a..c8716f6c80f70 100644
--- a/app/code/Magento/UrlRewrite/Block/Edit.php
+++ b/app/code/Magento/UrlRewrite/Block/Edit.php
@@ -173,7 +173,7 @@ protected function _addDeleteButton()
['id' => $this->getUrlRewrite()->getId()]
)
)
- . ')',
+ . ', {data: {}})',
'class' => 'scalable delete',
'level' => -1
]
@@ -243,7 +243,7 @@ private function _getSelectorBlock()
* Since buttons are set as children, we remove them as children after generating them
* not to duplicate them in future
*
- * @param string $area
+ * @param string|null $area
* @return string
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
diff --git a/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/CmsPageGrid.php b/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/CmsPageGrid.php
index 480efa8235716..7240dfc36f1e1 100644
--- a/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/CmsPageGrid.php
+++ b/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/CmsPageGrid.php
@@ -6,7 +6,11 @@
*/
namespace Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite;
-class CmsPageGrid extends \Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite
+use Magento\Framework\App\Action\HttpGetActionInterface;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
+use Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite as RewriteAction;
+
+class CmsPageGrid extends RewriteAction implements HttpPostActionInterface, HttpGetActionInterface
{
/**
* Ajax CMS pages grid action
diff --git a/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/Delete.php b/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/Delete.php
index f8f7b145e2806..dc49776a1ac00 100644
--- a/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/Delete.php
+++ b/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/Delete.php
@@ -6,7 +6,9 @@
*/
namespace Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite;
-class Delete extends \Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite
+use Magento\Framework\App\Action\HttpPostActionInterface;
+
+class Delete extends \Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite implements HttpPostActionInterface
{
/**
* URL rewrite delete action
diff --git a/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/Edit.php b/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/Edit.php
index b7ff92213003c..e2161f4ffd9bb 100644
--- a/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/Edit.php
+++ b/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/Edit.php
@@ -6,7 +6,9 @@
*/
namespace Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite;
-class Edit extends \Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Edit extends \Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite implements HttpGetActionInterface
{
/**#@+
* Modes
diff --git a/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/Index.php b/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/Index.php
index 066377ff7bd75..4f3a1e7849ec0 100644
--- a/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/Index.php
+++ b/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/Index.php
@@ -6,7 +6,9 @@
*/
namespace Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite;
-class Index extends \Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Index extends \Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite implements HttpGetActionInterface
{
/**
* Show URL rewrites index page
diff --git a/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/Save.php b/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/Save.php
index 6325fe162d9e7..c508e85d87c3b 100644
--- a/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/Save.php
+++ b/app/code/Magento/UrlRewrite/Controller/Adminhtml/Url/Rewrite/Save.php
@@ -7,11 +7,12 @@
namespace Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\UrlRewrite\Model\UrlFinderInterface;
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
-class Save extends \Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite
+class Save extends \Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite implements HttpPostActionInterface
{
/**
* @var \Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator
diff --git a/app/code/Magento/UrlRewriteGraphQl/Model/Resolver/UrlRewrite.php b/app/code/Magento/UrlRewriteGraphQl/Model/Resolver/UrlRewrite.php
index 488f1281ce30f..5bdaf36272536 100644
--- a/app/code/Magento/UrlRewriteGraphQl/Model/Resolver/UrlRewrite.php
+++ b/app/code/Magento/UrlRewriteGraphQl/Model/Resolver/UrlRewrite.php
@@ -75,7 +75,7 @@ public function resolve(
if ($urlRewrite) {
$result = [
'id' => $urlRewrite->getEntityId(),
- 'canonical_url' => $urlRewrite->getTargetPath(),
+ 'relative_url' => $urlRewrite->getTargetPath(),
'type' => $this->sanitizeType($urlRewrite->getEntityType())
];
}
diff --git a/app/code/Magento/UrlRewriteGraphQl/etc/schema.graphqls b/app/code/Magento/UrlRewriteGraphQl/etc/schema.graphqls
index 38f1d9c65637c..e9a39617774c0 100644
--- a/app/code/Magento/UrlRewriteGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/UrlRewriteGraphQl/etc/schema.graphqls
@@ -1,14 +1,14 @@
# Copyright © Magento, Inc. All rights reserved.
# See COPYING.txt for license details.
-type EntityUrl @doc(description: "EntityUrl is an output object containing the `id`, `canonical_url`, and `type` attributes") {
+type EntityUrl @doc(description: "EntityUrl is an output object containing the `id`, `relative_url`, and `type` attributes") {
id: Int @doc(description: "The ID assigned to the object associated with the specified url. This could be a product ID, category ID, or page ID.")
- canonical_url: String @doc(description: "The internal relative URL. If the specified url is a redirect, the query returns the redirected URL, not the original.")
+ relative_url: String @doc(description: "The internal relative URL. If the specified url is a redirect, the query returns the redirected URL, not the original.")
type: UrlRewriteEntityTypeEnum @doc(description: "One of PRODUCT, CATEGORY, or CMS_PAGE.")
}
type Query {
- urlResolver(url: String!): EntityUrl @resolver(class: "Magento\\UrlRewriteGraphQl\\Model\\Resolver\\UrlRewrite") @doc(description: "The urlResolver query returns the canonical URL for a specified product, category or CMS page")
+ urlResolver(url: String!): EntityUrl @resolver(class: "Magento\\UrlRewriteGraphQl\\Model\\Resolver\\UrlRewrite") @doc(description: "The urlResolver query returns the relative URL for a specified product, category or CMS page")
}
enum UrlRewriteEntityTypeEnum {
diff --git a/app/code/Magento/User/Controller/Adminhtml/Locks/Index.php b/app/code/Magento/User/Controller/Adminhtml/Locks/Index.php
index 7c0e31076cace..e3e1e3def3985 100644
--- a/app/code/Magento/User/Controller/Adminhtml/Locks/Index.php
+++ b/app/code/Magento/User/Controller/Adminhtml/Locks/Index.php
@@ -6,10 +6,12 @@
*/
namespace Magento\User\Controller\Adminhtml\Locks;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
/**
* Locks Index action
*/
-class Index extends \Magento\User\Controller\Adminhtml\Locks
+class Index extends \Magento\User\Controller\Adminhtml\Locks implements HttpGetActionInterface
{
/**
* Render page with grid
diff --git a/app/code/Magento/User/Controller/Adminhtml/User/Index.php b/app/code/Magento/User/Controller/Adminhtml/User/Index.php
index 7f79dd4773731..bc4157c144a87 100644
--- a/app/code/Magento/User/Controller/Adminhtml/User/Index.php
+++ b/app/code/Magento/User/Controller/Adminhtml/User/Index.php
@@ -6,7 +6,9 @@
*/
namespace Magento\User\Controller\Adminhtml\User;
-class Index extends \Magento\User\Controller\Adminhtml\User
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Index extends \Magento\User\Controller\Adminhtml\User implements HttpGetActionInterface
{
/**
* @return void
diff --git a/app/code/Magento/User/Controller/Adminhtml/User/Role/Index.php b/app/code/Magento/User/Controller/Adminhtml/User/Role/Index.php
index e1853be17a128..8d468d45f1aee 100644
--- a/app/code/Magento/User/Controller/Adminhtml/User/Role/Index.php
+++ b/app/code/Magento/User/Controller/Adminhtml/User/Role/Index.php
@@ -6,7 +6,9 @@
*/
namespace Magento\User\Controller\Adminhtml\User\Role;
-class Index extends \Magento\User\Controller\Adminhtml\User\Role
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Index extends \Magento\User\Controller\Adminhtml\User\Role implements HttpGetActionInterface
{
/**
* Show grid with roles existing in systems
diff --git a/app/code/Magento/User/Controller/Adminhtml/User/Role/RoleGrid.php b/app/code/Magento/User/Controller/Adminhtml/User/Role/RoleGrid.php
index 4d97b62cd8b14..ad8c87b617d52 100644
--- a/app/code/Magento/User/Controller/Adminhtml/User/Role/RoleGrid.php
+++ b/app/code/Magento/User/Controller/Adminhtml/User/Role/RoleGrid.php
@@ -6,7 +6,11 @@
*/
namespace Magento\User\Controller\Adminhtml\User\Role;
-class RoleGrid extends \Magento\User\Controller\Adminhtml\User\Role
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+use Magento\Framework\App\Action\HttpPostActionInterface;
+use Magento\User\Controller\Adminhtml\User\Role as RoleAction;
+
+class RoleGrid extends RoleAction implements HttpGetActionInterface, HttpPostActionInterface
{
/**
* Action for ajax request from grid
diff --git a/app/code/Magento/User/Controller/Adminhtml/User/Role/SaveRole.php b/app/code/Magento/User/Controller/Adminhtml/User/Role/SaveRole.php
index 9dfe34e435385..44862f1fce2a0 100644
--- a/app/code/Magento/User/Controller/Adminhtml/User/Role/SaveRole.php
+++ b/app/code/Magento/User/Controller/Adminhtml/User/Role/SaveRole.php
@@ -7,6 +7,7 @@
namespace Magento\User\Controller\Adminhtml\User\Role;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Authorization\Model\Acl\Role\Group as RoleGroup;
use Magento\Authorization\Model\UserContextInterface;
use Magento\Framework\Controller\ResultFactory;
@@ -16,7 +17,7 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class SaveRole extends \Magento\User\Controller\Adminhtml\User\Role
+class SaveRole extends \Magento\User\Controller\Adminhtml\User\Role implements HttpPostActionInterface
{
/**
* Session keys for Info form data
diff --git a/app/code/Magento/User/Controller/Adminhtml/User/RoleGrid.php b/app/code/Magento/User/Controller/Adminhtml/User/RoleGrid.php
index 2bfbadd3a0d5f..e171f0a8c2bc8 100644
--- a/app/code/Magento/User/Controller/Adminhtml/User/RoleGrid.php
+++ b/app/code/Magento/User/Controller/Adminhtml/User/RoleGrid.php
@@ -6,7 +6,11 @@
*/
namespace Magento\User\Controller\Adminhtml\User;
-class RoleGrid extends \Magento\User\Controller\Adminhtml\User
+use Magento\Framework\App\Action\HttpGetActionInterface;
+use Magento\Framework\App\Action\HttpPostActionInterface;
+use Magento\User\Controller\Adminhtml\User as UserAction;
+
+class RoleGrid extends UserAction implements HttpGetActionInterface, HttpPostActionInterface
{
/**
* @return void
diff --git a/app/code/Magento/User/Controller/Adminhtml/User/Save.php b/app/code/Magento/User/Controller/Adminhtml/User/Save.php
index 4b984b761c1fe..09061384a8e61 100644
--- a/app/code/Magento/User/Controller/Adminhtml/User/Save.php
+++ b/app/code/Magento/User/Controller/Adminhtml/User/Save.php
@@ -6,6 +6,7 @@
namespace Magento\User\Controller\Adminhtml\User;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Framework\Exception\AuthenticationException;
use Magento\Framework\Exception\State\UserLockedException;
use Magento\Security\Model\SecurityCookie;
@@ -13,7 +14,7 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class Save extends \Magento\User\Controller\Adminhtml\User
+class Save extends \Magento\User\Controller\Adminhtml\User implements HttpPostActionInterface
{
/**
* @var SecurityCookie
@@ -44,10 +45,14 @@ public function execute()
{
$userId = (int)$this->getRequest()->getParam('user_id');
$data = $this->getRequest()->getPostValue();
+ if (array_key_exists('form_key', $data)) {
+ unset($data['form_key']);
+ }
if (!$data) {
$this->_redirect('adminhtml/*/');
return;
}
+
/** @var $model \Magento\User\Model\User */
$model = $this->_userFactory->create()->load($userId);
if ($userId && $model->isObjectNew()) {
diff --git a/app/code/Magento/Variable/Controller/Adminhtml/System/Variable/Index.php b/app/code/Magento/Variable/Controller/Adminhtml/System/Variable/Index.php
index f70cb31eb545f..71cb76a67d15d 100644
--- a/app/code/Magento/Variable/Controller/Adminhtml/System/Variable/Index.php
+++ b/app/code/Magento/Variable/Controller/Adminhtml/System/Variable/Index.php
@@ -6,12 +6,14 @@
*/
namespace Magento\Variable\Controller\Adminhtml\System\Variable;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
/**
* Display Variables list page
* @api
* @since 100.0.2
*/
-class Index extends \Magento\Variable\Controller\Adminhtml\System\Variable
+class Index extends \Magento\Variable\Controller\Adminhtml\System\Variable implements HttpGetActionInterface
{
/**
* Index Action
diff --git a/app/code/Magento/Version/Controller/Index/Index.php b/app/code/Magento/Version/Controller/Index/Index.php
index c5d02cd9a1fd2..0db9b5f80d483 100644
--- a/app/code/Magento/Version/Controller/Index/Index.php
+++ b/app/code/Magento/Version/Controller/Index/Index.php
@@ -6,6 +6,7 @@
*/
namespace Magento\Version\Controller\Index;
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\ProductMetadataInterface;
@@ -13,7 +14,7 @@
/**
* Magento Version controller
*/
-class Index extends Action
+class Index extends Action implements HttpGetActionInterface
{
/**
* @var ProductMetadataInterface
diff --git a/app/code/Magento/Webapi/Controller/PathProcessor.php b/app/code/Magento/Webapi/Controller/PathProcessor.php
index 5e8c23aa15506..c5748cc6e848e 100644
--- a/app/code/Magento/Webapi/Controller/PathProcessor.php
+++ b/app/code/Magento/Webapi/Controller/PathProcessor.php
@@ -8,6 +8,9 @@
use Magento\Framework\Exception\NoSuchEntityException;
+/**
+ * Class PathProcessor
+ */
class PathProcessor
{
/** Store code alias to indicate that all stores should be affected by action */
@@ -50,7 +53,7 @@ private function stripPathBeforeStorecode($pathInfo)
public function process($pathInfo)
{
$pathParts = $this->stripPathBeforeStorecode($pathInfo);
- $storeCode = $pathParts[0];
+ $storeCode = current($pathParts);
$stores = $this->storeManager->getStores(false, true);
if (isset($stores[$storeCode])) {
$this->storeManager->setCurrentStore($storeCode);
diff --git a/app/code/Magento/Widget/Controller/Adminhtml/Widget/BuildWidget.php b/app/code/Magento/Widget/Controller/Adminhtml/Widget/BuildWidget.php
index d9ef20aa90e47..0b9431f717e0a 100644
--- a/app/code/Magento/Widget/Controller/Adminhtml/Widget/BuildWidget.php
+++ b/app/code/Magento/Widget/Controller/Adminhtml/Widget/BuildWidget.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Widget\Controller\Adminhtml\Widget;
-class BuildWidget extends \Magento\Backend\App\Action
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
+
+class BuildWidget extends \Magento\Backend\App\Action implements HttpPostActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Widget/Controller/Adminhtml/Widget/Index.php b/app/code/Magento/Widget/Controller/Adminhtml/Widget/Index.php
index 61e44fe00db61..e7454faf925a6 100644
--- a/app/code/Magento/Widget/Controller/Adminhtml/Widget/Index.php
+++ b/app/code/Magento/Widget/Controller/Adminhtml/Widget/Index.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Widget\Controller\Adminhtml\Widget;
-class Index extends \Magento\Backend\App\Action
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
+
+class Index extends \Magento\Backend\App\Action implements HttpPostActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Widget/Controller/Adminhtml/Widget/Instance/Index.php b/app/code/Magento/Widget/Controller/Adminhtml/Widget/Instance/Index.php
index 40ade57f6a9e9..50f3addaf7c59 100644
--- a/app/code/Magento/Widget/Controller/Adminhtml/Widget/Instance/Index.php
+++ b/app/code/Magento/Widget/Controller/Adminhtml/Widget/Instance/Index.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Widget\Controller\Adminhtml\Widget\Instance;
-class Index extends \Magento\Widget\Controller\Adminhtml\Widget\Instance
+use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
+
+class Index extends \Magento\Widget\Controller\Adminhtml\Widget\Instance implements HttpGetActionInterface
{
/**
* Widget Instances Grid
diff --git a/app/code/Magento/Widget/Controller/Adminhtml/Widget/Instance/Save.php b/app/code/Magento/Widget/Controller/Adminhtml/Widget/Instance/Save.php
index b5d31dc10be34..dc137365498b2 100644
--- a/app/code/Magento/Widget/Controller/Adminhtml/Widget/Instance/Save.php
+++ b/app/code/Magento/Widget/Controller/Adminhtml/Widget/Instance/Save.php
@@ -6,7 +6,9 @@
*/
namespace Magento\Widget\Controller\Adminhtml\Widget\Instance;
-class Save extends \Magento\Widget\Controller\Adminhtml\Widget\Instance
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
+
+class Save extends \Magento\Widget\Controller\Adminhtml\Widget\Instance implements HttpPostActionInterface
{
/**
* Save action
diff --git a/app/code/Magento/Widget/Controller/Adminhtml/Widget/LoadOptions.php b/app/code/Magento/Widget/Controller/Adminhtml/Widget/LoadOptions.php
index 054019079ebaa..03d9d10311382 100644
--- a/app/code/Magento/Widget/Controller/Adminhtml/Widget/LoadOptions.php
+++ b/app/code/Magento/Widget/Controller/Adminhtml/Widget/LoadOptions.php
@@ -6,9 +6,11 @@
*/
namespace Magento\Widget\Controller\Adminhtml\Widget;
+use Magento\Framework\App\Action\HttpGetActionInterface;
+use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
use Magento\Framework\App\ObjectManager;
-class LoadOptions extends \Magento\Backend\App\Action
+class LoadOptions extends \Magento\Backend\App\Action implements HttpGetActionInterface, HttpPostActionInterface
{
/**
* Authorization level of a basic admin session
diff --git a/app/code/Magento/Wishlist/Helper/Data.php b/app/code/Magento/Wishlist/Helper/Data.php
index f4c1aa9662bda..3b9f431566da0 100644
--- a/app/code/Magento/Wishlist/Helper/Data.php
+++ b/app/code/Magento/Wishlist/Helper/Data.php
@@ -195,6 +195,7 @@ public function getWishlist()
/**
* Retrieve wishlist item count (include config settings)
+ *
* Used in top link menu only
*
* @return int
@@ -450,6 +451,8 @@ public function getSharedAddAllToCartUrl()
}
/**
+ * Get cart URL parameters
+ *
* @param string|\Magento\Catalog\Model\Product|\Magento\Wishlist\Model\Item $item
* @return array
*/
@@ -576,7 +579,7 @@ public function calculate()
) {
$count = $collection->getItemsQty();
} else {
- $count = $collection->getSize();
+ $count = $collection->count();
}
$this->_customerSession->setWishlistDisplayType(
$this->scopeConfig->getValue(
diff --git a/app/code/Magento/Wishlist/Model/ResourceModel/Item/Collection.php b/app/code/Magento/Wishlist/Model/ResourceModel/Item/Collection.php
index 225026f31a994..b285270c67ef8 100644
--- a/app/code/Magento/Wishlist/Model/ResourceModel/Item/Collection.php
+++ b/app/code/Magento/Wishlist/Model/ResourceModel/Item/Collection.php
@@ -307,6 +307,7 @@ protected function _assignProducts()
$checkInStock = $this->_productInStock && !$this->stockConfiguration->isShowOutOfStock();
+ /** @var \Magento\Wishlist\Model\Item $item */
foreach ($this as $item) {
$product = $productCollection->getItemById($item->getProductId());
if ($product) {
@@ -320,7 +321,7 @@ protected function _assignProducts()
$item->setPrice($product->getPrice());
}
} else {
- $item->isDeleted(true);
+ $this->removeItemByKey($item->getId());
}
}
@@ -418,6 +419,7 @@ public function setVisibilityFilter($flag = true)
/**
* Set Salable Filter.
+ *
* This filter apply Salable Product Types Filter to product collection.
*
* @param bool $flag
@@ -431,6 +433,7 @@ public function setSalableFilter($flag = true)
/**
* Set In Stock Filter.
+ *
* This filter remove items with no salable product.
*
* @param bool $flag
@@ -567,6 +570,8 @@ public function getItemsQty()
}
/**
+ * After load data
+ *
* @return $this
*/
protected function _afterLoadData()
diff --git a/app/code/Magento/Wishlist/Model/Wishlist.php b/app/code/Magento/Wishlist/Model/Wishlist.php
index ec0021c4949ea..9797ab58b0766 100644
--- a/app/code/Magento/Wishlist/Model/Wishlist.php
+++ b/app/code/Magento/Wishlist/Model/Wishlist.php
@@ -380,6 +380,7 @@ public function addItem(Item $item)
/**
* Adds new product to wishlist.
+ *
* Returns new item or string on error.
*
* @param int|\Magento\Catalog\Model\Product $product
@@ -581,7 +582,7 @@ public function setStore($store)
*/
public function getItemsCount()
{
- return $this->getItemCollection()->getSize();
+ return $this->getItemCollection()->count();
}
/**
diff --git a/app/code/Magento/Wishlist/Test/Mftf/ActionGroup/StorefrontCustomerWishlistActionGroup.xml b/app/code/Magento/Wishlist/Test/Mftf/ActionGroup/StorefrontCustomerWishlistActionGroup.xml
index c4b3763af9b97..7bb42e12d1451 100644
--- a/app/code/Magento/Wishlist/Test/Mftf/ActionGroup/StorefrontCustomerWishlistActionGroup.xml
+++ b/app/code/Magento/Wishlist/Test/Mftf/ActionGroup/StorefrontCustomerWishlistActionGroup.xml
@@ -25,6 +25,7 @@
+
diff --git a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontAddMultipleStoreProductsToWishlistTest.xml b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontAddMultipleStoreProductsToWishlistTest.xml
index 8ea82490a63f9..145fb94f356f7 100644
--- a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontAddMultipleStoreProductsToWishlistTest.xml
+++ b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontAddMultipleStoreProductsToWishlistTest.xml
@@ -87,15 +87,12 @@
-
-
-
diff --git a/app/design/adminhtml/Magento/backend/Magento_Backend/web/images/logo-magento.png b/app/design/adminhtml/Magento/backend/Magento_Backend/web/images/logo-magento.png
index d9395c938cbff..0cca183e08da2 100644
Binary files a/app/design/adminhtml/Magento/backend/Magento_Backend/web/images/logo-magento.png and b/app/design/adminhtml/Magento/backend/Magento_Backend/web/images/logo-magento.png differ
diff --git a/app/design/adminhtml/Magento/backend/web/css/source/components/_calendar-temp.less b/app/design/adminhtml/Magento/backend/web/css/source/components/_calendar-temp.less
index 11b187db3d1e4..5ba18af6b0547 100644
--- a/app/design/adminhtml/Magento/backend/web/css/source/components/_calendar-temp.less
+++ b/app/design/adminhtml/Magento/backend/web/css/source/components/_calendar-temp.less
@@ -43,7 +43,7 @@
height: @action__height;
margin-left: -@action__height;
overflow: hidden;
- position: absolute;
+ position: relative;
vertical-align: top;
z-index: 1;
diff --git a/app/design/frontend/Magento/blank/web/images/logo.svg b/app/design/frontend/Magento/blank/web/images/logo.svg
index 013d6e7c5a107..e4f627809b627 100644
--- a/app/design/frontend/Magento/blank/web/images/logo.svg
+++ b/app/design/frontend/Magento/blank/web/images/logo.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
diff --git a/app/etc/di.xml b/app/etc/di.xml
index 8e050dec6eb87..db979f9b76382 100755
--- a/app/etc/di.xml
+++ b/app/etc/di.xml
@@ -206,8 +206,6 @@
-
@@ -1695,4 +1693,32 @@
Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT
+
+
+
+
+ - CsrfRequestValidator
+ -
+ Magento\Framework\App\Request\HttpMethodValidator
+
+
+
+
+
+
+
+
+ - \Magento\Framework\App\Action\HttpOptionsActionInterface
+ - \Magento\Framework\App\Action\HttpGetActionInterface
+ - \Magento\Framework\App\Action\HttpHeadActionInterface
+ - \Magento\Framework\App\Action\HttpPostActionInterface
+ - \Magento\Framework\App\Action\HttpPutActionInterface
+ - \Magento\Framework\App\Action\HttpPatchActionInterface
+ - \Magento\Framework\App\Action\HttpDeleteActionInterface
+ - \Magento\Framework\App\Action\HttpConnectActionInterface
+ - \Magento\Framework\App\Action\HttpPropfindActionInterface
+ - \Magento\Framework\App\Action\HttpTraceActionInterface
+
+
+
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CustomerChangePasswordTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CustomerChangePasswordTest.php
new file mode 100644
index 0000000000000..ede719bb569ba
--- /dev/null
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CustomerChangePasswordTest.php
@@ -0,0 +1,147 @@
+customerTokenService = Bootstrap::getObjectManager()->get(CustomerTokenServiceInterface::class);
+ $this->accountManagement = Bootstrap::getObjectManager()->get(AccountManagementInterface::class);
+ $this->customerRegistry = Bootstrap::getObjectManager()->get(CustomerRegistry::class);
+ }
+
+ /**
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
+ */
+ public function testCustomerChangeValidPassword()
+ {
+ $customerEmail = 'customer@example.com';
+ $oldCustomerPassword = 'password';
+ $newCustomerPassword = 'anotherPassword1';
+
+ $query = $this->getChangePassQuery($oldCustomerPassword, $newCustomerPassword);
+ $headerMap = $this->getCustomerAuthHeaders($customerEmail, $oldCustomerPassword);
+
+ $response = $this->graphQlQuery($query, [], '', $headerMap);
+ $this->assertEquals($customerEmail, $response['changeCustomerPassword']['email']);
+
+ try {
+ // registry contains the old password hash so needs to be reset
+ $this->customerRegistry->removeByEmail($customerEmail);
+ $this->accountManagement->authenticate($customerEmail, $newCustomerPassword);
+ } catch (LocalizedException $e) {
+ $this->fail('Password was not changed: ' . $e->getMessage());
+ }
+ }
+
+ public function testGuestUserCannotChangePassword()
+ {
+ $query = $this->getChangePassQuery('currentpassword', 'newpassword');
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage(
+ 'GraphQL response contains errors: Current customer' . ' ' .
+ 'does not have access to the resource "customer"'
+ );
+ $this->graphQlQuery($query);
+ }
+
+ /**
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
+ */
+ public function testChangeWeakPassword()
+ {
+ $this->markTestIncomplete('https://github.com/magento/graphql-ce/issues/190');
+ $customerEmail = 'customer@example.com';
+ $oldCustomerPassword = 'password';
+ $newCustomerPassword = 'weakpass';
+
+ $query = $this->getChangePassQuery($oldCustomerPassword, $newCustomerPassword);
+ $headerMap = $this->getCustomerAuthHeaders($customerEmail, $oldCustomerPassword);
+
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessageRegExp('/Minimum of different classes of characters in password is.*/');
+
+ $this->graphQlQuery($query, [], '', $headerMap);
+ }
+
+ /**
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
+ */
+ public function testCannotChangeWithIncorrectPassword()
+ {
+ $this->markTestIncomplete('https://github.com/magento/graphql-ce/issues/190');
+ $customerEmail = 'customer@example.com';
+ $oldCustomerPassword = 'password';
+ $newCustomerPassword = 'anotherPassword1';
+ $incorrectPassword = 'password-incorrect';
+
+ $query = $this->getChangePassQuery($incorrectPassword, $newCustomerPassword);
+
+ // acquire authentication with correct password
+ $headerMap = $this->getCustomerAuthHeaders($customerEmail, $oldCustomerPassword);
+
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessageRegExp('/The password doesn\'t match this account. Verify the password.*/');
+
+ // but try to change with incorrect 'old' password
+ $this->graphQlQuery($query, [], '', $headerMap);
+ }
+
+ private function getChangePassQuery($currentPassword, $newPassword)
+ {
+ $query = <<customerTokenService->createCustomerAccessToken($email, $password);
+ return ['Authorization' => 'Bearer ' . $customerToken];
+ }
+}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/GenerateCustomerTokenTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/GenerateCustomerTokenTest.php
new file mode 100644
index 0000000000000..ae28e23a28bf1
--- /dev/null
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/GenerateCustomerTokenTest.php
@@ -0,0 +1,71 @@
+graphQlQuery($mutation);
+ $this->assertArrayHasKey('generateCustomerToken', $response);
+ $this->assertInternalType('array', $response['generateCustomerToken']);
+ }
+
+ /**
+ * Verify customer with invalid credentials
+ */
+ public function testGenerateCustomerTokenWithInvalidCredentials()
+ {
+ $userName = 'customer@example.com';
+ $password = 'bad-password';
+
+ $mutation
+ = <<expectException(\Exception::class);
+ $this->expectExceptionMessage('GraphQL response contains errors: The account sign-in' . ' ' .
+ 'was incorrect or your account is disabled temporarily. Please wait and try again later.');
+ $this->graphQlQuery($mutation);
+ }
+}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/CouponTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/CouponTest.php
new file mode 100644
index 0000000000000..1f8ad06a9f8ed
--- /dev/null
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/CouponTest.php
@@ -0,0 +1,225 @@
+quoteResource = $objectManager->create(QuoteResource::class);
+ $this->quote = $objectManager->create(Quote::class);
+ $this->quoteIdToMaskedId = $objectManager->create(QuoteIdToMaskedQuoteIdInterface::class);
+ }
+
+ /**
+ * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
+ * @magentoApiDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
+ */
+ public function testApplyCouponToGuestCartWithItems()
+ {
+ $couponCode = '2?ds5!2d';
+
+ $this->quoteResource->load(
+ $this->quote,
+ 'test_order_with_simple_product_without_address',
+ 'reserved_order_id'
+ );
+ $maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());
+ $query = $this->prepareAddCouponRequestQuery($maskedQuoteId, $couponCode);
+ $response = $this->graphQlQuery($query);
+
+ self::assertArrayHasKey("applyCouponToCart", $response);
+ self::assertEquals($couponCode, $response['applyCouponToCart']['cart']['applied_coupon']['code']);
+ }
+
+ /**
+ * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
+ * @magentoApiDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
+ */
+ public function testApplyCouponTwice()
+ {
+ $couponCode = '2?ds5!2d';
+
+ $this->quoteResource->load(
+ $this->quote,
+ 'test_order_with_simple_product_without_address',
+ 'reserved_order_id'
+ );
+ $maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());
+ $query = $this->prepareAddCouponRequestQuery($maskedQuoteId, $couponCode);
+ $response = $this->graphQlQuery($query);
+
+ self::assertArrayHasKey("applyCouponToCart", $response);
+ self::assertEquals($couponCode, $response['applyCouponToCart']['cart']['applied_coupon']['code']);
+
+ self::expectExceptionMessage('A coupon is already applied to the cart. Please remove it to apply another');
+ $this->graphQlQuery($query);
+ }
+
+ /**
+ * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
+ * @magentoApiDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
+ */
+ public function testApplyCouponToCartWithNoItems()
+ {
+ $this->markTestIncomplete('https://github.com/magento/graphql-ce/issues/191');
+ $couponCode = '2?ds5!2d';
+
+ $this->quoteResource->load($this->quote, 'test_order_1', 'reserved_order_id');
+ $maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());
+ $query = $this->prepareAddCouponRequestQuery($maskedQuoteId, $couponCode);
+
+ self::expectExceptionMessageRegExp('/Cart doesn\'t contain products/');
+ $this->graphQlQuery($query);
+ }
+
+ /**
+ * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
+ * @magentoApiDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
+ */
+ public function testGuestCustomerAttemptToChangeCustomerCart()
+ {
+ $couponCode = '2?ds5!2d';
+
+ $this->quoteResource->load(
+ $this->quote,
+ 'test_order_with_simple_product_without_address',
+ 'reserved_order_id'
+ );
+ $maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());
+ $this->quote->setCustomerId(1);
+ $this->quoteResource->save($this->quote);
+ $query = $this->prepareAddCouponRequestQuery($maskedQuoteId, $couponCode);
+
+ self::expectExceptionMessage('The current user cannot perform operations on cart "' . $maskedQuoteId . '"');
+ $this->graphQlQuery($query);
+ }
+
+ /**
+ * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
+ * @magentoApiDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
+ */
+ public function testRemoveCoupon()
+ {
+ $couponCode = '2?ds5!2d';
+
+ /* Apply coupon to the quote */
+ $this->quoteResource->load(
+ $this->quote,
+ 'test_order_with_simple_product_without_address',
+ 'reserved_order_id'
+ );
+ $maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());
+ $this->quoteResource->load(
+ $this->quote,
+ 'test_order_with_simple_product_without_address',
+ 'reserved_order_id'
+ );
+ $query = $this->prepareAddCouponRequestQuery($maskedQuoteId, $couponCode);
+ $this->graphQlQuery($query);
+
+ /* Remove coupon from quote */
+ $query = $this->prepareRemoveCouponRequestQuery($maskedQuoteId);
+ $response = $this->graphQlQuery($query);
+
+ self::assertArrayHasKey('removeCouponFromCart', $response);
+ self::assertSame('', $response['removeCouponFromCart']['cart']['applied_coupon']['code']);
+ }
+
+ /**
+ * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
+ * @magentoApiDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
+ */
+ public function testRemoveCouponFromCustomerCartByGuest()
+ {
+ $this->quoteResource->load(
+ $this->quote,
+ 'test_order_with_simple_product_without_address',
+ 'reserved_order_id'
+ );
+ $maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());
+ $this->quoteResource->load(
+ $this->quote,
+ 'test_order_with_simple_product_without_address',
+ 'reserved_order_id'
+ );
+ $this->quote->setCustomerId(1);
+ $this->quoteResource->save($this->quote);
+ $query = $this->prepareRemoveCouponRequestQuery($maskedQuoteId);
+
+ self::expectExceptionMessage('The current user cannot perform operations on cart "' . $maskedQuoteId . '"');
+ $this->graphQlQuery($query);
+ }
+
+ /**
+ * @param string $maskedQuoteId
+ * @param string $couponCode
+ * @return string
+ */
+ private function prepareAddCouponRequestQuery(string $maskedQuoteId, string $couponCode): string
+ {
+ return <<graphQlQuery($query);
$this->assertArrayHasKey('urlResolver', $response);
$this->assertEquals($product->getEntityId(), $response['urlResolver']['id']);
- $this->assertEquals($targetPath, $response['urlResolver']['canonical_url']);
+ $this->assertEquals($targetPath, $response['urlResolver']['relative_url']);
$this->assertEquals(strtoupper($expectedType), $response['urlResolver']['type']);
}
/**
- * Tests the use case where canonical_url is provided as resolver input in the Query
+ * Tests the use case where relative_url is provided as resolver input in the Query
*
* @magentoApiDataFixture Magento/CatalogUrlRewrite/_files/product_with_category.php
*/
@@ -101,7 +104,7 @@ public function testProductUrlWithCanonicalUrlInput()
urlResolver(url:"{$canonicalPath}")
{
id
- canonical_url
+ relative_url
type
}
}
@@ -109,7 +112,7 @@ public function testProductUrlWithCanonicalUrlInput()
$response = $this->graphQlQuery($query);
$this->assertArrayHasKey('urlResolver', $response);
$this->assertEquals($product->getEntityId(), $response['urlResolver']['id']);
- $this->assertEquals($targetPath, $response['urlResolver']['canonical_url']);
+ $this->assertEquals($targetPath, $response['urlResolver']['relative_url']);
$this->assertEquals(strtoupper($expectedType), $response['urlResolver']['type']);
}
@@ -144,7 +147,7 @@ public function testCategoryUrlResolver()
urlResolver(url:"{$urlPath2}")
{
id
- canonical_url
+ relative_url
type
}
}
@@ -152,7 +155,7 @@ public function testCategoryUrlResolver()
$response = $this->graphQlQuery($query);
$this->assertArrayHasKey('urlResolver', $response);
$this->assertEquals($categoryId, $response['urlResolver']['id']);
- $this->assertEquals($targetPath, $response['urlResolver']['canonical_url']);
+ $this->assertEquals($targetPath, $response['urlResolver']['relative_url']);
$this->assertEquals(strtoupper($expectedType), $response['urlResolver']['type']);
}
@@ -180,14 +183,14 @@ public function testCMSPageUrlResolver()
urlResolver(url:"{$requestPath}")
{
id
- canonical_url
+ relative_url
type
}
}
QUERY;
$response = $this->graphQlQuery($query);
$this->assertEquals($cmsPageId, $response['urlResolver']['id']);
- $this->assertEquals($targetPath, $response['urlResolver']['canonical_url']);
+ $this->assertEquals($targetPath, $response['urlResolver']['relative_url']);
$this->assertEquals(strtoupper(str_replace('-', '_', $expectedEntityType)), $response['urlResolver']['type']);
}
@@ -223,7 +226,7 @@ public function testProductUrlRewriteResolver()
urlResolver(url:"{$urlPath}")
{
id
- canonical_url
+ relative_url
type
}
}
@@ -231,7 +234,7 @@ public function testProductUrlRewriteResolver()
$response = $this->graphQlQuery($query);
$this->assertArrayHasKey('urlResolver', $response);
$this->assertEquals($product->getEntityId(), $response['urlResolver']['id']);
- $this->assertEquals($targetPath, $response['urlResolver']['canonical_url']);
+ $this->assertEquals($targetPath, $response['urlResolver']['relative_url']);
$this->assertEquals(strtoupper($expectedType), $response['urlResolver']['type']);
}
@@ -263,7 +266,7 @@ public function testInvalidUrlResolverInput()
urlResolver(url:"{$urlPath}")
{
id
- canonical_url
+ relative_url
type
}
}
@@ -304,7 +307,7 @@ public function testCategoryUrlWithLeadingSlash()
urlResolver(url:"/{$urlPath}")
{
id
- canonical_url
+ relative_url
type
}
}
@@ -312,7 +315,7 @@ public function testCategoryUrlWithLeadingSlash()
$response = $this->graphQlQuery($query);
$this->assertArrayHasKey('urlResolver', $response);
$this->assertEquals($categoryId, $response['urlResolver']['id']);
- $this->assertEquals($targetPath, $response['urlResolver']['canonical_url']);
+ $this->assertEquals($targetPath, $response['urlResolver']['relative_url']);
$this->assertEquals(strtoupper($expectedType), $response['urlResolver']['type']);
}
@@ -321,22 +324,35 @@ public function testCategoryUrlWithLeadingSlash()
*/
public function testResolveSlash()
{
+ /** @var \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfigInterface */
+ $scopeConfigInterface = $this->objectManager->get(ScopeConfigInterface::class);
+ $homePageIdentifier = $scopeConfigInterface->getValue(
+ PageHelper::XML_PATH_HOME_PAGE,
+ ScopeInterface::SCOPE_STORE
+ );
+ /** @var \Magento\Cms\Model\Page $page */
+ $page = $this->objectManager->get(\Magento\Cms\Model\Page::class);
+ $page->load($homePageIdentifier);
+ $homePageId = $page->getId();
+ /** @var \Magento\CmsUrlRewrite\Model\CmsPageUrlPathGenerator $urlPathGenerator */
+ $urlPathGenerator = $this->objectManager->get(\Magento\CmsUrlRewrite\Model\CmsPageUrlPathGenerator::class);
+ /** @param \Magento\Cms\Api\Data\PageInterface $page */
+ $targetPath = $urlPathGenerator->getCanonicalUrlPath($page);
$query
= <<graphQlQuery($query);
-
$this->assertArrayHasKey('urlResolver', $response);
- $this->assertEquals(2, $response['urlResolver']['id']);
- $this->assertEquals('cms/page/view/page_id/2', $response['urlResolver']['canonical_url']);
+ $this->assertEquals($homePageId, $response['urlResolver']['id']);
+ $this->assertEquals($targetPath, $response['urlResolver']['relative_url']);
$this->assertEquals('CMS_PAGE', $response['urlResolver']['type']);
}
}
diff --git a/dev/tests/functional/lib/Magento/Mtf/Constraint/AbstractAssertForm.php b/dev/tests/functional/lib/Magento/Mtf/Constraint/AbstractAssertForm.php
index eb04450d5261d..61e5b7649303f 100644
--- a/dev/tests/functional/lib/Magento/Mtf/Constraint/AbstractAssertForm.php
+++ b/dev/tests/functional/lib/Magento/Mtf/Constraint/AbstractAssertForm.php
@@ -53,7 +53,7 @@ protected function verifyData(array $fixtureData, array $formData, $isStrict = f
}
$formValue = isset($formData[$key]) ? $formData[$key] : null;
if (is_numeric($formValue)) {
- $formValue = floatval($formValue);
+ $formValue = (float)$formValue;
}
if (null === $formValue) {
@@ -118,6 +118,7 @@ protected function sortData(array $data)
/**
* Sort multidimensional array by paths.
+ *
* Pattern path: key/subKey::sortKey.
* Example:
* $data = [
@@ -150,7 +151,6 @@ protected function sortData(array $data)
*
* @param array $data
* @param string $path
- * @param string $path
* @return array
* @throws \Exception
*
diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Handler/Ui/LoginUser.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Handler/Ui/LoginUser.php
index 3738f51ef6c6a..01d8401b22fe1 100644
--- a/dev/tests/functional/tests/app/Magento/Backend/Test/Handler/Ui/LoginUser.php
+++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Handler/Ui/LoginUser.php
@@ -6,6 +6,7 @@
namespace Magento\Backend\Test\Handler\Ui;
+use Magento\Backend\Test\Page\AdminAuthLogin;
use Magento\Mtf\Factory\Factory;
use Magento\Mtf\Fixture\FixtureInterface;
use Magento\Mtf\Handler\Ui;
@@ -29,10 +30,15 @@ public function persist(FixtureInterface $fixture = null)
$fixture = Factory::getFixtureFactory()->getMagentoBackendAdminSuperAdmin();
}
+ /** @var AdminAuthLogin $loginPage */
$loginPage = Factory::getPageFactory()->getAdminAuthLogin();
$loginForm = $loginPage->getLoginBlock();
-
$adminHeaderPanel = $loginPage->getHeaderBlock();
+ if (!$loginForm->isVisible() && !$adminHeaderPanel->isVisible()) {
+ //We are currently not in the admin area.
+ $loginPage->open();
+ }
+
if (!$adminHeaderPanel || !$adminHeaderPanel->isVisible()) {
$loginPage->open();
if ($adminHeaderPanel->isVisible()) {
diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php
index 9f05a4ade8a37..dcc8cce970098 100644
--- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php
+++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Product/View/CustomOptions.php
@@ -231,7 +231,7 @@ protected function getFieldData(SimpleElement $option)
return [
'options' => [
[
- 'price' => floatval($price),
+ 'price' => (float)$price,
'max_characters' => $maxCharacters,
],
]
@@ -262,7 +262,7 @@ protected function getFileData(SimpleElement $option)
return [
'options' => [
[
- 'price' => floatval($price),
+ 'price' => (float)$price,
'file_extension' => $this->getOptionNotice($option, 1),
'image_size_x' => preg_replace('/[^0-9]/', '', $this->getOptionNotice($option, 2)),
'image_size_y' => preg_replace('/[^0-9]/', '', $this->getOptionNotice($option, 3)),
@@ -344,7 +344,7 @@ protected function getDateData(SimpleElement $option)
return [
'options' => [
[
- 'price' => floatval($price),
+ 'price' => (float)$price,
],
]
];
diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.php
index 5e871bf6d97a5..707a62a446054 100644
--- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.php
+++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.php
@@ -10,6 +10,7 @@
use Magento\Catalog\Test\Page\Adminhtml\CatalogProductNew;
use Magento\Mtf\Fixture\FixtureFactory;
use Magento\Mtf\TestCase\Injectable;
+use Magento\Downloadable\Test\Block\Adminhtml\Catalog\Product\Edit\Section\Downloadable;
/**
* Test Creation for ProductTypeSwitchingOnCreation
@@ -75,18 +76,49 @@ public function __inject(
*
* @param string $createProduct
* @param string $product
+ * @param string $actionName
* @return array
*/
- public function test($createProduct, $product)
+ public function test(string $createProduct, string $product, string $actionName = null): array
{
// Steps
list($fixture, $dataset) = explode('::', $product);
$product = $this->fixtureFactory->createByCode($fixture, ['dataset' => $dataset]);
$this->catalogProductIndex->open();
$this->catalogProductIndex->getGridPageActionBlock()->addProduct($createProduct);
+ if ($actionName) {
+ $this->performAction($actionName);
+ }
$this->catalogProductNew->getProductForm()->fill($product);
$this->catalogProductNew->getFormPageActions()->save($product);
return ['product' => $product];
}
+
+ /**
+ * Perform action.
+ *
+ * @param string $actionName
+ * @return void
+ */
+ private function performAction(string $actionName): void
+ {
+ if (method_exists(__CLASS__, $actionName)) {
+ $this->$actionName();
+ }
+ }
+
+ /**
+ * Clear downloadable product data.
+ *
+ * @return void
+ */
+ private function clearDownloadableData(): void
+ {
+ $this->catalogProductNew->getProductForm()->openSection('downloadable_information');
+ /** @var Downloadable $downloadableInfoTab */
+ $downloadableInfoTab = $this->catalogProductNew->getProductForm()->getSection('downloadable_information');
+ $downloadableInfoTab->getDownloadableBlock('Links')->clearDownloadableData();
+ $downloadableInfoTab->setIsDownloadable('No');
+ }
}
diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.xml
index f45fbc96a738d..7c4824c604e29 100644
--- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/ProductTypeSwitchingOnCreationTest.xml
@@ -76,7 +76,7 @@
downloadable
configurableProduct::not_virtual_for_type_switching
- to_maintain:yes
+ clearDownloadableData
diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleForm.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleForm.php
index 7db32337b995d..17739f5524e13 100644
--- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleForm.php
+++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleForm.php
@@ -42,10 +42,10 @@ public function processAssert(
$fixtureData = $catalogPriceRule->getData();
//convert discount_amount to float to compare
if (isset($formData['discount_amount'])) {
- $formData['discount_amount'] = floatval($formData['discount_amount']);
+ $formData['discount_amount'] = (float)$formData['discount_amount'];
}
if (isset($fixtureData['discount_amount'])) {
- $fixtureData['discount_amount'] = floatval($fixtureData['discount_amount']);
+ $fixtureData['discount_amount'] = (float)$fixtureData['discount_amount'];
}
$diff = $this->verifyData($formData, $fixtureData);
\PHPUnit\Framework\Assert::assertTrue(
diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Downloadable.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Downloadable.php
index ebc19eec9ad53..d78a2d94e7635 100644
--- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Downloadable.php
+++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Block/Adminhtml/Catalog/Product/Edit/Section/Downloadable.php
@@ -104,4 +104,21 @@ public function setFieldsData(array $fields, SimpleElement $element = null)
return $this;
}
+
+ /**
+ * Set "Is this downloadable Product?" value.
+ *
+ * @param string $downloadable
+ * @param SimpleElement|null $element
+ * @return void
+ */
+ public function setIsDownloadable(string $downloadable = 'Yes', SimpleElement $element = null): void
+ {
+ $context = $element ?: $this->_rootElement;
+ $isDownloadable = $context->find($this->isDownloadableProduct);
+ $value = 'Yes' == $downloadable ? '1' : '0';
+ if ($isDownloadable->isVisible() && $isDownloadable->getAttribute('value') != $value) {
+ $isDownloadable->click();
+ }
+ }
}
diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Handler/DownloadableProduct/Webapi.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Handler/DownloadableProduct/Webapi.php
index 434c78e55c69b..d14d6754b12ec 100644
--- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Handler/DownloadableProduct/Webapi.php
+++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Handler/DownloadableProduct/Webapi.php
@@ -148,7 +148,7 @@ protected function prepareLinkData(array $link)
'title' => $link['title'],
'sort_order' => isset($link['sort_order']) ? $link['sort_order'] : 0,
'is_shareable' => $link['is_shareable'],
- 'price' => floatval($link['price']),
+ 'price' => (float)$link['price'],
'number_of_downloads' => isset($link['number_of_downloads']) ? $link['number_of_downloads'] : 0,
'link_type' => $link['type'],
'link_url' => isset($link['link_url']) ? $link['link_url'] : null,
diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertSalesReportIntervalResult.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertSalesReportIntervalResult.php
index 745450aa2c024..1236a86e160b6 100644
--- a/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertSalesReportIntervalResult.php
+++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertSalesReportIntervalResult.php
@@ -52,7 +52,7 @@ protected function prepareSalesResult($salesResult)
{
$data = [];
foreach ($salesResult as $key => $result) {
- $data[$key] = floatval($result);
+ $data[$key] = (float)$result;
}
return $data;
diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertSalesReportTotalResult.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertSalesReportTotalResult.php
index 5f435e4822904..423ca6dafbdde 100644
--- a/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertSalesReportTotalResult.php
+++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Constraint/AssertSalesReportTotalResult.php
@@ -52,7 +52,7 @@ protected function prepareSalesResult($salesResult)
{
$data = [];
foreach ($salesResult as $key => $result) {
- $data[$key] = floatval($result);
+ $data[$key] = (float)$result;
}
return $data;
diff --git a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractBackendController.php b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractBackendController.php
index 543bac2c6b5b5..b2e0b57bae729 100644
--- a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractBackendController.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractBackendController.php
@@ -5,10 +5,12 @@
*/
namespace Magento\TestFramework\TestCase;
+use Magento\Framework\App\Request\Http as HttpRequest;
+
/**
- * A parent class for backend controllers - contains directives for admin user creation and authentication
+ * A parent class for backend controllers - contains directives for admin user creation and authentication.
+ *
* @SuppressWarnings(PHPMD.NumberOfChildren)
- * @SuppressWarnings(PHPMD.numberOfChildren)
*/
abstract class AbstractBackendController extends \Magento\TestFramework\TestCase\AbstractController
{
@@ -36,6 +38,16 @@ abstract class AbstractBackendController extends \Magento\TestFramework\TestCase
*/
protected $uri = null;
+ /**
+ * @var string|null
+ */
+ protected $httpMethod;
+
+ /**
+ * @inheritDoc
+ *
+ * @throws \Magento\Framework\Exception\AuthenticationException
+ */
protected function setUp()
{
parent::setUp();
@@ -62,6 +74,9 @@ protected function _getAdminCredentials()
];
}
+ /**
+ * @inheritDoc
+ */
protected function tearDown()
{
$this->_auth->getAuthStorage()->destroy(['send_expire_cookie' => false]);
@@ -86,21 +101,33 @@ public function assertSessionMessages(
parent::assertSessionMessages($constraint, $messageType, $messageManagerClass);
}
+ /**
+ * Test ACL configuration for action working.
+ */
public function testAclHasAccess()
{
if ($this->uri === null) {
$this->markTestIncomplete('AclHasAccess test is not complete');
}
+ if ($this->httpMethod) {
+ $this->getRequest()->setMethod($this->httpMethod);
+ }
$this->dispatch($this->uri);
$this->assertNotSame(403, $this->getResponse()->getHttpResponseCode());
$this->assertNotSame(404, $this->getResponse()->getHttpResponseCode());
}
+ /**
+ * Test ACL actually denying access.
+ */
public function testAclNoAccess()
{
if ($this->resource === null) {
$this->markTestIncomplete('Acl test is not complete');
}
+ if ($this->httpMethod) {
+ $this->getRequest()->setMethod($this->httpMethod);
+ }
$this->_objectManager->get(\Magento\Framework\Acl\Builder::class)
->getAcl()
->deny(null, $this->resource);
diff --git a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php
index 1bf6d471fc40a..feb9eca0793a2 100644
--- a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php
@@ -10,10 +10,12 @@
namespace Magento\TestFramework\TestCase;
use Magento\Framework\Data\Form\FormKey;
+use Magento\Framework\Message\MessageInterface;
use Magento\Framework\Stdlib\CookieManagerInterface;
use Magento\Framework\View\Element\Message\InterpretationStrategyInterface;
use Magento\Theme\Controller\Result\MessagePlugin;
use Magento\Framework\App\Request\Http as HttpRequest;
+use Magento\Framework\App\Response\Http as HttpResponse;
/**
* @SuppressWarnings(PHPMD.NumberOfChildren)
@@ -70,6 +72,9 @@ protected function setUp()
$this->_objectManager->removeSharedInstance(\Magento\Framework\App\RequestInterface::class);
}
+ /**
+ * @inheritDoc
+ */
protected function tearDown()
{
$this->_request = null;
@@ -114,7 +119,7 @@ public function dispatch($uri)
/**
* Request getter
*
- * @return \Magento\Framework\App\RequestInterface
+ * @return \Magento\Framework\App\RequestInterface|HttpRequest
*/
public function getRequest()
{
@@ -127,7 +132,7 @@ public function getRequest()
/**
* Response getter
*
- * @return \Magento\Framework\App\ResponseInterface
+ * @return \Magento\Framework\App\ResponseInterface|HttpResponse
*/
public function getResponse()
{
@@ -212,13 +217,21 @@ public function assertSessionMessages(
$messageManagerClass = \Magento\Framework\Message\Manager::class
) {
$this->_assertSessionErrors = false;
-
+ /** @var MessageInterface[]|string[] $messageObjects */
$messages = $this->getMessages($messageType, $messageManagerClass);
+ /** @var string[] $messages */
+ $messagesFiltered = array_map(
+ function ($message) {
+ /** @var MessageInterface|string $message */
+ return ($message instanceof MessageInterface) ? $message->toString() : $message;
+ },
+ $messages
+ );
$this->assertThat(
- $messages,
+ $messagesFiltered,
$constraint,
- 'Session messages do not meet expectations ' . var_export($messages, true)
+ 'Session messages do not meet expectations ' . var_export($messagesFiltered, true)
);
}
diff --git a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/IndexTest.php b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/IndexTest.php
index 219fde6e37075..d5a48b960811e 100644
--- a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/IndexTest.php
+++ b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/IndexTest.php
@@ -5,6 +5,8 @@
*/
namespace Magento\Backend\Controller\Adminhtml;
+use Magento\Framework\App\Request\Http as HttpRequest;
+
/**
* @magentoAppArea adminhtml
* @magentoDbIsolation enabled
@@ -45,6 +47,7 @@ public function testLoggedIndexAction()
public function testGlobalSearchAction()
{
$this->getRequest()->setParam('isAjax', 'true');
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue('query', 'dummy');
$this->dispatch('backend/admin/index/globalSearch');
diff --git a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/UrlRewriteTest.php b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/UrlRewriteTest.php
index 1185ae9727e98..0d48fc8b0f59c 100644
--- a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/UrlRewriteTest.php
+++ b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/UrlRewriteTest.php
@@ -5,6 +5,8 @@
*/
namespace Magento\Backend\Controller\Adminhtml;
+use Magento\Framework\App\Request\Http as HttpRequest;
+
/**
* @magentoAppArea adminhtml
*/
@@ -20,6 +22,7 @@ public function testSaveActionCmsPage()
$page = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Cms\Model\Page::class);
$page->load('page_design_blank', 'identifier');
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue(
[
'description' => 'Some URL rewrite description',
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php
index 11f49464bbd21..a6d03fcc200e2 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php
@@ -5,6 +5,8 @@
*/
namespace Magento\Catalog\Controller\Adminhtml;
+use Magento\Framework\App\Request\Http as HttpRequest;
+
/**
* @magentoAppArea adminhtml
*/
@@ -27,6 +29,7 @@ public function testSaveAction($inputData, $defaultAttributes, $attributesSaved
$store->load('fixturestore', 'code');
$storeId = $store->getId();
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($inputData);
$this->getRequest()->setParam('store', $storeId);
$this->getRequest()->setParam('id', 2);
@@ -75,6 +78,7 @@ public function testSaveAction($inputData, $defaultAttributes, $attributesSaved
*/
public function testSaveActionFromProductCreationPage($postData)
{
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($postData);
$this->dispatch('backend/catalog/category/save');
@@ -123,6 +127,9 @@ public static function categoryCreatedFromProductCreationPageDataProvider()
return [[$postData], [$postData + ['return_session_messages_only' => 1]]];
}
+ /**
+ * Test SuggestCategories finds any categories.
+ */
public function testSuggestCategoriesActionDefaultCategoryFound()
{
$this->getRequest()->setParam('label_part', 'Default');
@@ -133,6 +140,9 @@ public function testSuggestCategoriesActionDefaultCategoryFound()
);
}
+ /**
+ * Test SuggestCategories properly processes search by label.
+ */
public function testSuggestCategoriesActionNoSuggestions()
{
$this->getRequest()->setParam('label_part', strrev('Default'));
@@ -322,8 +332,12 @@ public function saveActionDataProvider()
];
}
+ /**
+ * Test validation.
+ */
public function testSaveActionCategoryWithDangerRequest()
{
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue(
[
'general' => [
@@ -374,7 +388,8 @@ public function testMoveAction($parentId, $childId, $childUrlKey, $grandChildId,
}
$this->getRequest()
->setPostValue('id', $grandChildId)
- ->setPostValue('pid', $parentId);
+ ->setPostValue('pid', $parentId)
+ ->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/catalog/category/move');
$jsonResponse = json_decode($this->getResponse()->getBody());
$this->assertNotNull($jsonResponse);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php
index cea49d940cb62..a2967878402d0 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Action/AttributeTest.php
@@ -5,6 +5,8 @@
*/
namespace Magento\Catalog\Controller\Adminhtml\Product\Action;
+use Magento\Framework\App\Request\Http as HttpRequest;
+
/**
* @magentoAppArea adminhtml
*/
@@ -23,6 +25,7 @@ public function testSaveActionRedirectsSuccessfully()
/** @var $session \Magento\Backend\Model\Session */
$session = $objectManager->get(\Magento\Backend\Model\Session::class);
$session->setProductIds([1]);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/catalog/product_action_attribute/save/store/0');
@@ -69,6 +72,7 @@ public function testSaveActionChangeVisibility($attributes)
$session = $objectManager->get(\Magento\Backend\Model\Session::class);
$session->setProductIds([$product->getId()]);
$this->getRequest()->setParam('attributes', $attributes);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/catalog/product_action_attribute/save/store/0');
/** @var \Magento\Catalog\Model\Category $category */
@@ -89,6 +93,8 @@ public function testSaveActionChangeVisibility($attributes)
}
/**
+ * @param array $attributes Request parameter.
+ *
* @covers \Magento\Catalog\Controller\Adminhtml\Product\Action\Attribute\Validate::execute
*
* @dataProvider validateActionDataProvider
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php
index 4261873cc8e6e..98eb9d3ad4cc4 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/AttributeTest.php
@@ -6,10 +6,13 @@
namespace Magento\Catalog\Controller\Adminhtml\Product;
use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\App\Request\Http as HttpRequest;
/**
* @magentoAppArea adminhtml
* @magentoDbIsolation enabled
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class AttributeTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
@@ -25,6 +28,7 @@ public function testWrongFrontendInput()
'frontend_input' => 'some_input',
]
);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($postData);
$this->dispatch('backend/catalog/product_attribute/save');
$this->assertEquals(302, $this->getResponse()->getHttpResponseCode());
@@ -50,6 +54,7 @@ public function testWithPopup()
'popup' => 'true',
'new_attribute_set_name' => 'new_attribute_set',
];
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($postData);
$this->dispatch('backend/catalog/product_attribute/save');
$this->assertEquals(302, $this->getResponse()->getHttpResponseCode());
@@ -71,6 +76,7 @@ public function testWithExceptionWhenSaveAttribute()
{
$postData = $this->_getAttributeData() + ['attribute_id' => 0, 'frontend_input' => 'boolean'];
$this->getRequest()->setPostValue($postData);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/catalog/product_attribute/save');
$this->assertEquals(302, $this->getResponse()->getHttpResponseCode());
$this->assertContains(
@@ -89,6 +95,7 @@ public function testWrongAttributeId()
{
$postData = $this->_getAttributeData() + ['attribute_id' => 100500];
$this->getRequest()->setPostValue($postData);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/catalog/product_attribute/save');
$this->assertEquals(302, $this->getResponse()->getHttpResponseCode());
$this->assertContains(
@@ -113,6 +120,7 @@ public function testAttributeWithoutId()
'set' => 4,
'frontend_input' => 'boolean',
];
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($postData);
$this->dispatch('backend/catalog/product_attribute/save');
$this->assertEquals(302, $this->getResponse()->getHttpResponseCode());
@@ -135,6 +143,7 @@ public function testWrongAttributeCode()
{
$postData = $this->_getAttributeData() + ['attribute_code' => '_()&&&?'];
$this->getRequest()->setPostValue($postData);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/catalog/product_attribute/save');
$this->assertEquals(302, $this->getResponse()->getHttpResponseCode());
$this->assertContains(
@@ -159,6 +168,7 @@ public function testWrongAttributeCode()
public function testAttributeWithoutEntityTypeId()
{
$postData = $this->_getAttributeData() + ['attribute_id' => '2', 'new_attribute_set_name' => ' '];
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($postData);
$this->dispatch('backend/catalog/product_attribute/save');
$this->assertEquals(302, $this->getResponse()->getHttpResponseCode());
@@ -174,6 +184,7 @@ public function testAttributeWithoutEntityTypeId()
public function testSaveActionApplyToDataSystemAttribute()
{
$postData = $this->_getAttributeData() + ['attribute_id' => '2'];
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($postData);
$this->dispatch('backend/catalog/product_attribute/save');
$model = $this->_objectManager->create(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class);
@@ -187,6 +198,7 @@ public function testSaveActionApplyToDataSystemAttribute()
public function testSaveActionApplyToDataUserDefinedAttribute()
{
$postData = $this->_getAttributeData() + ['attribute_id' => '1'];
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($postData);
$this->dispatch('backend/catalog/product_attribute/save');
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $model */
@@ -202,6 +214,7 @@ public function testSaveActionApplyToData()
{
$postData = $this->_getAttributeData() + ['attribute_id' => '3'];
unset($postData['apply_to']);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($postData);
$this->dispatch('backend/catalog/product_attribute/save');
$model = $this->_objectManager->create(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class);
@@ -221,6 +234,7 @@ public function testSaveActionCleanAttributeLabelCache()
$this->assertEquals('predefined string translation', $this->_translate('string to translate'));
$string->saveTranslate('string to translate', 'new string translation');
$postData = $this->_getAttributeData() + ['attribute_id' => 1];
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($postData);
$this->dispatch('backend/catalog/product_attribute/save');
$this->assertEquals('new string translation', $this->_translate('string to translate'));
@@ -293,6 +307,7 @@ public function testLargeOptionsDataSet()
$optionsData []= "option[delete][option_{$i}=";
}
$attributeData['serialized_options'] = json_encode($optionsData);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($attributeData);
$this->dispatch('backend/catalog/product_attribute/save');
$entityTypeId = $this->_objectManager->create(
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/DeleteTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/DeleteTest.php
index 7c5d4ea48a238..7e034b8b3cb7e 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/DeleteTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/DeleteTest.php
@@ -6,6 +6,7 @@
namespace Magento\Catalog\Controller\Adminhtml\Product\Set;
use Magento\Framework\Message\MessageInterface;
+use Magento\Framework\App\Request\Http as HttpRequest;
class DeleteTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
@@ -15,7 +16,7 @@ class DeleteTest extends \Magento\TestFramework\TestCase\AbstractBackendControll
public function testDeleteById()
{
$attributeSet = $this->getAttributeSetByName('empty_attribute_set');
- $this->getRequest()->setParam('id', $attributeSet->getId());
+ $this->getRequest()->setParam('id', $attributeSet->getId())->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/catalog/product_set/delete/');
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php
index 5b711b2ea7418..8ccd426424a29 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php
@@ -9,6 +9,7 @@
use Magento\Eav\Api\Data\AttributeSetInterface;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\TestFramework\Helper\Bootstrap;
+use Magento\Framework\App\Request\Http as HttpRequest;
class SaveTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
@@ -20,6 +21,7 @@ public function testAlreadyExistsExceptionProcessingWhenGroupCodeIsDuplicated()
$attributeSet = $this->getAttributeSetByName('attribute_set_test');
$this->assertNotEmpty($attributeSet, 'Attribute set with name "attribute_set_test" is missed');
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue('data', json_encode([
'attribute_set_name' => 'attribute_set_test',
'groups' => [
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php
index 2877ef4fb3619..06bbc43e36e8d 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php
@@ -6,17 +6,20 @@
namespace Magento\Catalog\Controller\Adminhtml;
use Magento\Framework\App\Request\DataPersistorInterface;
-use Magento\Framework\Data\Form\FormKey;
use Magento\Framework\Message\Manager;
-use Magento\TestFramework\Helper\Bootstrap;
+use Magento\Framework\App\Request\Http as HttpRequest;
/**
* @magentoAppArea adminhtml
*/
class ProductTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
+ /**
+ * Test calling save with invalid product's ID.
+ */
public function testSaveActionWithDangerRequest()
{
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue(['product' => ['entity_id' => 15]]);
$this->dispatch('backend/catalog/product/save');
$this->assertSessionMessages(
@@ -27,6 +30,8 @@ public function testSaveActionWithDangerRequest()
}
/**
+ * Test saving existing product and specifying that we want redirect to new product form.
+ *
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
*/
public function testSaveActionAndNew()
@@ -34,6 +39,7 @@ public function testSaveActionAndNew()
$this->getRequest()->setPostValue(['back' => 'new']);
$repository = $this->_objectManager->create(\Magento\Catalog\Model\ProductRepository::class);
$product = $repository->get('simple');
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/catalog/product/save/id/' . $product->getEntityId());
$this->assertRedirect($this->stringStartsWith('http://localhost/index.php/backend/catalog/product/new/'));
$this->assertSessionMessages(
@@ -43,6 +49,9 @@ public function testSaveActionAndNew()
}
/**
+ * Test saving existing product and specifying that
+ * we want redirect to new product form with saved product's data applied.
+ *
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
*/
public function testSaveActionAndDuplicate()
@@ -50,6 +59,7 @@ public function testSaveActionAndDuplicate()
$this->getRequest()->setPostValue(['back' => 'duplicate']);
$repository = $this->_objectManager->create(\Magento\Catalog\Model\ProductRepository::class);
$product = $repository->get('simple');
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/catalog/product/save/id/' . $product->getEntityId());
$this->assertRedirect($this->stringStartsWith('http://localhost/index.php/backend/catalog/product/edit/'));
$this->assertRedirect(
@@ -69,6 +79,9 @@ public function testSaveActionAndDuplicate()
);
}
+ /**
+ * Testing Add Product button showing.
+ */
public function testIndexAction()
{
$this->dispatch('backend/catalog/product');
@@ -109,6 +122,8 @@ public function testIndexAction()
}
/**
+ * Testing existing product edit page.
+ *
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
*/
public function testEditAction()
@@ -159,11 +174,13 @@ public function testEditAction()
public function testSaveActionWithAlreadyExistingUrlKey(array $postData)
{
$this->getRequest()->setPostValue($postData);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/catalog/product/save');
/** @var Manager $messageManager */
$messageManager = $this->_objectManager->get(Manager::class);
$messages = $messageManager->getMessages();
$errors = $messages->getItemsByType('error');
+ $this->assertNotEmpty($errors);
$message = array_shift($errors);
$this->assertSame('URL key for specified store already exists.', $message->getText());
$this->assertRedirect($this->stringContains('/backend/catalog/product/new'));
@@ -231,7 +248,6 @@ public function saveActionWithAlreadyExistingUrlKeyDataProvider()
'thumbnail' => '/m/a//magento_image.jpg.tmp',
'swatch_image' => '/m/a//magento_image.jpg.tmp',
],
- 'form_key' => Bootstrap::getObjectManager()->get(FormKey::class)->getFormKey(),
]
]
];
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php
index ec2e97f942451..1cb2caace4fa1 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php
@@ -7,6 +7,7 @@
namespace Magento\Catalog\Controller\Product;
use Magento\Framework\Message\MessageInterface;
+use Magento\Framework\App\Request\Http as HttpRequest;
/**
* @magentoDataFixture Magento/Catalog/controllers/_files/products.php
@@ -23,7 +24,7 @@ class CompareTest extends \Magento\TestFramework\TestCase\AbstractController
protected $productRepository;
/**
- * Test setup
+ * @inheritDoc
*/
protected function setUp()
{
@@ -36,6 +37,8 @@ protected function setUp()
}
/**
+ * Test adding product to compare list.
+ *
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function testAddAction()
@@ -45,6 +48,7 @@ public function testAddAction()
/** @var \Magento\Framework\Data\Form\FormKey $formKey */
$formKey = $objectManager->get(\Magento\Framework\Data\Form\FormKey::class);
$product = $this->productRepository->get('simple_product_1');
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch(
sprintf(
'catalog/product_compare/add/product/%s/form_key/%s?nocookie=1',
@@ -69,6 +73,8 @@ public function testAddAction()
}
/**
+ * Test comparing a product.
+ *
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function testIndexActionAddProducts()
@@ -83,12 +89,15 @@ public function testIndexActionAddProducts()
}
/**
+ * Test removing a product from compare list.
+ *
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function testRemoveAction()
{
$this->_requireVisitorWithTwoProducts();
$product = $this->productRepository->get('simple_product_2');
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('catalog/product_compare/remove/product/' . $product->getEntityId());
$this->assertSessionMessages(
@@ -102,12 +111,15 @@ public function testRemoveAction()
}
/**
+ * Test removing a product from compare list of a registered customer.
+ *
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function testRemoveActionWithSession()
{
$this->_requireCustomerWithTwoProducts();
$product = $this->productRepository->get('simple_product_1');
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('catalog/product_compare/remove/product/' . $product->getEntityId());
$secondProduct = $this->productRepository->get('simple_product_2');
@@ -122,7 +134,7 @@ public function testRemoveActionWithSession()
}
/**
- * testIndexActionDisplay
+ * Test getting a list of compared product.
*/
public function testIndexActionDisplay()
{
@@ -151,12 +163,13 @@ public function testIndexActionDisplay()
}
/**
- * testClearAction
+ * Test clearing a list of compared products.
*/
public function testClearAction()
{
$this->_requireVisitorWithTwoProducts();
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('catalog/product_compare/clear');
$this->assertSessionMessages(
@@ -170,12 +183,15 @@ public function testClearAction()
}
/**
+ * Test escaping a session message.
+ *
* @magentoDataFixture Magento/Catalog/_files/product_simple_xss.php
*/
public function testRemoveActionProductNameXss()
{
$this->_prepareCompareListWithProductNameXss();
$product = $this->productRepository->get('product-with-xss');
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('catalog/product_compare/remove/product/' . $product->getEntityId() . '?nocookie=1');
$this->assertSessionMessages(
@@ -187,6 +203,9 @@ public function testRemoveActionProductNameXss()
}
/**
+ * Preparing compare list.
+ *
+ * @throws \Magento\Framework\Exception\LocalizedException
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
protected function _prepareCompareListWithProductNameXss()
@@ -212,7 +231,9 @@ protected function _prepareCompareListWithProductNameXss()
}
/**
- * _requireVisitorWithNoProducts
+ * Preparing compare list.
+ *
+ * @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _requireVisitorWithNoProducts()
{
@@ -234,6 +255,9 @@ protected function _requireVisitorWithNoProducts()
}
/**
+ * Preparing compare list.
+ *
+ * @throws \Magento\Framework\Exception\LocalizedException
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
protected function _requireVisitorWithTwoProducts()
@@ -269,6 +293,9 @@ protected function _requireVisitorWithTwoProducts()
}
/**
+ * Preparing a compare list.
+ *
+ * @throws \Magento\Framework\Exception\LocalizedException
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
protected function _requireCustomerWithTwoProducts()
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php
index 82d39bbb7066a..c34120404a950 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php
@@ -581,8 +581,11 @@ public function testGetOptions()
'4-2-radio' => 40000.00
];
foreach ($options as $option) {
+ if (!$option->getValues()) {
+ continue;
+ }
foreach ($option->getValues() as $value) {
- $this->assertEquals($expectedValue[$value->getSku()], floatval($value->getPrice()));
+ $this->assertEquals($expectedValue[$value->getSku()], (float)$value->getPrice());
}
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_options.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_options.php
index 059b784978a22..61b549f7729d1 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_options.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_options.php
@@ -86,7 +86,18 @@
'sku' => '4-2-radio',
],
]
- ]
+ ],
+ [
+ 'previous_group' => 'text',
+ 'title' => 'Test Field',
+ 'type' => 'field',
+ 'is_require' => 1,
+ 'sort_order' => 0,
+ 'price' => 1,
+ 'price_type' => 'fixed',
+ 'sku' => '1-text',
+ 'max_characters' => 100,
+ ],
];
$options = [];
diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Controller/Cart/Index/CouponPostTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Controller/Cart/Index/CouponPostTest.php
index 07141843793e4..3e99c5cad3c39 100644
--- a/dev/tests/integration/testsuite/Magento/Checkout/Controller/Cart/Index/CouponPostTest.php
+++ b/dev/tests/integration/testsuite/Magento/Checkout/Controller/Cart/Index/CouponPostTest.php
@@ -6,6 +6,8 @@
namespace Magento\Checkout\Controller\Cart\Index;
+use Magento\Framework\App\Request\Http as HttpRequest;
+
/**
* @magentoDbIsolation enabled
*/
@@ -26,6 +28,7 @@ public function testExecute()
'remove' => 0,
'coupon_code' => 'test'
];
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($inputData);
$this->dispatch(
'checkout/cart/couponPost/'
diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Controller/CartTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Controller/CartTest.php
index 52156040b2800..fc85cc384a3db 100644
--- a/dev/tests/integration/testsuite/Magento/Checkout/Controller/CartTest.php
+++ b/dev/tests/integration/testsuite/Magento/Checkout/Controller/CartTest.php
@@ -11,13 +11,18 @@
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Checkout\Model\Session;
+use Magento\Checkout\Model\Session as CheckoutSession;
use Magento\Customer\Model\ResourceModel\CustomerRepository;
use Magento\Framework\Data\Form\FormKey;
+use Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Quote\Model\Quote;
+use Magento\Quote\Api\CartRepositoryInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\Request;
use Magento\Customer\Model\Session as CustomerSession;
use Magento\Sales\Model\ResourceModel\Order\Collection as OrderCollection;
use Magento\Sales\Model\ResourceModel\Order\Item\Collection as OrderItemCollection;
+use Magento\Framework\App\Request\Http as HttpRequest;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -25,6 +30,28 @@
*/
class CartTest extends \Magento\TestFramework\TestCase\AbstractController
{
+ /** @var CheckoutSession */
+ private $checkoutSession;
+
+ /**
+ * @inheritdoc
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+ $this->checkoutSession = $this->_objectManager->get(CheckoutSession::class);
+ $this->_objectManager->addSharedInstance($this->checkoutSession, CheckoutSession::class);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ protected function tearDown()
+ {
+ $this->_objectManager->removeSharedInstance(CheckoutSession::class);
+ parent::tearDown();
+ }
+
/**
* Test for \Magento\Checkout\Controller\Cart::configureAction() with simple product
*
@@ -32,8 +59,8 @@ class CartTest extends \Magento\TestFramework\TestCase\AbstractController
*/
public function testConfigureActionWithSimpleProduct()
{
- /** @var $session \Magento\Checkout\Model\Session */
- $session = $this->_objectManager->create(\Magento\Checkout\Model\Session::class);
+ /** @var $session CheckoutSession */
+ $session = $this->_objectManager->create(CheckoutSession::class);
/** @var ProductRepositoryInterface $productRepository */
$productRepository = $this->_objectManager->create(ProductRepositoryInterface::class);
@@ -63,19 +90,20 @@ public function testConfigureActionWithSimpleProduct()
/**
* Test for \Magento\Checkout\Controller\Cart::configureAction() with simple product and custom option
*
- * @magentoDataFixture Magento/Checkout/_files/quote_with_simple_product_and_custom_option.php
+ * @magentoDataFixture Magento/Checkout/_files/cart_with_simple_product_and_custom_options.php
*/
public function testConfigureActionWithSimpleProductAndCustomOption()
{
- /** @var $session \Magento\Checkout\Model\Session */
- $session = $this->_objectManager->create(\Magento\Checkout\Model\Session::class);
+ /** @var Quote $quote */
+ $quote = $this->getQuote('test_order_item_with_custom_options');
+ $this->checkoutSession->setQuoteId($quote->getId());
/** @var ProductRepositoryInterface $productRepository */
$productRepository = $this->_objectManager->create(ProductRepositoryInterface::class);
/** @var $product \Magento\Catalog\Model\Product */
- $product = $productRepository->get('simple');
+ $product = $productRepository->get('simple_with_custom_options');
- $quoteItem = $this->_getQuoteItemIdByProductId($session->getQuote(), $product->getId());
+ $quoteItem = $this->_getQuoteItemIdByProductId($quote, $product->getId());
$this->assertNotNull($quoteItem, 'Cannot get quote item for simple product with custom option');
$this->dispatch(
@@ -112,8 +140,8 @@ public function testConfigureActionWithSimpleProductAndCustomOption()
*/
public function testConfigureActionWithBundleProduct()
{
- /** @var $session \Magento\Checkout\Model\Session */
- $session = $this->_objectManager->create(\Magento\Checkout\Model\Session::class);
+ /** @var $session CheckoutSession */
+ $session = $this->_objectManager->create(CheckoutSession::class);
/** @var ProductRepositoryInterface $productRepository */
$productRepository = $this->_objectManager->create(ProductRepositoryInterface::class);
@@ -147,8 +175,8 @@ public function testConfigureActionWithBundleProduct()
*/
public function testConfigureActionWithDownloadableProduct()
{
- /** @var $session \Magento\Checkout\Model\Session */
- $session = $this->_objectManager->create(\Magento\Checkout\Model\Session::class);
+ /** @var $session CheckoutSession */
+ $session = $this->_objectManager->create(CheckoutSession::class);
/** @var ProductRepositoryInterface $productRepository */
$productRepository = $this->_objectManager->create(ProductRepositoryInterface::class);
@@ -201,8 +229,8 @@ public function testUpdatePostAction()
$productId = $product->getId();
$originalQuantity = 1;
$updatedQuantity = 2;
- /** @var $checkoutSession \Magento\Checkout\Model\Session */
- $checkoutSession = $this->_objectManager->create(\Magento\Checkout\Model\Session::class);
+ /** @var $checkoutSession CheckoutSession */
+ $checkoutSession = $this->_objectManager->create(CheckoutSession::class);
$quoteItem = $this->_getQuoteItemIdByProductId($checkoutSession->getQuote(), $productId);
/** @var FormKey $formKey */
@@ -212,6 +240,7 @@ public function testUpdatePostAction()
'update_cart_action' => 'update_qty',
'form_key' => $formKey->getFormKey(),
];
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($postData);
/** @var $customerSession \Magento\Customer\Model\Session */
$customerSession = $this->_objectManager->create(\Magento\Customer\Model\Session::class);
@@ -235,11 +264,32 @@ public function testUpdatePostAction()
$this->assertEquals($updatedQuantity, $quoteItem->getQty(), "Invalid quote item quantity");
}
+ /**
+ * Gets quote by reserved order id.
+ *
+ * @param string $reservedOrderId
+ * @return Quote
+ */
+ private function getQuote($reservedOrderId)
+ {
+ /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+ $searchCriteriaBuilder = $this->_objectManager->get(SearchCriteriaBuilder::class);
+ $searchCriteria = $searchCriteriaBuilder->addFilter('reserved_order_id', $reservedOrderId)
+ ->create();
+
+ /** @var CartRepositoryInterface $quoteRepository */
+ $quoteRepository = $this->_objectManager->get(CartRepositoryInterface::class);
+ $items = $quoteRepository->getList($searchCriteria)->getItems();
+
+ return array_pop($items);
+ }
+
/**
* Gets \Magento\Quote\Model\Quote\Item from \Magento\Quote\Model\Quote by product id
*
* @param \Magento\Quote\Model\Quote $quote
- * @param int $productId
+ * @param string|int $productId
+ *
* @return \Magento\Quote\Model\Quote\Item|null
*/
private function _getQuoteItemIdByProductId($quote, $productId)
@@ -274,6 +324,7 @@ public function testAddToCartSimpleProduct($area, $expectedPrice)
'isAjax' => 1
];
\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea($area);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($postData);
$quote = $this->_objectManager->create(\Magento\Checkout\Model\Cart::class);
@@ -301,6 +352,77 @@ public function addAddProductDataProvider()
];
}
+ /**
+ * Test for \Magento\Checkout\Controller\Cart\Add::execute() with simple product and activated redirect to cart
+ *
+ * @magentoDataFixture Magento/Catalog/_files/products.php
+ * @magentoConfigFixture current_store checkout/cart/redirect_to_cart 1
+ * @magentoAppIsolation enabled
+ */
+ public function testMessageAtAddToCartWithRedirect()
+ {
+ $formKey = $this->_objectManager->get(FormKey::class);
+ $postData = [
+ 'qty' => '1',
+ 'product' => '1',
+ 'custom_price' => 1,
+ 'form_key' => $formKey->getFormKey(),
+ 'isAjax' => 1
+ ];
+ \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('frontend');
+ $this->getRequest()->setPostValue($postData);
+ $this->getRequest()->setMethod('POST');
+
+ $this->dispatch('checkout/cart/add');
+
+ $this->assertEquals(
+ '{"backUrl":"http:\/\/localhost\/index.php\/checkout\/cart\/"}',
+ $this->getResponse()->getBody()
+ );
+
+ $this->assertSessionMessages(
+ $this->contains(
+ 'You added Simple Product to your shopping cart.'
+ ),
+ \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS
+ );
+ }
+
+ /**
+ * Test for \Magento\Checkout\Controller\Cart\Add::execute() with simple product and deactivated redirect to cart
+ *
+ * @magentoDataFixture Magento/Catalog/_files/products.php
+ * @magentoConfigFixture current_store checkout/cart/redirect_to_cart 0
+ * @magentoAppIsolation enabled
+ */
+ public function testMessageAtAddToCartWithoutRedirect()
+ {
+ $formKey = $this->_objectManager->get(FormKey::class);
+ $postData = [
+ 'qty' => '1',
+ 'product' => '1',
+ 'custom_price' => 1,
+ 'form_key' => $formKey->getFormKey(),
+ 'isAjax' => 1
+ ];
+ \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('frontend');
+ $this->getRequest()->setPostValue($postData);
+ $this->getRequest()->setMethod('POST');
+
+ $this->dispatch('checkout/cart/add');
+
+ $this->assertFalse($this->getResponse()->isRedirect());
+ $this->assertEquals('[]', $this->getResponse()->getBody());
+
+ $this->assertSessionMessages(
+ $this->contains(
+ "\n" . 'You added Simple Product to your ' .
+ 'shopping cart.'
+ ),
+ \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS
+ );
+ }
+
/**
* @covers \Magento\Checkout\Controller\Cart\Addgroup::execute()
*
diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/cart_with_simple_product_and_custom_options.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/cart_with_simple_product_and_custom_options.php
new file mode 100644
index 0000000000000..22367979adcab
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/cart_with_simple_product_and_custom_options.php
@@ -0,0 +1,47 @@
+create(ProductRepositoryInterface::class);
+$product = $productRepository->get('simple_with_custom_options');
+
+$options = [];
+/** @var $option Option */
+foreach ($product->getOptions() as $option) {
+ switch ($option->getGroupByType()) {
+ case ProductCustomOptionInterface::OPTION_GROUP_SELECT:
+ $value = key($option->getValues());
+ break;
+ default:
+ $value = 'test';
+ break;
+ }
+ $options[$option->getId()] = $value;
+}
+
+$requestInfo = new DataObject(['qty' => 1, 'options' => $options]);
+
+/** @var $cart \Magento\Checkout\Model\Cart */
+$quote = Bootstrap::getObjectManager()->create(Quote::class);
+$quote->setReservedOrderId('test_order_item_with_custom_options');
+$quote->addProduct($product, $requestInfo);
+$quote->save();
+
+/** @var $objectManager \Magento\TestFramework\ObjectManager */
+$objectManager = Bootstrap::getObjectManager();
+$objectManager->removeSharedInstance(Session::class);
diff --git a/dev/tests/integration/testsuite/Magento/Config/Controller/Adminhtml/System/ConfigTest.php b/dev/tests/integration/testsuite/Magento/Config/Controller/Adminhtml/System/ConfigTest.php
index 2ad15fbea6c40..24b68e804cd57 100644
--- a/dev/tests/integration/testsuite/Magento/Config/Controller/Adminhtml/System/ConfigTest.php
+++ b/dev/tests/integration/testsuite/Magento/Config/Controller/Adminhtml/System/ConfigTest.php
@@ -7,12 +7,16 @@
namespace Magento\Config\Controller\Adminhtml\System;
use Magento\TestFramework\Helper\Bootstrap;
+use Magento\Framework\App\Request\Http as HttpRequest;
/**
* @magentoAppArea adminhtml
*/
class ConfigTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
+ /**
+ * Test Configuration page existing.
+ */
public function testEditAction()
{
$this->dispatch('backend/admin/system_config/edit');
@@ -20,6 +24,8 @@ public function testEditAction()
}
/**
+ * Test redirect after changing base URL.
+ *
* @magentoAppIsolation enabled
* @magentoDbIsolation enabled
*/
@@ -43,6 +49,8 @@ public function testChangeBaseUrl()
)->setParam(
'section',
'web'
+ )->setMethod(
+ HttpRequest::METHOD_POST
);
$this->dispatch('backend/admin/system_config/save');
@@ -60,7 +68,9 @@ public function testChangeBaseUrl()
}
/**
- * Reset test framework default base url
+ * Reset test framework default base url.
+ *
+ * @param string $defaultHost
*/
protected function resetBaseUrl($defaultHost)
{
diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/ProductTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/ProductTest.php
index 4254a6ce9c71d..b71507ae43f9f 100644
--- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/Adminhtml/ProductTest.php
@@ -9,6 +9,7 @@
use Magento\Framework\Registry;
use Magento\TestFramework\ObjectManager;
use Magento\Catalog\Api\ProductRepositoryInterface;
+use Magento\Framework\App\Request\Http as HttpRequest;
/**
* @magentoAppArea adminhtml
@@ -23,6 +24,7 @@ public function testSaveActionAssociatedProductIds()
{
$associatedProductIds = ['3', '14', '15', '92'];
$associatedProductIdsJSON = json_encode($associatedProductIds);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue(
[
'id' => 1,
diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/CartTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/CartTest.php
index 4e0b74ba0f901..0d93d3ad4f4ae 100644
--- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/CartTest.php
+++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Controller/CartTest.php
@@ -9,6 +9,8 @@
*/
namespace Magento\ConfigurableProduct\Controller;
+use Magento\Framework\App\Request\Http as HttpRequest;
+
class CartTest extends \Magento\TestFramework\TestCase\AbstractController
{
/**
@@ -85,6 +87,7 @@ public function testExecuteForConfigurableLastOption()
'remove' => 0,
'coupon_code' => 'test'
];
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($inputData);
$this->dispatch(
'checkout/cart/couponPost/'
diff --git a/dev/tests/integration/testsuite/Magento/Contact/Controller/IndexTest.php b/dev/tests/integration/testsuite/Magento/Contact/Controller/IndexTest.php
index 2f89cb72b0cd9..c1255ae9b1aad 100644
--- a/dev/tests/integration/testsuite/Magento/Contact/Controller/IndexTest.php
+++ b/dev/tests/integration/testsuite/Magento/Contact/Controller/IndexTest.php
@@ -6,7 +6,7 @@
namespace Magento\Contact\Controller;
-use Zend\Http\Request;
+use Magento\Framework\App\Request\Http as HttpRequest;
/**
* Contact index controller test
@@ -14,7 +14,7 @@
class IndexTest extends \Magento\TestFramework\TestCase\AbstractController
{
/**
- * testPostAction
+ * Test contacting.
*/
public function testPostAction()
{
@@ -24,8 +24,7 @@ public function testPostAction()
'email' => 'user@example.com',
'hideit' => '',
];
- $this->getRequest()->setPostValue($params);
- $this->getRequest()->setMethod(Request::METHOD_POST);
+ $this->getRequest()->setPostValue($params)->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('contact/index/post');
$this->assertRedirect($this->stringContains('contact/index'));
@@ -38,14 +37,16 @@ public function testPostAction()
}
/**
+ * Test validation.
+ *
+ * @param array $params For Request.
+ * @param string $expectedMessage Expected response.
+ *
* @dataProvider dataInvalidPostAction
- * @param array $params
- * @param string $expectedMessage
*/
public function testInvalidPostAction($params, $expectedMessage)
{
- $this->getRequest()->setPostValue($params);
- $this->getRequest()->setMethod(Request::METHOD_POST);
+ $this->getRequest()->setPostValue($params)->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('contact/index/post');
$this->assertRedirect($this->stringContains('contact/index'));
diff --git a/dev/tests/integration/testsuite/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/SaveRatesTest.php b/dev/tests/integration/testsuite/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/SaveRatesTest.php
index c9f2ffad67644..fefd1a7b250c3 100644
--- a/dev/tests/integration/testsuite/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/SaveRatesTest.php
+++ b/dev/tests/integration/testsuite/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/SaveRatesTest.php
@@ -5,6 +5,8 @@
*/
namespace Magento\CurrencySymbol\Controller\Adminhtml\System\Currency;
+use Magento\Framework\App\Request\Http as HttpRequest;
+
class SaveRatesTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
@@ -43,6 +45,7 @@ public function testSaveAction()
$rate = 1.0000;
$request = $this->getRequest();
+ $request->setMethod(HttpRequest::METHOD_POST);
$request->setPostValue(
'rate',
[
@@ -75,6 +78,7 @@ public function testSaveWithWarningAction()
$rate = '0';
$request = $this->getRequest();
+ $request->setMethod(HttpRequest::METHOD_POST);
$request->setPostValue(
'rate',
[
diff --git a/dev/tests/integration/testsuite/Magento/CurrencySymbol/Controller/Adminhtml/System/Currencysymbol/SaveTest.php b/dev/tests/integration/testsuite/Magento/CurrencySymbol/Controller/Adminhtml/System/Currencysymbol/SaveTest.php
index 5217c3576a51d..2929f137be89f 100644
--- a/dev/tests/integration/testsuite/Magento/CurrencySymbol/Controller/Adminhtml/System/Currencysymbol/SaveTest.php
+++ b/dev/tests/integration/testsuite/Magento/CurrencySymbol/Controller/Adminhtml/System/Currencysymbol/SaveTest.php
@@ -5,10 +5,16 @@
*/
namespace Magento\CurrencySymbol\Controller\Adminhtml\System\Currencysymbol;
+use Magento\Framework\App\Request\Http as HttpRequest;
+
class SaveTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
/**
- * Test save action
+ * Test save action.
+ *
+ * @param string $currencyCode
+ * @param string $inputCurrencySymbol
+ * @param string $outputCurrencySymbol
*
* @magentoConfigFixture currency/options/allow USD
* @magentoDbIsolation enabled
@@ -31,6 +37,7 @@ public function testSaveAction($currencyCode, $inputCurrencySymbol, $outputCurre
$currencyCode => $inputCurrencySymbol,
]
);
+ $request->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/admin/system_currencysymbol/save');
$this->assertRedirect();
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
index 186d9c8f87dc2..921fa81fa6f23 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
@@ -22,6 +22,7 @@
use Magento\TestFramework\Request;
use Magento\TestFramework\Response;
use Zend\Stdlib\Parameters;
+use Magento\Framework\App\Request\Http as HttpRequest;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -56,7 +57,7 @@ public function testIndexAction()
}
/**
- * @return void
+ * Test sign up form displaying.
*/
public function testCreateAction()
{
@@ -97,10 +98,8 @@ public function testForgotPasswordEmailMessageWithSpecialCharacters()
{
$email = 'customer@example.com';
- $this->getRequest()
- ->setPostValue([
- 'email' => $email,
- ]);
+ $this->getRequest()->setPostValue(['email' => $email]);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('customer/account/forgotPasswordPost');
$this->assertRedirect($this->stringContains('customer/account/'));
@@ -377,10 +376,8 @@ public function testForgotPasswordPostAction()
{
$email = 'customer@example.com';
- $this->getRequest()
- ->setPostValue([
- 'email' => $email,
- ]);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+ $this->getRequest()->setPostValue(['email' => $email]);
$this->dispatch('customer/account/forgotPasswordPost');
$this->assertRedirect($this->stringContains('customer/account/'));
@@ -400,6 +397,7 @@ public function testForgotPasswordPostAction()
*/
public function testForgotPasswordPostWithBadEmailAction()
{
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()
->setPostValue([
'email' => 'bad@email',
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/AddressTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/AddressTest.php
index 32a622d4aa654..92e104496fed8 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Controller/AddressTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/AddressTest.php
@@ -9,6 +9,7 @@
use Magento\Customer\Model\CustomerRegistry;
use Magento\Framework\Data\Form\FormKey;
use Magento\TestFramework\Helper\Bootstrap;
+use Magento\Framework\App\Request\Http as HttpRequest;
class AddressTest extends \Magento\TestFramework\TestCase\AbstractController
{
@@ -19,7 +20,7 @@ class AddressTest extends \Magento\TestFramework\TestCase\AbstractController
private $formKey;
/**
- * {@inheritDoc}
+ * @inheritDoc
*/
protected function setUp()
{
@@ -168,7 +169,7 @@ public function testFailedFormPostAction()
public function testDeleteAction()
{
$this->getRequest()->setParam('id', 1);
- $this->getRequest()->setParam('form_key', $this->formKey->getFormKey());
+ $this->getRequest()->setParam('form_key', $this->formKey->getFormKey())->setMethod(HttpRequest::METHOD_POST);
// we are overwriting the address coming from the fixture
$this->dispatch('customer/address/delete');
@@ -186,7 +187,7 @@ public function testDeleteAction()
public function testWrongAddressDeleteAction()
{
$this->getRequest()->setParam('id', 555);
- $this->getRequest()->setParam('form_key', $this->formKey->getFormKey());
+ $this->getRequest()->setParam('form_key', $this->formKey->getFormKey())->setMethod(HttpRequest::METHOD_POST);
// we are overwriting the address coming from the fixture
$this->dispatch('customer/address/delete');
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/GroupTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/GroupTest.php
index 80b11a920e3fb..db1cc4995e676 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/GroupTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/GroupTest.php
@@ -7,6 +7,7 @@
use Magento\Framework\Message\MessageInterface;
use Magento\TestFramework\Helper\Bootstrap;
+use Magento\Framework\App\Request\Http as HttpRequest;
/**
* @magentoAppArea adminhtml
@@ -25,6 +26,11 @@ class GroupTest extends \Magento\TestFramework\TestCase\AbstractBackendControlle
/** @var \Magento\Customer\Api\GroupRepositoryInterface */
private $groupRepository;
+ /**
+ * @inheritDoc
+ *
+ * @throws \Magento\Framework\Exception\AuthenticationException
+ */
public function setUp()
{
parent::setUp();
@@ -33,12 +39,18 @@ public function setUp()
$this->groupRepository = $objectManager->get(\Magento\Customer\Api\GroupRepositoryInterface::class);
}
+ /**
+ * @inheritDoc
+ */
public function tearDown()
{
parent::tearDown();
//$this->session->unsCustomerGroupData();
}
+ /**
+ * Test new group form.
+ */
public function testNewActionNoCustomerGroupDataInSession()
{
$this->dispatch('backend/customer/group/new');
@@ -49,6 +61,9 @@ public function testNewActionNoCustomerGroupDataInSession()
$this->assertContains($expected, $responseBody);
}
+ /**
+ * Test form filling with data in session.
+ */
public function testNewActionWithCustomerGroupDataInSession()
{
/** @var \Magento\Customer\Api\Data\GroupInterfaceFactory $customerGroupFactory */
@@ -76,21 +91,27 @@ public function testNewActionWithCustomerGroupDataInSession()
}
/**
+ * Test calling delete without an ID.
+ *
* @magentoDataFixture Magento/Customer/_files/customer_group.php
*/
public function testDeleteActionNoGroupId()
{
+ $this->getRequest()->setMethod(\Magento\Framework\App\Request\Http::METHOD_POST);
$this->dispatch('backend/customer/group/delete');
$this->assertRedirect($this->stringStartsWith(self::BASE_CONTROLLER_URL));
}
/**
+ * Test deleting a group.
+ *
* @magentoDataFixture Magento/Customer/_files/customer_group.php
*/
public function testDeleteActionExistingGroup()
{
$groupId = $this->findGroupIdWithCode(self::CUSTOMER_GROUP_CODE);
$this->getRequest()->setParam('id', $groupId);
+ $this->getRequest()->setMethod(\Magento\Framework\App\Request\Http::METHOD_POST);
$this->dispatch('backend/customer/group/delete');
/**
@@ -104,11 +125,14 @@ public function testDeleteActionExistingGroup()
}
/**
+ * Tet deleting with wrong ID.
+ *
* @magentoDataFixture Magento/Customer/_files/customer_group.php
*/
public function testDeleteActionNonExistingGroupId()
{
$this->getRequest()->setParam('id', 10000);
+ $this->getRequest()->setMethod(\Magento\Framework\App\Request\Http::METHOD_POST);
$this->dispatch('backend/customer/group/delete');
/**
@@ -122,6 +146,8 @@ public function testDeleteActionNonExistingGroupId()
}
/**
+ * Test saving a valid group.
+ *
* @magentoDataFixture Magento/Customer/_files/customer_group.php
*/
public function testSaveActionExistingGroup()
@@ -130,6 +156,7 @@ public function testSaveActionExistingGroup()
$this->getRequest()->setParam('tax_class', self::TAX_CLASS_ID);
$this->getRequest()->setParam('id', $groupId);
$this->getRequest()->setParam('code', self::CUSTOMER_GROUP_CODE);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/group/save');
@@ -161,9 +188,13 @@ public function testSaveActionExistingGroup()
);
}
+ /**
+ * Test saving an invalid group.
+ */
public function testSaveActionCreateNewGroupWithoutCode()
{
$this->getRequest()->setParam('tax_class', self::TAX_CLASS_ID);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/group/save');
@@ -173,19 +204,26 @@ public function testSaveActionCreateNewGroupWithoutCode()
);
}
+ /**
+ * Test saving an empty group.
+ */
public function testSaveActionForwardNewCreateNewGroup()
{
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/group/save');
$responseBody = $this->getResponse()->getBody();
$this->assertRegExp('/\s*New Customer Group\s*<\/h1>/', $responseBody);
}
/**
+ * Test saving an existing group.
+ *
* @magentoDataFixture Magento/Customer/_files/customer_group.php
*/
public function testSaveActionForwardNewEditExistingGroup()
{
$groupId = $this->findGroupIdWithCode(self::CUSTOMER_GROUP_CODE);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setParam('id', $groupId);
$this->dispatch('backend/customer/group/save');
@@ -193,10 +231,14 @@ public function testSaveActionForwardNewEditExistingGroup()
$this->assertRegExp('/\s*' . self::CUSTOMER_GROUP_CODE . '\s*<\/h1>/', $responseBody);
}
+ /**
+ * Test using an invalid ID.
+ */
public function testSaveActionNonExistingGroupId()
{
$this->getRequest()->setParam('id', 10000);
$this->getRequest()->setParam('tax_class', self::TAX_CLASS_ID);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/group/save');
@@ -211,6 +253,8 @@ public function testSaveActionNonExistingGroupId()
}
/**
+ * Test using existing code.
+ *
* @magentoDataFixture Magento/Customer/_files/customer_group.php
*/
public function testSaveActionNewGroupWithExistingGroupCode()
@@ -220,6 +264,7 @@ public function testSaveActionNewGroupWithExistingGroupCode()
$this->getRequest()->setParam('tax_class', self::TAX_CLASS_ID);
$this->getRequest()->setParam('code', self::CUSTOMER_GROUP_CODE);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/group/save');
@@ -232,6 +277,8 @@ public function testSaveActionNewGroupWithExistingGroupCode()
}
/**
+ * Test saving an invalid group.
+ *
* @magentoDataFixture Magento/Customer/_files/customer_group.php
*/
public function testSaveActionNewGroupWithoutGroupCode()
@@ -240,6 +287,7 @@ public function testSaveActionNewGroupWithoutGroupCode()
$originalCode = $this->groupRepository->getById($groupId)->getCode();
$this->getRequest()->setParam('tax_class', self::TAX_CLASS_ID);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/group/save');
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassAssignGroupTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassAssignGroupTest.php
index 8ee12fa1aa8d5..761064ed61fcf 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassAssignGroupTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassAssignGroupTest.php
@@ -9,6 +9,7 @@
use Magento\Backend\Model\Session;
use Magento\Customer\Api\CustomerRepositoryInterface;
+use Magento\Framework\App\Request\Http as HttpRequest;
use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Framework\Message\MessageInterface;
use Magento\TestFramework\Helper\Bootstrap;
@@ -31,12 +32,20 @@ class MassAssignGroupTest extends AbstractBackendController
*/
protected $customerRepository;
+ /**
+ * @inheritDoc
+ *
+ * @throws \Magento\Framework\Exception\AuthenticationException
+ */
protected function setUp()
{
parent::setUp();
$this->customerRepository = Bootstrap::getObjectManager()->get(CustomerRepositoryInterface::class);
}
+ /**
+ * @inheritDoc
+ */
protected function tearDown()
{
/**
@@ -69,7 +78,8 @@ public function testMassAssignGroupAction()
'selected' => [$customer->getId()]
];
- $this->getRequest()->setParams($params);
+ $this->getRequest()->setParams($params)
+ ->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/index/massAssignGroup');
$this->assertSessionMessages(
self::equalTo(['A total of 1 record(s) were updated.']),
@@ -103,7 +113,8 @@ public function testLargeGroupMassAssignGroupAction()
'selected' => $ids,
];
- $this->getRequest()->setParams($params);
+ $this->getRequest()->setParams($params)
+ ->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/index/massAssignGroup');
$this->assertSessionMessages(
self::equalTo(['A total of 5 record(s) were updated.']),
@@ -124,11 +135,9 @@ public function testLargeGroupMassAssignGroupAction()
*/
public function testMassAssignGroupActionNoCustomerIds()
{
- $params = [
- 'group' => 0,
- 'namespace' => 'customer_listing',
+ $params = ['group'=> 0,'namespace'=> 'customer_listing',
];
- $this->getRequest()->setParams($params);
+ $this->getRequest()->setParams($params)->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/index/massAssignGroup');
$this->assertSessionMessages(
$this->equalTo(['An item needs to be selected. Select and try again.']),
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassDeleteTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassDeleteTest.php
index 940f7c84325f6..eea94bb3f9867 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassDeleteTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/MassDeleteTest.php
@@ -13,6 +13,7 @@
use PHPUnit\Framework\Constraint\Constraint;
use Magento\Framework\Message\MessageInterface;
use Magento\TestFramework\Helper\Bootstrap;
+use Magento\Framework\App\Request\Http as HttpRequest;
use Magento\TestFramework\TestCase\AbstractBackendController;
/**
@@ -32,12 +33,20 @@ class MassDeleteTest extends AbstractBackendController
*/
private $baseControllerUrl = 'http://localhost/index.php/backend/customer/index/index';
+ /**
+ * @inheritDoc
+ *
+ * @throws \Magento\Framework\Exception\AuthenticationException
+ */
protected function setUp()
{
parent::setUp();
$this->customerRepository = Bootstrap::getObjectManager()->get(CustomerRepositoryInterface::class);
}
+ /**
+ * @inheritDoc
+ */
protected function tearDown()
{
/**
@@ -106,7 +115,7 @@ private function massDeleteAssertions($ids, Constraint $constraint, $messageType
'namespace' => 'customer_listing',
];
- $this->getRequest()->setParams($requestData);
+ $this->getRequest()->setParams($requestData)->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/index/massDelete');
$this->assertSessionMessages(
$constraint,
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/ResetPasswordTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/ResetPasswordTest.php
index b5ca783d68cf2..eaaba639d49a8 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/ResetPasswordTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index/ResetPasswordTest.php
@@ -5,6 +5,8 @@
*/
namespace Magento\Customer\Controller\Adminhtml\Index;
+use Magento\Framework\App\Request\Http as HttpRequest;
+
/**
* ResetPassword controller test.
*
@@ -32,7 +34,7 @@ public function testResetPasswordSuccess()
$this->passwordResetRequestEventCreate(
\Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST
);
- $this->getRequest()->setPostValue(['customer_id' => '1']);
+ $this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/index/resetPassword');
$this->assertSessionMessages(
$this->equalTo(['The customer will receive an email with a link to reset password.']),
@@ -55,7 +57,7 @@ public function testResetPasswordMinTimeError()
$this->passwordResetRequestEventCreate(
\Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST
);
- $this->getRequest()->setPostValue(['customer_id' => '1']);
+ $this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/index/resetPassword');
$this->assertSessionMessages(
$this->equalTo(['The customer will receive an email with a link to reset password.']),
@@ -78,7 +80,7 @@ public function testResetPasswordLimitError()
$this->passwordResetRequestEventCreate(
\Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST
);
- $this->getRequest()->setPostValue(['customer_id' => '1']);
+ $this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/index/resetPassword');
$this->assertSessionMessages(
$this->equalTo(['The customer will receive an email with a link to reset password.']),
@@ -103,7 +105,7 @@ public function testResetPasswordWithSecurityViolationException()
$this->passwordResetRequestEventCreate(
\Magento\Security\Model\PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST
);
- $this->getRequest()->setPostValue(['customer_id' => '1']);
+ $this->getRequest()->setPostValue(['customer_id' => '1'])->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/index/resetPassword');
$this->assertSessionMessages(
$this->equalTo(['The customer will receive an email with a link to reset password.']),
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php
index 6448816c9345c..4262967aa8d1a 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/IndexTest.php
@@ -12,6 +12,7 @@
use Magento\Customer\Controller\RegistryConstants;
use Magento\Customer\Model\EmailNotification;
use Magento\TestFramework\Helper\Bootstrap;
+use Magento\Framework\App\Request\Http as HttpRequest;
/**
* @magentoAppArea adminhtml
@@ -45,7 +46,7 @@ class IndexTest extends \Magento\TestFramework\TestCase\AbstractBackendControlle
protected $objectManager;
/**
- * {@inheritDoc}
+ * @inheritDoc
*/
protected function setUp()
{
@@ -71,7 +72,7 @@ protected function setUp()
}
/**
- * {@inheritDoc}
+ * @inheritDoc
*/
protected function tearDown()
{
@@ -91,7 +92,7 @@ protected function tearDown()
*/
public function testSaveActionWithEmptyPostData()
{
- $this->getRequest()->setPostValue([]);
+ $this->getRequest()->setPostValue([])->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/index/save');
$this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl));
}
@@ -102,7 +103,7 @@ public function testSaveActionWithEmptyPostData()
public function testSaveActionWithInvalidFormData()
{
$post = ['account' => ['middlename' => 'test middlename', 'group_id' => 1]];
- $this->getRequest()->setPostValue($post);
+ $this->getRequest()->setPostValue($post)->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/index/save');
/**
* Check that errors was generated and set to session
@@ -111,13 +112,13 @@ public function testSaveActionWithInvalidFormData()
$this->logicalNot($this->isEmpty()),
\Magento\Framework\Message\MessageInterface::TYPE_ERROR
);
+ /** @var \Magento\Backend\Model\Session $session */
+ $session = $this->objectManager->get(\Magento\Backend\Model\Session::class);
/**
* Check that customer data were set to session
*/
- $this->assertEquals(
- $post,
- $this->objectManager->get(\Magento\Backend\Model\Session::class)->getCustomerFormData()
- );
+ $this->assertNotEmpty($session->getCustomerFormData());
+ $this->assertArraySubset($post, $session->getCustomerFormData());
$this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl . 'new'));
}
@@ -138,7 +139,7 @@ public function testSaveActionWithInvalidCustomerAddressData()
],
'address' => ['_item1' => []],
];
- $this->getRequest()->setPostValue($post);
+ $this->getRequest()->setPostValue($post)->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/index/save');
/**
* Check that errors was generated and set to session
@@ -150,7 +151,7 @@ public function testSaveActionWithInvalidCustomerAddressData()
/**
* Check that customer data were set to session
*/
- $this->assertEquals(
+ $this->assertArraySubset(
$post,
$this->objectManager->get(\Magento\Backend\Model\Session::class)->getCustomerFormData()
);
@@ -187,7 +188,7 @@ public function testSaveActionWithValidCustomerDataAndValidAddressData()
],
],
];
- $this->getRequest()->setPostValue($post);
+ $this->getRequest()->setPostValue($post)->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setParam('back', '1');
// Emulate setting customer data to session in editAction
@@ -299,7 +300,7 @@ public function testSaveActionExistingCustomerAndExistingAddressData()
],
'subscription' => '',
];
- $this->getRequest()->setPostValue($post);
+ $this->getRequest()->setPostValue($post)->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setParam('id', 1);
$this->dispatch('backend/customer/index/save');
@@ -365,7 +366,7 @@ public function testSaveActionExistingCustomerUnsubscribeNewsletter()
],
'subscription' => '0'
];
- $this->getRequest()->setPostValue($post);
+ $this->getRequest()->setPostValue($post)->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setParam('id', 1);
$this->dispatch('backend/customer/index/save');
@@ -426,7 +427,7 @@ public function testSaveActionExistingCustomerChangeEmail()
'default_billing' => 1,
]
];
- $this->getRequest()->setPostValue($post);
+ $this->getRequest()->setPostValue($post)->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setParam('id', 1);
$this->dispatch('backend/customer/index/save');
@@ -473,7 +474,7 @@ public function testInlineEditChangeEmail()
]
];
$this->getRequest()->setParam('ajax', true)->setParam('isAjax', true);
- $this->getRequest()->setPostValue($post);
+ $this->getRequest()->setPostValue($post)->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setParam('id', 1);
$this->dispatch('backend/customer/index/inlineEdit');
@@ -499,7 +500,7 @@ public function testSaveActionCoreException()
'password' => 'password',
],
];
- $this->getRequest()->setPostValue($post);
+ $this->getRequest()->setPostValue($post)->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/index/save');
/*
* Check that error message is set
@@ -508,7 +509,7 @@ public function testSaveActionCoreException()
$this->equalTo(['A customer with the same email address already exists in an associated website.']),
\Magento\Framework\Message\MessageInterface::TYPE_ERROR
);
- $this->assertEquals(
+ $this->assertArraySubset(
$post,
Bootstrap::getObjectManager()->get(\Magento\Backend\Model\Session::class)->getCustomerFormData()
);
@@ -529,9 +530,9 @@ public function testEditAction()
}
/**
- * Tests new action
+ * Test new customer form page.
*/
- public function testNewAction(): void
+ public function testNewAction()
{
$this->dispatch('backend/customer/index/edit');
$body = $this->getResponse()->getBody();
@@ -666,7 +667,7 @@ public function testValidateCustomerWithAddressSuccess()
/**
* set customer data
*/
- $this->getRequest()->setParams($customerData);
+ $this->getRequest()->setParams($customerData)->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/index/validate');
$body = $this->getResponse()->getBody();
@@ -720,7 +721,7 @@ public function testValidateCustomerWithAddressFailure()
/**
* set customer data
*/
- $this->getRequest()->setPostValue($customerData);
+ $this->getRequest()->setPostValue($customerData)->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/index/validate');
$body = $this->getResponse()->getBody();
@@ -737,6 +738,7 @@ public function testValidateCustomerWithAddressFailure()
public function testResetPasswordActionNoCustomerId()
{
// No customer ID in post, will just get redirected to base
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/index/resetPassword');
$this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl));
}
@@ -747,6 +749,7 @@ public function testResetPasswordActionNoCustomerId()
public function testResetPasswordActionBadCustomerId()
{
// Bad customer ID in post, will just get redirected to base
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue(['customer_id' => '789']);
$this->dispatch('backend/customer/index/resetPassword');
$this->assertRedirect($this->stringStartsWith($this->_baseControllerUrl));
@@ -758,6 +761,7 @@ public function testResetPasswordActionBadCustomerId()
public function testResetPasswordActionSuccess()
{
$this->getRequest()->setPostValue(['customer_id' => '1']);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/customer/index/resetPassword');
$this->assertSessionMessages(
$this->equalTo(['The customer will receive an email with a link to reset password.']),
diff --git a/dev/tests/integration/testsuite/Magento/Eav/Model/Entity/Attribute/Frontend/DefaultFrontendTest.php b/dev/tests/integration/testsuite/Magento/Eav/Model/Entity/Attribute/Frontend/DefaultFrontendTest.php
index 5e8239586d76b..9961101dac7cb 100644
--- a/dev/tests/integration/testsuite/Magento/Eav/Model/Entity/Attribute/Frontend/DefaultFrontendTest.php
+++ b/dev/tests/integration/testsuite/Magento/Eav/Model/Entity/Attribute/Frontend/DefaultFrontendTest.php
@@ -9,7 +9,7 @@
use Magento\TestFramework\Helper\CacheCleaner;
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
use Magento\Framework\App\CacheInterface;
-use Magento\Store\Api\StoreResolverInterface;
+use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\Serialize\Serializer\Json as Serializer;
use Magento\Eav\Model\Entity\Attribute;
@@ -44,9 +44,9 @@ class DefaultFrontendTest extends \PHPUnit\Framework\TestCase
private $cache;
/**
- * @var StoreResolverInterface
+ * @var StoreManagerInterface
*/
- private $storeResolver;
+ private $storeManager;
/**
* @var Serializer
@@ -60,7 +60,7 @@ protected function setUp()
$this->defaultFrontend = $this->objectManager->get(DefaultFrontend::class);
$this->cache = $this->objectManager->get(CacheInterface::class);
- $this->storeResolver = $this->objectManager->get(StoreResolverInterface::class);
+ $this->storeManager = $this->objectManager->get(StoreManagerInterface::class);
$this->serializer = $this->objectManager->get(Serializer::class);
$this->attribute = $this->objectManager->get(Attribute::class);
@@ -99,6 +99,6 @@ private function getCacheKey()
{
return 'attribute-navigation-option-' .
$this->defaultFrontend->getAttribute()->getAttributeCode() . '-' .
- $this->storeResolver->getCurrentStoreId();
+ $this->storeManager->getStore()->getId();
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Elasticsearch/Controller/Adminhtml/Category/SaveTest.php b/dev/tests/integration/testsuite/Magento/Elasticsearch/Controller/Adminhtml/Category/SaveTest.php
index b37392fff7609..fcd8226aec50c 100644
--- a/dev/tests/integration/testsuite/Magento/Elasticsearch/Controller/Adminhtml/Category/SaveTest.php
+++ b/dev/tests/integration/testsuite/Magento/Elasticsearch/Controller/Adminhtml/Category/SaveTest.php
@@ -80,6 +80,7 @@ public function testExecute()
];
$this->getRequest()->setPostValue($inputData);
+ $this->getRequest()->setMethod('POST');
$this->dispatch('backend/catalog/category/save');
$this->assertSessionMessages(
self::equalTo(['You saved the category.']),
diff --git a/dev/tests/integration/testsuite/Magento/Framework/App/FrontControllerTest.php b/dev/tests/integration/testsuite/Magento/Framework/App/FrontControllerTest.php
index 431c705430819..89240f4ab3241 100644
--- a/dev/tests/integration/testsuite/Magento/Framework/App/FrontControllerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Framework/App/FrontControllerTest.php
@@ -5,11 +5,21 @@
*/
namespace Magento\Framework\App;
+use Magento\Framework\App\Request\InvalidRequestException;
+use Magento\Framework\App\Request\ValidatorInterface;
+use Magento\Framework\Exception\NotFoundException;
+use Magento\Framework\Phrase;
+use PHPUnit\Framework\TestCase;
+use Magento\Framework\App\Request\Http as HttpRequest;
+use Magento\Framework\Controller\ResultInterface;
+use Magento\TestFramework\Helper\Bootstrap;
+
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @magentoAppArea frontend
*/
-class FrontControllerTest extends \PHPUnit\Framework\TestCase
+class FrontControllerTest extends TestCase
{
/**
* @var \Magento\Framework\ObjectManagerInterface
@@ -17,28 +27,94 @@ class FrontControllerTest extends \PHPUnit\Framework\TestCase
protected $_objectManager;
/**
- * @var \Magento\Framework\App\FrontController
+ * @var FrontController
*/
protected $_model;
+ /**
+ * @var ValidatorInterface
+ */
+ private $fakeRequestValidator;
+
+ /**
+ * @return ValidatorInterface
+ *
+ * @SuppressWarnings(PHPMD.UnusedLocalVariable)
+ */
+ private function createRequestValidator(): ValidatorInterface
+ {
+ if (!$this->fakeRequestValidator) {
+ $this->fakeRequestValidator = new class implements ValidatorInterface {
+ /**
+ * @var bool
+ */
+ public $valid;
+
+ /**
+ * @inheritDoc
+ */
+ public function validate(
+ RequestInterface $request,
+ ActionInterface $action
+ ): void {
+ if (!$this->valid) {
+ throw new InvalidRequestException(new NotFoundException(new Phrase('Not found')));
+ }
+ }
+ };
+ }
+
+ return $this->fakeRequestValidator;
+ }
+
+ /**
+ * @inheritDoc
+ */
protected function setUp()
{
- $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
- $this->_model = $this->_objectManager->create(\Magento\Framework\App\FrontController::class);
+ $this->_objectManager = Bootstrap::getObjectManager();
+ $this->_model = $this->_objectManager->create(
+ FrontController::class,
+ ['requestValidator' => $this->createRequestValidator()]
+ );
}
+ /**
+ * Test dispatching an empty action.
+ */
public function testDispatch()
{
- if (!\Magento\TestFramework\Helper\Bootstrap::canTestHeaders()) {
+ if (!Bootstrap::canTestHeaders()) {
+ $this->markTestSkipped('Can\'t test dispatch process without sending headers');
+ }
+ $this->fakeRequestValidator->valid = true;
+ $_SERVER['HTTP_HOST'] = 'localhost';
+ $this->_objectManager->get(State::class)->setAreaCode('frontend');
+ $request = $this->_objectManager->get(HttpRequest::class);
+ /* empty action */
+ $request->setRequestUri('core/index/index');
+ $this->assertInstanceOf(
+ ResultInterface::class,
+ $this->_model->dispatch($request)
+ );
+ }
+
+ /**
+ * Test request validator invalidating given request.
+ */
+ public function testInvalidRequest()
+ {
+ if (!Bootstrap::canTestHeaders()) {
$this->markTestSkipped('Can\'t test dispatch process without sending headers');
}
+ $this->fakeRequestValidator->valid = false;
$_SERVER['HTTP_HOST'] = 'localhost';
- $this->_objectManager->get(\Magento\Framework\App\State::class)->setAreaCode('frontend');
- $request = $this->_objectManager->get(\Magento\Framework\App\Request\Http::class);
+ $this->_objectManager->get(State::class)->setAreaCode('frontend');
+ $request = $this->_objectManager->get(HttpRequest::class);
/* empty action */
$request->setRequestUri('core/index/index');
$this->assertInstanceOf(
- \Magento\Framework\Controller\ResultInterface::class,
+ ResultInterface::class,
$this->_model->dispatch($request)
);
}
diff --git a/dev/tests/integration/testsuite/Magento/Framework/App/Request/HttpMethodValidatorTest.php b/dev/tests/integration/testsuite/Magento/Framework/App/Request/HttpMethodValidatorTest.php
new file mode 100644
index 0000000000000..74aa5b8bfed05
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Framework/App/Request/HttpMethodValidatorTest.php
@@ -0,0 +1,110 @@
+validator = $objectManager->get(HttpMethodValidator::class);
+ $this->request = $objectManager->get(RequestInterface::class);
+ if (!$this->request instanceof HttpRequest) {
+ throw new \RuntimeException('We need HTTP request');
+ }
+ $this->map = $objectManager->get(HttpMethodMap::class);
+ }
+
+ /**
+ * @return array
+ */
+ private function getMap(): array
+ {
+ $map = $this->map->getMap();
+ if (count($map) < 2) {
+ throw new \RuntimeException(
+ 'We need at least 2 HTTP methods allowed'
+ );
+ }
+
+ $sorted = [];
+ foreach ($map as $method => $interface) {
+ $sorted[] = ['method' => $method, 'interface' => $interface];
+ }
+
+ return $sorted;
+ }
+
+ /**
+ * Test positive case.
+ *
+ * @throws InvalidRequestException
+ */
+ public function testAllowed()
+ {
+ $map = $this->getMap();
+
+ $action1 = $this->getMockForAbstractClass($map[0]['interface']);
+ $this->request->setMethod($map[0]['method']);
+ $this->validator->validate($this->request, $action1);
+
+ $action2 = $this->getMockForAbstractClass(ActionInterface::class);
+ $this->validator->validate($this->request, $action2);
+ }
+
+ /**
+ * Test negative case.
+ *
+ * @expectedException \Magento\Framework\App\Request\InvalidRequestException
+ */
+ public function testNotAllowedMethod()
+ {
+ $this->request->setMethod('method' .rand(0, 1000));
+ $action = $this->getMockForAbstractClass(ActionInterface::class);
+
+ $this->validator->validate($this->request, $action);
+ }
+
+ /**
+ * @expectedException \Magento\Framework\App\Request\InvalidRequestException
+ */
+ public function testRestrictedMethod()
+ {
+ $map = $this->getMap();
+
+ $this->request->setMethod($map[1]['method']);
+ $action = $this->getMockForAbstractClass($map[0]['interface']);
+
+ $this->validator->validate($this->request, $action);
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/GiftMessage/Observer/SalesEventQuoteMergeTest.php b/dev/tests/integration/testsuite/Magento/GiftMessage/Observer/SalesEventQuoteMergeTest.php
new file mode 100644
index 0000000000000..0902c35568ee3
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/GiftMessage/Observer/SalesEventQuoteMergeTest.php
@@ -0,0 +1,40 @@
+get(ManagerInterface::class);
+ /** @var Quote $sourceQuote */
+ $sourceQuote = $objectManager->create(QuoteFactory::class)->create();
+ $targetQuote = clone($sourceQuote);
+ $sourceQuote->setGiftMessageId($giftMessageId);
+
+ $eventManager->dispatch(
+ 'sales_quote_merge_after',
+ [
+ 'quote' => $targetQuote,
+ 'source' => $sourceQuote
+ ]
+ );
+
+ self::assertEquals($giftMessageId, $targetQuote->getGiftMessageId());
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php b/dev/tests/integration/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php
index 8011873577dc8..4da0c12c6087a 100644
--- a/dev/tests/integration/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php
+++ b/dev/tests/integration/testsuite/Magento/Integration/Controller/Adminhtml/IntegrationTest.php
@@ -7,6 +7,7 @@
namespace Magento\Integration\Controller\Adminhtml;
use Magento\TestFramework\Bootstrap;
+use Magento\Framework\App\Request\Http as HttpRequest;
/**
* \Magento\Integration\Controller\Adminhtml\Integration
@@ -20,6 +21,9 @@ class IntegrationTest extends \Magento\TestFramework\TestCase\AbstractBackendCon
/** @var \Magento\Integration\Model\Integration */
private $_integration;
+ /**
+ * @inheritDoc
+ */
protected function setUp()
{
parent::setUp();
@@ -29,6 +33,9 @@ protected function setUp()
$this->_integration = $integration->load('Fixture Integration', 'name');
}
+ /**
+ * Test view page.
+ */
public function testIndexAction()
{
$this->dispatch('backend/admin/integration/index');
@@ -44,6 +51,9 @@ public function testIndexAction()
);
}
+ /**
+ * Test creation form.
+ */
public function testNewAction()
{
$this->dispatch('backend/admin/integration/new');
@@ -61,6 +71,9 @@ public function testNewAction()
);
}
+ /**
+ * Test update form.
+ */
public function testEditAction()
{
$integrationId = $this->_integration->getId();
@@ -88,12 +101,16 @@ public function testEditAction()
);
}
+ /**
+ * Test saving.
+ */
public function testSaveActionUpdateIntegration()
{
$integrationId = $this->_integration->getId();
$integrationName = $this->_integration->getName();
$this->getRequest()->setParam('id', $integrationId);
$url = 'http://magento.ll/endpoint_url';
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue(
[
'name' => $integrationName,
@@ -111,10 +128,14 @@ public function testSaveActionUpdateIntegration()
$this->assertRedirect($this->stringContains('backend/admin/integration/index/'));
}
+ /**
+ * Test saving.
+ */
public function testSaveActionNewIntegration()
{
$url = 'http://magento.ll/endpoint_url';
$integrationName = md5(rand());
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue(
[
'name' => $integrationName,
diff --git a/dev/tests/integration/testsuite/Magento/NewRelicReporting/Plugin/SeparateAppsTest.php b/dev/tests/integration/testsuite/Magento/NewRelicReporting/Plugin/SeparateAppsTest.php
new file mode 100644
index 0000000000000..9271e08942279
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/NewRelicReporting/Plugin/SeparateAppsTest.php
@@ -0,0 +1,76 @@
+objectManager = Bootstrap::getObjectManager();
+ }
+
+ /**
+ * @magentoConfigFixture default/newrelicreporting/general/enable 1
+ * @magentoConfigFixture default/newrelicreporting/general/app_name beverly_hills
+ * @magentoConfigFixture default/newrelicreporting/general/separate_apps 1
+ */
+ public function testAppNameIsSetWhenConfiguredCorrectly()
+ {
+ $newRelicWrapper = $this->getMockBuilder(NewRelicWrapper::class)
+ ->setMethods(['setAppName'])
+ ->getMock();
+
+ $this->objectManager->configure([NewRelicWrapper::class => ['shared' => true]]);
+ $this->objectManager->addSharedInstance($newRelicWrapper, NewRelicWrapper::class);
+
+ $newRelicWrapper->expects($this->once())
+ ->method('setAppName')
+ ->with($this->equalTo('beverly_hills;beverly_hills_90210'));
+
+ $state = $this->objectManager->get(State::class);
+
+ $state->setAreaCode('90210');
+ }
+
+ /**
+ * @magentoConfigFixture default/newrelicreporting/general/enable 1
+ * @magentoConfigFixture default/newrelicreporting/general/app_name beverly_hills
+ * @magentoConfigFixture default/newrelicreporting/general/separate_apps 0
+ */
+ public function testAppNameIsNotSetWhenDisabled()
+ {
+ $newRelicWrapper = $this->getMockBuilder(NewRelicWrapper::class)
+ ->setMethods(['setAppName'])
+ ->getMock();
+
+ $this->objectManager->configure([NewRelicWrapper::class => ['shared' => true]]);
+ $this->objectManager->addSharedInstance($newRelicWrapper, NewRelicWrapper::class);
+
+ $newRelicWrapper->expects($this->never())->method('setAppName');
+
+ $state = $this->objectManager->get(State::class);
+
+ $state->setAreaCode('90210');
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/Controller/Adminhtml/NewsletterQueueTest.php b/dev/tests/integration/testsuite/Magento/Newsletter/Controller/Adminhtml/NewsletterQueueTest.php
index 5c1a11756c1b1..7a0ac030d120b 100644
--- a/dev/tests/integration/testsuite/Magento/Newsletter/Controller/Adminhtml/NewsletterQueueTest.php
+++ b/dev/tests/integration/testsuite/Magento/Newsletter/Controller/Adminhtml/NewsletterQueueTest.php
@@ -5,6 +5,8 @@
*/
namespace Magento\Newsletter\Controller\Adminhtml;
+use Magento\Framework\App\Request\Http as HttpRequest;
+
/**
* @magentoAppArea adminhtml
*/
@@ -15,6 +17,9 @@ class NewsletterQueueTest extends \Magento\TestFramework\TestCase\AbstractBacken
*/
protected $_model;
+ /**
+ * @inheritDoc
+ */
protected function setUp()
{
parent::setUp();
@@ -23,6 +28,9 @@ protected function setUp()
);
}
+ /**
+ * @inheritDoc
+ */
protected function tearDown()
{
/**
@@ -47,6 +55,7 @@ public function testSaveActionQueueTemplateAndVerifySuccessMessage()
'subject' => 'test subject',
'text' => 'newsletter text',
];
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($postForQueue);
// Loading by code, since ID will vary. template_code is not actually used to load anywhere else.
diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/Controller/Adminhtml/NewsletterTemplateTest.php b/dev/tests/integration/testsuite/Magento/Newsletter/Controller/Adminhtml/NewsletterTemplateTest.php
index 50e89d92e434c..ae57703f9e8e2 100644
--- a/dev/tests/integration/testsuite/Magento/Newsletter/Controller/Adminhtml/NewsletterTemplateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Newsletter/Controller/Adminhtml/NewsletterTemplateTest.php
@@ -20,6 +20,9 @@ class NewsletterTemplateTest extends \Magento\TestFramework\TestCase\AbstractBac
*/
protected $model;
+ /**
+ * @inheritDoc
+ */
protected function setUp()
{
parent::setUp();
@@ -39,6 +42,9 @@ protected function setUp()
);
}
+ /**
+ * @inheritDoc
+ */
protected function tearDown()
{
/**
@@ -138,19 +144,6 @@ public function testSaveActionTemplateWithGetAndVerifyRedirect()
$this->getRequest()->setMethod(\Zend\Http\Request::METHOD_GET)->setParam('id', $this->model->getId());
$this->dispatch('backend/newsletter/template/save');
- /**
- * Check that errors was generated and set to session
- */
- $this->assertSessionMessages($this->isEmpty(), \Magento\Framework\Message\MessageInterface::TYPE_ERROR);
-
- /**
- * Check that correct redirect performed.
- */
- $backendUrlModel = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
- \Magento\Backend\Model\UrlInterface::class
- );
- $backendUrlModel->turnOffSecretKey();
- $url = $backendUrlModel->getUrl('newsletter');
- $this->assertRedirect($this->stringStartsWith($url));
+ $this->assertEquals(404, $this->getResponse()->getStatusCode());
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php b/dev/tests/integration/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php
index bd641dab26c09..cb83fa3abd857 100644
--- a/dev/tests/integration/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php
+++ b/dev/tests/integration/testsuite/Magento/Paypal/Model/Express/CheckoutTest.php
@@ -293,6 +293,7 @@ public function testReturnFromPaypal()
/**
* The case when handling address data from Paypal button.
* System's address fields are replacing from export Paypal data.
+ * Billing and Shipping address are the same
*
* @magentoDataFixture Magento/Paypal/_files/quote_payment_express_with_customer.php
* @magentoAppIsolation enabled
@@ -307,18 +308,65 @@ public function testReturnFromPaypalButton()
$this->checkoutModel->returnFromPaypal('token');
$shippingAddress = $quote->getShippingAddress();
- $prefix = '';
+ $billingAddress = $quote->getBillingAddress();
+ $exportedShippingData = $this->getExportedData()['shipping'];
+
+ $this->assertEquals([$exportedShippingData['street']], $shippingAddress->getStreet());
+ $this->assertEquals($exportedShippingData['firstname'], $shippingAddress->getFirstname());
+ $this->assertEquals($exportedShippingData['city'], $shippingAddress->getCity());
+ $this->assertEquals($exportedShippingData['telephone'], $shippingAddress->getTelephone());
+ $this->assertEquals($exportedShippingData['email'], $shippingAddress->getEmail());
+
+ $this->assertEquals([$exportedShippingData['street']], $billingAddress->getStreet());
+ $this->assertEquals($exportedShippingData['firstname'], $billingAddress->getFirstname());
+ $this->assertEquals($exportedShippingData['city'], $billingAddress->getCity());
+ $this->assertEquals($exportedShippingData['telephone'], $billingAddress->getTelephone());
+ $this->assertEquals($exportedShippingData['email'], $billingAddress->getEmail());
+ }
+
+ /**
+ * The case when handling address data from Paypal button.
+ * System's address fields are replacing from export Paypal data.
+ * Billing and Shipping address are different
+ *
+ * @magentoDataFixture Magento/Paypal/_files/quote_payment_express_with_customer.php
+ * @magentoAppIsolation enabled
+ * @magentoDbIsolation enabled
+ */
+ public function testReturnFromPaypalButtonWithReturnBillingAddress()
+ {
+ $quote = $this->getFixtureQuote();
+ $this->paypalConfig->expects($this->exactly(2))
+ ->method('getValue')
+ ->with('requireBillingAddress')
+ ->willReturn(1);
+ $this->prepareCheckoutModel($quote);
+ $quote->getPayment()->setAdditionalInformation(Checkout::PAYMENT_INFO_BUTTON, 1);
+
+ $this->checkoutModel->returnFromPaypal('token');
- $this->assertEquals([$prefix . $this->getExportedData()['street']], $shippingAddress->getStreet());
- $this->assertEquals($prefix . $this->getExportedData()['firstname'], $shippingAddress->getFirstname());
- $this->assertEquals($prefix . $this->getExportedData()['city'], $shippingAddress->getCity());
- $this->assertEquals($prefix . $this->getExportedData()['telephone'], $shippingAddress->getTelephone());
- $this->assertEquals($prefix . $this->getExportedData()['email'], $shippingAddress->getEmail());
+ $shippingAddress = $quote->getShippingAddress();
+ $billingAddress = $quote->getBillingAddress();
+ $exportedBillingData = $this->getExportedData()['billing'];
+ $exportedShippingData = $this->getExportedData()['shipping'];
+
+ $this->assertEquals([$exportedShippingData['street']], $shippingAddress->getStreet());
+ $this->assertEquals($exportedShippingData['firstname'], $shippingAddress->getFirstname());
+ $this->assertEquals($exportedShippingData['city'], $shippingAddress->getCity());
+ $this->assertEquals($exportedShippingData['telephone'], $shippingAddress->getTelephone());
+ $this->assertEquals($exportedShippingData['email'], $shippingAddress->getEmail());
+
+ $this->assertEquals([$exportedBillingData['street']], $billingAddress->getStreet());
+ $this->assertEquals($exportedBillingData['firstname'], $billingAddress->getFirstname());
+ $this->assertEquals($exportedBillingData['city'], $billingAddress->getCity());
+ $this->assertEquals($exportedBillingData['telephone'], $billingAddress->getTelephone());
+ $this->assertEquals($exportedBillingData['email'], $billingAddress->getEmail());
}
/**
* The case when handling address data from the checkout.
* System's address fields are not replacing from export PayPal data.
+ * Billing and Shipping address are the same
*
* @magentoDataFixture Magento/Paypal/_files/quote_payment_express_with_customer.php
* @magentoAppIsolation enabled
@@ -326,20 +374,67 @@ public function testReturnFromPaypalButton()
*/
public function testReturnFromPaypalIfCheckout()
{
+ $prefix = 'exported';
$quote = $this->getFixtureQuote();
- $this->prepareCheckoutModel($quote);
+ $this->prepareCheckoutModel($quote, $prefix);
$quote->getPayment()->setAdditionalInformation(Checkout::PAYMENT_INFO_BUTTON, 0);
+ $originalShippingAddress = $quote->getShippingAddress();
+ $originalBillingAddress = $quote->getBillingAddress();
+
$this->checkoutModel->returnFromPaypal('token');
$shippingAddress = $quote->getShippingAddress();
+ $billingAddress = $quote->getBillingAddress();
+
+ $this->assertEquals($originalShippingAddress->getStreet(), $shippingAddress->getStreet());
+ $this->assertEquals($originalShippingAddress->getFirstname(), $shippingAddress->getFirstname());
+ $this->assertEquals($originalShippingAddress->getCity(), $shippingAddress->getCity());
+ $this->assertEquals($originalShippingAddress->getTelephone(), $shippingAddress->getTelephone());
+
+ $this->assertEquals($originalBillingAddress->getStreet(), $billingAddress->getStreet());
+ $this->assertEquals($originalBillingAddress->getFirstname(), $billingAddress->getFirstname());
+ $this->assertEquals($originalBillingAddress->getCity(), $billingAddress->getCity());
+ $this->assertEquals($originalBillingAddress->getTelephone(), $billingAddress->getTelephone());
+ }
+ /**
+ * The case when handling address data from the checkout.
+ * System's address fields are replacing billing address from export PayPal data.
+ * Billing and Shipping address are different
+ *
+ * @magentoDataFixture Magento/Paypal/_files/quote_payment_express_with_customer.php
+ * @magentoAppIsolation enabled
+ * @magentoDbIsolation enabled
+ */
+ public function testReturnFromPaypalIfCheckoutWithReturnBillingAddress()
+ {
$prefix = 'exported';
+ $quote = $this->getFixtureQuote();
+ $this->paypalConfig->expects($this->exactly(2))
+ ->method('getValue')
+ ->with('requireBillingAddress')
+ ->willReturn(1);
+ $this->prepareCheckoutModel($quote, $prefix);
+ $quote->getPayment()->setAdditionalInformation(Checkout::PAYMENT_INFO_BUTTON, 0);
+
+ $originalShippingAddress = $quote->getShippingAddress();
+
+ $this->checkoutModel->returnFromPaypal('token');
- $this->assertNotEquals([$prefix . $this->getExportedData()['street']], $shippingAddress->getStreet());
- $this->assertNotEquals($prefix . $this->getExportedData()['firstname'], $shippingAddress->getFirstname());
- $this->assertNotEquals($prefix . $this->getExportedData()['city'], $shippingAddress->getCity());
- $this->assertNotEquals($prefix . $this->getExportedData()['telephone'], $shippingAddress->getTelephone());
+ $shippingAddress = $quote->getShippingAddress();
+ $billingAddress = $quote->getBillingAddress();
+ $exportedBillingData = $this->getExportedData()['billing'];
+
+ $this->assertEquals($originalShippingAddress->getStreet(), $shippingAddress->getStreet());
+ $this->assertEquals($originalShippingAddress->getFirstname(), $shippingAddress->getFirstname());
+ $this->assertEquals($originalShippingAddress->getCity(), $shippingAddress->getCity());
+ $this->assertEquals($originalShippingAddress->getTelephone(), $shippingAddress->getTelephone());
+
+ $this->assertEquals([$prefix . $exportedBillingData['street']], $billingAddress->getStreet());
+ $this->assertEquals($prefix . $exportedBillingData['firstname'], $billingAddress->getFirstname());
+ $this->assertEquals($prefix . $exportedBillingData['city'], $billingAddress->getCity());
+ $this->assertEquals($prefix . $exportedBillingData['telephone'], $billingAddress->getTelephone());
}
/**
@@ -363,7 +458,7 @@ public function testReturnFromPayPalForCustomerWithEmptyAddresses(): void
$billingAddress = $quote->getBillingAddress();
- $this->performQuoteAddressAssertions($billingAddress, $this->getExportedData());
+ $this->performQuoteAddressAssertions($billingAddress, $this->getExportedData()['billing']);
}
/**
@@ -437,7 +532,7 @@ private function performQuoteAddressAssertions(Address $address, array $expected
*
* @param Quote $quote
*/
- private function prepareCheckoutModel(Quote $quote)
+ private function prepareCheckoutModel(Quote $quote, $prefix = '')
{
$this->checkoutModel = $this->objectManager->create(
Checkout::class,
@@ -448,11 +543,11 @@ private function prepareCheckoutModel(Quote $quote)
]
);
- $exportedBillingAddress = $this->getExportedAddressFixture($this->getExportedData());
+ $exportedBillingAddress = $this->getExportedAddressFixture($this->getExportedData()['billing'], $prefix);
$this->api->method('getExportedBillingAddress')
->willReturn($exportedBillingAddress);
- $exportedShippingAddress = $this->getExportedAddressFixture($this->getExportedData());
+ $exportedShippingAddress = $this->getExportedAddressFixture($this->getExportedData()['shipping'], $prefix);
$this->api->method('getExportedShippingAddress')
->willReturn($exportedShippingAddress);
@@ -468,16 +563,30 @@ private function prepareCheckoutModel(Quote $quote)
private function getExportedData(): array
{
return [
- 'email' => 'customer@example.com',
- 'firstname' => 'John',
- 'lastname' => 'Doe',
- 'country' => 'US',
- 'region' => 'Colorado',
- 'region_id' => '13',
- 'city' => 'Denver',
- 'street' => '66 Pearl St',
- 'postcode' => '80203',
- 'telephone' => '555-555-555',
+ 'shipping' => [
+ 'email' => 'customer@example.com',
+ 'firstname' => 'John',
+ 'lastname' => 'Doe',
+ 'country' => 'US',
+ 'region' => 'Colorado',
+ 'region_id' => '13',
+ 'city' => 'Denver',
+ 'street' => '66 Pearl St',
+ 'postcode' => '80203',
+ 'telephone' => '555-555-555'
+ ],
+ 'billing' => [
+ 'email' => 'customer@example.com',
+ 'firstname' => 'Jane',
+ 'lastname' => 'Doe',
+ 'country' => 'US',
+ 'region' => 'Texas',
+ 'region_id' => '13',
+ 'city' => 'Austin',
+ 'street' => '1100 Congress Ave',
+ 'postcode' => '78701',
+ 'telephone' => '555-555-555'
+ ]
];
}
diff --git a/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteManagementTest.php b/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteManagementTest.php
index 0b0071beb5133..356117f2b3dc8 100644
--- a/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteManagementTest.php
+++ b/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteManagementTest.php
@@ -3,10 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Quote\Model;
+use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Product\Type;
+use Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Quote\Api\CartManagementInterface;
+use Magento\Quote\Api\CartRepositoryInterface;
+use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\TestFramework\Helper\Bootstrap;
+use Magento\TestFramework\ObjectManager;
/**
* Class for testing QuoteManagement model
@@ -14,79 +22,120 @@
class QuoteManagementTest extends \PHPUnit\Framework\TestCase
{
/**
- * Create order with product that has child items
+ * @var ObjectManager
+ */
+ private $objectManager;
+
+ /**
+ * @var CartManagementInterface
+ */
+ private $cartManagement;
+
+ /**
+ * @inheritdoc
+ */
+ protected function setUp()
+ {
+ $this->objectManager = Bootstrap::getObjectManager();
+
+ $this->cartManagement = $this->objectManager->create(CartManagementInterface::class);
+ }
+
+ /**
+ * Creates order with product that has child items.
*
* @magentoAppIsolation enabled
* @magentoDataFixture Magento/Sales/_files/quote_with_bundle.php
*/
public function testSubmit()
{
- /**
- * Preconditions:
- * Load quote with Bundle product that has at least two child products
- */
- $objectManager = Bootstrap::getObjectManager();
- /** @var \Magento\Quote\Model\Quote $quote */
- $quote = $objectManager->create(\Magento\Quote\Model\Quote::class);
- $quote->load('test01', 'reserved_order_id');
-
- /** Execute SUT */
- /** @var \Magento\Quote\Api\CartManagementInterface $model */
- $cartManagement = $objectManager->create(\Magento\Quote\Api\CartManagementInterface::class);
- /** @var \Magento\Sales\Api\OrderRepositoryInterface $orderRepository */
- $orderRepository = $objectManager->create(\Magento\Sales\Api\OrderRepositoryInterface::class);
- $orderId = $cartManagement->placeOrder($quote->getId());
+ $quote = $this->getQuote('test01');
+ $orderId = $this->cartManagement->placeOrder($quote->getId());
+
+ /** @var OrderRepositoryInterface $orderRepository */
+ $orderRepository = $this->objectManager->create(OrderRepositoryInterface::class);
$order = $orderRepository->get($orderId);
- /** Check if SUT caused expected effects */
$orderItems = $order->getItems();
- $this->assertCount(3, $orderItems);
+ self::assertCount(3, $orderItems);
foreach ($orderItems as $orderItem) {
if ($orderItem->getProductType() == Type::TYPE_SIMPLE) {
- $this->assertNotEmpty($orderItem->getParentItem(), 'Parent is not set for child product');
- $this->assertNotEmpty($orderItem->getParentItemId(), 'Parent is not set for child product');
+ self::assertNotEmpty($orderItem->getParentItem(), 'Parent is not set for child product');
+ self::assertNotEmpty($orderItem->getParentItemId(), 'Parent is not set for child product');
}
}
}
/**
- * Create order with product that has child items and one of them was deleted
+ * Tries to create order with product that has child items and one of them was deleted.
*
* @magentoAppArea adminhtml
* @magentoAppIsolation enabled
* @magentoDataFixture Magento/Sales/_files/quote_with_bundle.php
+ * @expectedException \Magento\Framework\Exception\LocalizedException
+ * @expectedExceptionMessage Some of the products below do not have all the required options.
*/
public function testSubmitWithDeletedItem()
{
- /**
- * Preconditions:
- * Load quote with Bundle product that have at least to child products
- */
- $objectManager = Bootstrap::getObjectManager();
- /** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
- $productRepository = $objectManager->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
+ /** @var ProductRepositoryInterface $productRepository */
+ $productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
$product = $productRepository->get('simple-2');
$productRepository->delete($product);
- /** @var \Magento\Quote\Model\Quote $quote */
- $quote = $objectManager->create(\Magento\Quote\Model\Quote::class);
- $quote->load('test01', 'reserved_order_id');
-
- /** Execute SUT */
- /** @var \Magento\Quote\Api\CartManagementInterface $model */
- $cartManagement = $objectManager->create(\Magento\Quote\Api\CartManagementInterface::class);
- /** @var \Magento\Sales\Api\OrderRepositoryInterface $orderRepository */
- $orderRepository = $objectManager->create(\Magento\Sales\Api\OrderRepositoryInterface::class);
- $orderId = $cartManagement->placeOrder($quote->getId());
- $order = $orderRepository->get($orderId);
+ $quote = $this->getQuote('test01');
- /** Check if SUT caused expected effects */
- $orderItems = $order->getItems();
- $this->assertCount(2, $orderItems);
- foreach ($orderItems as $orderItem) {
- if ($orderItem->getProductType() == Type::TYPE_SIMPLE) {
- $this->assertNotEmpty($orderItem->getParentItem(), 'Parent is not set for child product');
- $this->assertNotEmpty($orderItem->getParentItemId(), 'Parent is not set for child product');
- }
- }
+ $this->cartManagement->placeOrder($quote->getId());
+ }
+
+ /**
+ * Tries to create order with item of stock during checkout.
+ *
+ * @magentoDataFixture Magento/Sales/_files/quote.php
+ * @expectedException \Magento\Framework\Exception\LocalizedException
+ * @expectedExceptionMessage Some of the products are out of stock.
+ * @magentoDbIsolation enabled
+ */
+ public function testSubmitWithItemOutOfStock()
+ {
+ $this->makeProductOutOfStock('simple');
+ $quote = $this->getQuote('test01');
+ $this->cartManagement->placeOrder($quote->getId());
+ }
+
+ /**
+ * Gets quote by reserved order ID.
+ *
+ * @param string $reservedOrderId
+ * @return Quote
+ */
+ private function getQuote(string $reservedOrderId): Quote
+ {
+ /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+ $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
+ $searchCriteria = $searchCriteriaBuilder->addFilter('reserved_order_id', $reservedOrderId)
+ ->create();
+
+ /** @var CartRepositoryInterface $quoteRepository */
+ $quoteRepository = $this->objectManager->get(CartRepositoryInterface::class);
+ $items = $quoteRepository->getList($searchCriteria)
+ ->getItems();
+
+ return array_pop($items);
+ }
+
+ /**
+ * Makes provided product as out of stock.
+ *
+ * @param string $sku
+ * @return void
+ */
+ private function makeProductOutOfStock(string $sku)
+ {
+ /** @var ProductRepositoryInterface $productRepository */
+ $productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
+ $product = $productRepository->get($sku);
+ $extensionAttributes = $product->getExtensionAttributes();
+ $stockItem = $extensionAttributes->getStockItem();
+ $stockItem->setIsInStock(false);
+ $productRepository->save($product);
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/GridTest.php b/dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/GridTest.php
index b8446839c8c99..0af32b32c7d48 100644
--- a/dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/GridTest.php
+++ b/dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/GridTest.php
@@ -3,10 +3,13 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Reports\Block\Adminhtml\Shopcart\Abandoned;
use Magento\Quote\Model\Quote;
use Magento\TestFramework\Helper\Bootstrap;
+use Magento\Framework\View\LayoutInterface;
/**
* Test class for \Magento\Reports\Block\Adminhtml\Shopcart\Abandoned\Grid
@@ -20,12 +23,12 @@ class GridTest extends \Magento\Reports\Block\Adminhtml\Shopcart\GridTestAbstrac
/**
* @return void
*/
- public function testGridContent()
+ public function testGridContent(): void
{
- /** @var \Magento\Framework\View\LayoutInterface $layout */
- $layout = Bootstrap::getObjectManager()->get(\Magento\Framework\View\LayoutInterface::class);
+ /** @var LayoutInterface $layout */
+ $layout = Bootstrap::getObjectManager()->get(LayoutInterface::class);
/** @var Grid $grid */
- $grid = $layout->createBlock(\Magento\Reports\Block\Adminhtml\Shopcart\Abandoned\Grid::class);
+ $grid = $layout->createBlock(Grid::class);
$grid->getRequest()->setParams(['filter' => base64_encode(urlencode('email=customer@example.com'))]);
$result = $grid->getPreparedCollection();
@@ -35,4 +38,17 @@ public function testGridContent()
$this->assertEquals('customer@example.com', $quote->getCustomerEmail());
$this->assertEquals(10.00, $quote->getSubtotal());
}
+
+ /**
+ * @return void
+ */
+ public function testPageSizeIsSetToNullWhenExportCsvFile(): void
+ {
+ /** @var LayoutInterface $layout */
+ $layout = Bootstrap::getObjectManager()->get(LayoutInterface::class);
+ /** @var Grid $grid */
+ $grid = $layout->createBlock(Grid::class);
+ $grid->getCsvFile();
+ $this->assertNull($grid->getCollection()->getPageSize());
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create/SaveTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create/SaveTest.php
index b9573c99b4493..e2638b5df1f88 100644
--- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create/SaveTest.php
+++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Create/SaveTest.php
@@ -8,6 +8,7 @@
use Magento\Backend\Model\Session\Quote;
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Framework\App\Request\Http;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Message\MessageInterface;
use Magento\Quote\Api\CartRepositoryInterface;
@@ -38,6 +39,7 @@ public function testExecuteWithPaymentOperation()
'email' => $email
]
];
+ $this->getRequest()->setMethod(Http::METHOD_POST);
$this->getRequest()->setPostValue(['order' => $data]);
/** @var OrderService|MockObject $orderService */
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreateTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreateTest.php
index e071dde26a263..efb1b12fc60ed 100644
--- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreateTest.php
@@ -8,10 +8,13 @@
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Backend\Model\Session\Quote;
use Magento\Quote\Api\CartRepositoryInterface;
+use Magento\Framework\App\Request\Http as HttpRequest;
/**
* @magentoAppArea adminhtml
* @magentoDbIsolation enabled
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CreateTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
@@ -20,6 +23,11 @@ class CreateTest extends \Magento\TestFramework\TestCase\AbstractBackendControll
*/
protected $productRepository;
+ /**
+ * @inheritDoc
+ *
+ * @throws \Magento\Framework\Exception\AuthenticationException
+ */
protected function setUp()
{
parent::setUp();
@@ -27,8 +35,12 @@ protected function setUp()
->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
}
+ /**
+ * Test LoadBlock being dispatched.
+ */
public function testLoadBlockAction()
{
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setParam('block', ',');
$this->getRequest()->setParam('json', 1);
$this->dispatch('backend/sales/order_create/loadBlock');
@@ -46,6 +58,7 @@ public function testLoadBlockActionData()
)->addProducts(
[$product->getId() => ['qty' => 1]]
);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setParam('block', 'data');
$this->getRequest()->setParam('json', 1);
$this->dispatch('backend/sales/order_create/loadBlock');
@@ -57,10 +70,14 @@ public function testLoadBlockActionData()
}
/**
+ * @param string $block Block name.
+ * @param string $expected Contains HTML.
+ *
* @dataProvider loadBlockActionsDataProvider
*/
public function testLoadBlockActions($block, $expected)
{
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setParam('block', $block);
$this->getRequest()->setParam('json', 1);
$this->dispatch('backend/sales/order_create/loadBlock');
@@ -68,6 +85,9 @@ public function testLoadBlockActions($block, $expected)
$this->assertContains($expected, $html);
}
+ /**
+ * @return array
+ */
public function loadBlockActionsDataProvider()
{
return [
@@ -90,6 +110,7 @@ public function testLoadBlockActionItems()
)->addProducts(
[$product->getId() => ['qty' => 1]]
);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setParam('block', 'items');
$this->getRequest()->setParam('json', 1);
$this->dispatch('backend/sales/order_create/loadBlock');
@@ -215,6 +236,11 @@ public function testConfigureProductToAddAction()
$this->assertContains(sprintf('"productId":"%s"', $product->getEntityId()), $body);
}
+ /**
+ * Test not allowing to save.
+ *
+ * @throws \Magento\Framework\Exception\LocalizedException
+ */
public function testDeniedSaveAction()
{
$this->_objectManager->configure(
@@ -230,6 +256,7 @@ public function testDeniedSaveAction()
\Magento\TestFramework\Helper\Bootstrap::getInstance()
->loadArea('adminhtml');
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/sales/order_create/save');
$this->assertEquals('403', $this->getResponse()->getHttpResponseCode());
}
@@ -263,6 +290,7 @@ public function testSyncBetweenQuoteAddresses()
'region' => 'Kyivska',
'region_id' => 1
];
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue(
[
'order' => ['billing_address' => $data],
diff --git a/dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_cart_fixed_discount_rollback.php b/dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_cart_fixed_discount_rollback.php
new file mode 100644
index 0000000000000..33a8b4285d8d7
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_cart_fixed_discount_rollback.php
@@ -0,0 +1,17 @@
+get(\Magento\Framework\Registry::class);
+
+/** @var Magento\SalesRule\Model\Rule $rule */
+$rule = $registry->registry('cart_rule_fixed_discount_coupon');
+if ($rule) {
+ $rule->delete();
+}
diff --git a/dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_code_with_wildcard_rollback.php b/dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_code_with_wildcard_rollback.php
index 776c302210351..c9613c371bbe5 100644
--- a/dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_code_with_wildcard_rollback.php
+++ b/dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_code_with_wildcard_rollback.php
@@ -14,8 +14,19 @@
$objectManager = Bootstrap::getObjectManager();
+/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+$searchCriteriaBuilder = Bootstrap::getObjectManager()->get(SearchCriteriaBuilder::class);
+$searchCriteria = $searchCriteriaBuilder->addFilter('name', '5$ fixed discount on whole cart')
+ ->create();
+
+/** @var RuleRepositoryInterface $ruleRepository */
+$ruleRepository = Bootstrap::getObjectManager()->get(RuleRepositoryInterface::class);
+$items = $ruleRepository->getList($searchCriteria)
+ ->getItems();
+
+$salesRule = array_pop($items);
+
/** @var Rule $salesRule */
-$salesRule = getSalesRule('5$ fixed discount on whole cart');
if ($salesRule !== null) {
/** @var RuleRepositoryInterface $ruleRepository */
$ruleRepository = $objectManager->get(RuleRepositoryInterface::class);
@@ -29,18 +40,3 @@
$couponRepository = $objectManager->get(CouponRepositoryInterface::class);
$couponRepository->deleteById($coupon->getCouponId());
}
-
-function getSalesRule(string $name)
-{
- /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
- $searchCriteriaBuilder = Bootstrap::getObjectManager()->get(SearchCriteriaBuilder::class);
- $searchCriteria = $searchCriteriaBuilder->addFilter('name', $name)
- ->create();
-
- /** @var RuleRepositoryInterface $ruleRepository */
- $ruleRepository = Bootstrap::getObjectManager()->get(RuleRepositoryInterface::class);
- $items = $ruleRepository->getList($searchCriteria)
- ->getItems();
-
- return array_pop($items);
-}
diff --git a/dev/tests/integration/testsuite/Magento/Store/App/Request/PathInfoProcessorTest.php b/dev/tests/integration/testsuite/Magento/Store/App/Request/PathInfoProcessorTest.php
index 90ceaa4fcc5a0..e0a1321092a68 100644
--- a/dev/tests/integration/testsuite/Magento/Store/App/Request/PathInfoProcessorTest.php
+++ b/dev/tests/integration/testsuite/Magento/Store/App/Request/PathInfoProcessorTest.php
@@ -14,7 +14,7 @@ class PathInfoProcessorTest extends \PHPUnit\Framework\TestCase
/**
* @var \Magento\Store\App\Request\PathInfoProcessor
*/
- protected $pathProcessor;
+ private $pathProcessor;
protected function setUp()
{
@@ -31,7 +31,11 @@ public function testProcessNotValidStoreCode($pathInfo)
{
/** @var \Magento\Framework\App\RequestInterface $request */
$request = Bootstrap::getObjectManager()->create(\Magento\Framework\App\RequestInterface::class);
- $this->assertEquals($pathInfo, $this->pathProcessor->process($request, $pathInfo));
+ /** @var \Magento\Framework\App\Config\ReinitableConfigInterface $config */
+ $config = Bootstrap::getObjectManager()->get(\Magento\Framework\App\Config\ReinitableConfigInterface::class);
+ $config->setValue(Store::XML_PATH_STORE_IN_URL, true);
+ $info = $this->pathProcessor->process($request, $pathInfo);
+ $this->assertEquals($pathInfo, $info);
}
public function notValidStoreCodeDataProvider()
@@ -46,7 +50,7 @@ public function notValidStoreCodeDataProvider()
* @covers \Magento\Store\App\Request\PathInfoProcessor::process
* @magentoDataFixture Magento/Store/_files/core_fixturestore.php
*/
- public function testProcessValidStoreCodeCase1()
+ public function testProcessValidStoreDisabledStoreUrl()
{
/** @var \Magento\Store\Model\Store $store */
$store = Bootstrap::getObjectManager()->get(\Magento\Store\Model\Store::class);
@@ -57,6 +61,7 @@ public function testProcessValidStoreCodeCase1()
/** @var \Magento\Framework\App\Config\ReinitableConfigInterface $config */
$config = Bootstrap::getObjectManager()->get(\Magento\Framework\App\Config\ReinitableConfigInterface::class);
+ $config->setValue(Store::XML_PATH_STORE_IN_URL, true);
$config->setValue(Store::XML_PATH_STORE_IN_URL, false, ScopeInterface::SCOPE_STORE, $store->getCode());
$pathInfo = sprintf('/%s/m/c/a', $store->getCode());
$this->assertEquals($pathInfo, $this->pathProcessor->process($request, $pathInfo));
@@ -66,7 +71,7 @@ public function testProcessValidStoreCodeCase1()
* @covers \Magento\Store\App\Request\PathInfoProcessor::process
* @magentoDataFixture Magento/Store/_files/core_fixturestore.php
*/
- public function testProcessValidStoreCodeCase2()
+ public function testProcessValidStoreCodeCaseProcessStoreName()
{
/** @var \Magento\Store\Model\Store $store */
$store = Bootstrap::getObjectManager()->get(\Magento\Store\Model\Store::class);
@@ -77,6 +82,7 @@ public function testProcessValidStoreCodeCase2()
/** @var \Magento\Framework\App\Config\ReinitableConfigInterface $config */
$config = Bootstrap::getObjectManager()->get(\Magento\Framework\App\Config\ReinitableConfigInterface::class);
+ $config->setValue(Store::XML_PATH_STORE_IN_URL, true);
$config->setValue(Store::XML_PATH_STORE_IN_URL, true, ScopeInterface::SCOPE_STORE, $store->getCode());
$pathInfo = sprintf('/%s/m/c/a', $store->getCode());
$this->assertEquals('/m/c/a', $this->pathProcessor->process($request, $pathInfo));
@@ -86,7 +92,7 @@ public function testProcessValidStoreCodeCase2()
* @covers \Magento\Store\App\Request\PathInfoProcessor::process
* @magentoDataFixture Magento/Store/_files/core_fixturestore.php
*/
- public function testProcessValidStoreCodeCase3()
+ public function testProcessValidStoreCodeWhenStoreIsDirectFrontNameWithFrontName()
{
/** @var \Magento\Store\Model\Store $store */
$store = Bootstrap::getObjectManager()->get(\Magento\Store\Model\Store::class);
@@ -100,9 +106,77 @@ public function testProcessValidStoreCodeCase3()
/** @var \Magento\Framework\App\Config\ReinitableConfigInterface $config */
$config = Bootstrap::getObjectManager()->get(\Magento\Framework\App\Config\ReinitableConfigInterface::class);
+ $config->setValue(Store::XML_PATH_STORE_IN_URL, true);
$config->setValue(Store::XML_PATH_STORE_IN_URL, true, ScopeInterface::SCOPE_STORE, $store->getCode());
$pathInfo = sprintf('/%s/m/c/a', $store->getCode());
$this->assertEquals($pathInfo, $this->pathProcessor->process($request, $pathInfo));
- $this->assertEquals('noroute', $request->getActionName());
+ $this->assertEquals(\Magento\Framework\App\Router\Base::NO_ROUTE, $request->getActionName());
+ }
+
+ /**
+ * @covers \Magento\Store\App\Request\PathInfoProcessor::process
+ * @magentoDataFixture Magento/Store/_files/core_fixturestore.php
+ */
+ public function testProcessValidStoreCodeWhenStoreCodeInUrlIsDisabledWithFrontName()
+ {
+ /** @var \Magento\Store\Model\Store $store */
+ $store = Bootstrap::getObjectManager()->get(\Magento\Store\Model\Store::class);
+ $store->load('fixturestore', 'code');
+
+ /** @var \Magento\Framework\App\RequestInterface $request */
+ $request = Bootstrap::getObjectManager()->create(
+ \Magento\Framework\App\RequestInterface::class,
+ ['directFrontNames' => ['someFrontName' => true]]
+ );
+
+ /** @var \Magento\Framework\App\Config\ReinitableConfigInterface $config */
+ $config = Bootstrap::getObjectManager()->get(\Magento\Framework\App\Config\ReinitableConfigInterface::class);
+ $config->setValue(Store::XML_PATH_STORE_IN_URL, true);
+ $config->setValue(Store::XML_PATH_STORE_IN_URL, false, ScopeInterface::SCOPE_STORE, $store->getCode());
+ $pathInfo = sprintf('/%s/m/c/a', $store->getCode());
+ $this->assertEquals($pathInfo, $this->pathProcessor->process($request, $pathInfo));
+ }
+
+ /**
+ * @covers \Magento\Store\App\Request\PathInfoProcessor::process
+ * @magentoDataFixture Magento/Store/_files/core_fixturestore.php
+ */
+ public function testProcessValidStoreCodeWhenStoreCodeisAdmin()
+ {
+ /** @var \Magento\Store\Model\Store $store */
+ $store = Bootstrap::getObjectManager()->get(\Magento\Store\Model\Store::class);
+ $store->load('fixturestore', 'code');
+
+ /** @var \Magento\Framework\App\RequestInterface $request */
+ $request = Bootstrap::getObjectManager()->create(
+ \Magento\Framework\App\RequestInterface::class,
+ ['directFrontNames' => ['someFrontName' => true]]
+ );
+
+ /** @var \Magento\Framework\App\Config\ReinitableConfigInterface $config */
+ $config = Bootstrap::getObjectManager()->get(\Magento\Framework\App\Config\ReinitableConfigInterface::class);
+ $config->setValue(Store::XML_PATH_STORE_IN_URL, true);
+ $config->setValue(Store::XML_PATH_STORE_IN_URL, false, ScopeInterface::SCOPE_STORE, $store->getCode());
+ $pathInfo = sprintf('/%s/m/c/a', 'admin');
+ $this->assertEquals($pathInfo, $this->pathProcessor->process($request, $pathInfo));
+ }
+
+ /**
+ * @covers \Magento\Store\App\Request\PathInfoProcessor::process
+ */
+ public function testProcessValidStoreCodeWhenUrlConfigIsDisabled()
+ {
+ /** @var \Magento\Framework\App\RequestInterface $request */
+ $request = Bootstrap::getObjectManager()->create(
+ \Magento\Framework\App\RequestInterface::class,
+ ['directFrontNames' => ['someFrontName' => true]]
+ );
+
+ /** @var \Magento\Framework\App\Config\ReinitableConfigInterface $config */
+ $config = Bootstrap::getObjectManager()->get(\Magento\Framework\App\Config\ReinitableConfigInterface::class);
+ $config->setValue(Store::XML_PATH_STORE_IN_URL, false);
+ $pathInfo = sprintf('/%s/m/c/a', 'whatever');
+ $this->assertEquals($pathInfo, $this->pathProcessor->process($request, $pathInfo));
+ $this->assertEquals(null, $request->getActionName());
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Swatches/Controller/Adminhtml/Product/AttributeTest.php b/dev/tests/integration/testsuite/Magento/Swatches/Controller/Adminhtml/Product/AttributeTest.php
index 969d9530ae542..e222e6fda48d7 100644
--- a/dev/tests/integration/testsuite/Magento/Swatches/Controller/Adminhtml/Product/AttributeTest.php
+++ b/dev/tests/integration/testsuite/Magento/Swatches/Controller/Adminhtml/Product/AttributeTest.php
@@ -7,6 +7,8 @@
namespace Magento\Swatches\Controller\Adminhtml\Product;
+use Magento\Framework\App\Request\Http as HttpRequest;
+use Magento\Framework\Data\Form\FormKey;
use Magento\Framework\Exception\LocalizedException;
/**
@@ -17,6 +19,21 @@
*/
class AttributeTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
+ /**
+ * @var FormKey
+ */
+ private $formKey;
+
+ /**
+ * @inheritDoc
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+
+ $this->formKey = $this->_objectManager->get(FormKey::class);
+ }
+
/**
* Generate random hex color.
*
@@ -112,7 +129,6 @@ private function getAttributePreset() : array
{
return [
'serialized_options' => '[]',
- 'form_key' => 'XxtpPYjm2YPYUlAt',
'frontend_label' => [
0 => 'asdasd',
1 => '',
@@ -175,7 +191,9 @@ public function testLargeOptionsDataSet(
int $expectedOptionsCount,
array $expectedLabels
) : void {
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($attributeData);
+ $this->getRequest()->setPostValue('form_key', $this->formKey->getFormKey());
$this->dispatch('backend/catalog/product_attribute/save');
$entityTypeId = $this->_objectManager->create(
\Magento\Eav\Model\Entity::class
diff --git a/dev/tests/integration/testsuite/Magento/Theme/Controller/Adminhtml/System/Design/Config/SaveTest.php b/dev/tests/integration/testsuite/Magento/Theme/Controller/Adminhtml/System/Design/Config/SaveTest.php
index 95fcf24894c87..cb684c0216889 100644
--- a/dev/tests/integration/testsuite/Magento/Theme/Controller/Adminhtml/System/Design/Config/SaveTest.php
+++ b/dev/tests/integration/testsuite/Magento/Theme/Controller/Adminhtml/System/Design/Config/SaveTest.php
@@ -6,6 +6,7 @@
namespace Magento\Theme\Controller\Adminhtml\System\Design\Config;
+use Magento\Framework\App\Request\Http;
use Magento\Framework\Data\Form\FormKey;
use Magento\TestFramework\TestCase\AbstractBackendController;
@@ -29,6 +30,9 @@ class SaveTest extends AbstractBackendController
*/
protected $uri = 'backend/theme/design_config/save';
+ /**
+ * @inheritdoc
+ */
protected function setUp()
{
parent::setUp();
@@ -36,6 +40,7 @@ protected function setUp()
$this->formKey = $this->_objectManager->get(
FormKey::class
);
+ $this->httpMethod = Http::METHOD_POST;
}
/**
@@ -107,12 +112,11 @@ private function getRequestParams()
];
}
+ /**
+ * @inheritDoc
+ */
public function testAclHasAccess()
{
- $this->getRequest()->setMethod(
- \Zend\Http\Request::METHOD_POST
- );
-
$this->getRequest()->setParams(
[
'form_key' => $this->formKey->getFormKey()
diff --git a/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/UserTest.php b/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/UserTest.php
index 995ec5f6bed85..9cf8fc43951d4 100644
--- a/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/UserTest.php
+++ b/dev/tests/integration/testsuite/Magento/User/Controller/Adminhtml/UserTest.php
@@ -6,6 +6,7 @@
namespace Magento\User\Controller\Adminhtml;
+use Magento\Framework\App\Request\Http as HttpRequest;
use Magento\TestFramework\Bootstrap;
/**
@@ -35,6 +36,7 @@ public function testIndexAction()
*/
public function testSaveActionNoData()
{
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/admin/user/save');
$this->assertRedirect($this->stringContains('backend/admin/user/index/'));
}
@@ -55,6 +57,7 @@ public function testSaveActionWrongId()
$userId = $user->getId();
$this->assertNotEmpty($userId, 'Broken fixture');
$user->delete();
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue('user_id', $userId);
$this->dispatch('backend/admin/user/save');
$this->assertSessionMessages(
@@ -72,6 +75,7 @@ public function testSaveActionWrongId()
public function testSaveActionMissingCurrentAdminPassword()
{
$fixture = uniqid();
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue(
[
'username' => $fixture,
@@ -99,6 +103,7 @@ public function testSaveActionMissingCurrentAdminPassword()
public function testSaveAction()
{
$fixture = uniqid();
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue(
[
'username' => $fixture,
@@ -126,6 +131,7 @@ public function testSaveAction()
*/
public function testSaveActionDuplicateUser()
{
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue(
[
'username' => 'adminUser',
@@ -147,13 +153,17 @@ public function testSaveActionDuplicateUser()
}
/**
- * Verify password change properly updates fields when the request is valid
+ * Verify password change properly updates fields when the request is valid.
+ *
+ * @param array $postData
+ * @param bool $isPasswordCorrect
*
* @magentoDbIsolation enabled
* @dataProvider saveActionPasswordChangeDataProvider
*/
public function testSaveActionPasswordChange($postData, $isPasswordCorrect)
{
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($postData);
$this->dispatch('backend/admin/user/save');
diff --git a/dev/tests/integration/testsuite/Magento/Widget/Controller/Adminhtml/WidgetTest.php b/dev/tests/integration/testsuite/Magento/Widget/Controller/Adminhtml/WidgetTest.php
index 26ed706e3eccb..f5b5fe533e108 100644
--- a/dev/tests/integration/testsuite/Magento/Widget/Controller/Adminhtml/WidgetTest.php
+++ b/dev/tests/integration/testsuite/Magento/Widget/Controller/Adminhtml/WidgetTest.php
@@ -15,7 +15,7 @@ class WidgetTest extends \Magento\TestFramework\TestCase\AbstractBackendControll
*/
public function testLoadOptionsAction()
{
- $this->getRequest()->setPostValue(
+ $this->getRequest()->setParam(
'widget',
'{"widget_type":"Magento\\\\Cms\\\\Block\\\\Widget\\\\Page\\\\Link","values":{}}'
);
diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/Controller/IndexTest.php b/dev/tests/integration/testsuite/Magento/Wishlist/Controller/IndexTest.php
index 8edc916f2afd5..92eae7a3fe3d7 100644
--- a/dev/tests/integration/testsuite/Magento/Wishlist/Controller/IndexTest.php
+++ b/dev/tests/integration/testsuite/Magento/Wishlist/Controller/IndexTest.php
@@ -122,6 +122,7 @@ public function testAddActionProductNameXss()
}
/**
+ * @magentoDbIsolation disabled
* @magentoDataFixture Magento/Wishlist/_files/wishlist_with_product_qty_increments.php
*/
public function testAllcartAction()
diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/Model/WishlistTest.php b/dev/tests/integration/testsuite/Magento/Wishlist/Model/WishlistTest.php
index 99f9aa4991b5e..b684da05dd254 100644
--- a/dev/tests/integration/testsuite/Magento/Wishlist/Model/WishlistTest.php
+++ b/dev/tests/integration/testsuite/Magento/Wishlist/Model/WishlistTest.php
@@ -6,6 +6,7 @@
namespace Magento\Wishlist\Model;
use Magento\Catalog\Api\ProductRepositoryInterface;
+use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\DataObject;
@@ -85,4 +86,39 @@ public function testAddNewItemInvalidWishlistItemConfiguration()
);
$this->wishlist->addNewItem($product);
}
+
+ /**
+ * @magentoDbIsolation disabled
+ * @magentoDataFixture Magento/Wishlist/_files/wishlist.php
+ */
+ public function testGetItemCollection()
+ {
+ $productSku = 'simple';
+ $customerId = 1;
+
+ $this->wishlist->loadByCustomerId($customerId, true);
+ $itemCollection = $this->wishlist->getItemCollection();
+ /** @var \Magento\Wishlist\Model\Item $item */
+ $item = $itemCollection->getFirstItem();
+ $this->assertEquals($productSku, $item->getProduct()->getSku());
+ }
+
+ /**
+ * @magentoDbIsolation disabled
+ * @magentoDataFixture Magento/Wishlist/_files/wishlist.php
+ */
+ public function testGetItemCollectionWithDisabledProduct()
+ {
+ $productSku = 'simple';
+ $customerId = 1;
+
+ $productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
+ $product = $productRepository->get($productSku);
+ $product->setStatus(ProductStatus::STATUS_DISABLED);
+ $productRepository->save($product);
+
+ $this->wishlist->loadByCustomerId($customerId, true);
+ $itemCollection = $this->wishlist->getItemCollection();
+ $this->assertEmpty($itemCollection->getItems());
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_rollback.php b/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_rollback.php
new file mode 100644
index 0000000000000..61b5bbb7bd32f
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_rollback.php
@@ -0,0 +1,25 @@
+get(\Magento\Framework\Registry::class);
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+
+/** @var \Magento\Wishlist\Model\Wishlist $wishlist */
+$wishlist = $objectManager->create(\Magento\Wishlist\Model\Wishlist::class);
+$wishlist->loadByCustomerId(1);
+$wishlist->delete();
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
+
+require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_rollback.php';
+require __DIR__ . '/../../../Magento/Customer/_files/customer_rollback.php';
diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_with_product_qty_increments_rollback.php b/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_with_product_qty_increments_rollback.php
new file mode 100644
index 0000000000000..91392fec6b721
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_with_product_qty_increments_rollback.php
@@ -0,0 +1,25 @@
+get(\Magento\Framework\Registry::class);
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+
+/** @var \Magento\Wishlist\Model\Wishlist $wishlist */
+$wishlist = $objectManager->create(\Magento\Wishlist\Model\Wishlist::class);
+$wishlist->loadByCustomerId(1);
+$wishlist->delete();
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
+
+require __DIR__ . '/../../../Magento/Catalog/_files/product_special_price_rollback.php';
+require __DIR__ . '/../../../Magento/Customer/_files/customer_rollback.php';
diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Catalog/frontend/js/product/view/product-ids-resolver.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Catalog/frontend/js/product/view/product-ids-resolver.test.js
new file mode 100644
index 0000000000000..be92b6814da3b
--- /dev/null
+++ b/dev/tests/js/jasmine/tests/app/code/Magento/Catalog/frontend/js/product/view/product-ids-resolver.test.js
@@ -0,0 +1,62 @@
+/**
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+/* eslint-disable max-nested-callbacks */
+define([
+ 'squire',
+ 'jquery',
+ 'ko',
+ 'jquery/ui'
+], function (Squire, $, ko) {
+ 'use strict';
+
+ var injector = new Squire(),
+ mocks = {
+ 'Magento_Catalog/js/product/view/product-ids': ko.observableArray([])
+ },
+ form = $(
+ '
'
+ ),
+ productIdResolver;
+
+ beforeAll(function (done) {
+
+ injector.mock(mocks);
+ injector.require(
+ [
+ 'Magento_Catalog/js/product/view/product-ids-resolver'
+ ], function (resolver) {
+ productIdResolver = resolver;
+ done();
+ }
+ );
+ });
+
+ describe('Magento_Catalog/js/product/view/product-ids-resolver', function () {
+ var dataProvider = [
+ {
+ ids: [],
+ expected: ['1']
+ },
+ {
+ ids: ['2', '3'],
+ expected: ['2', '3', '1']
+ },
+ {
+ ids: ['3', '1', '5'],
+ expected: ['3', '1', '5']
+ }
+ ];
+
+ dataProvider.forEach(function (data) {
+ it('resolved product id\'s', function () {
+ mocks['Magento_Catalog/js/product/view/product-ids'](data.ids);
+ expect(productIdResolver(form)).toEqual(data.expected);
+ });
+ });
+ });
+});
diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/sidebar.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/sidebar.test.js
index 8b4fae5a69461..7c21a8aae2f26 100644
--- a/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/sidebar.test.js
+++ b/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/sidebar.test.js
@@ -26,15 +26,18 @@ define([
'items': [
{
'item_id': 1,
- 'product_sku': 'bundle'
+ 'product_sku': 'bundle',
+ 'product_id': '1'
},
{
'item_id': 5,
- 'product_sku': 'simple'
+ 'product_sku': 'simple',
+ 'product_id': '5'
},
{
'item_id': 7,
- 'product_sku': 'configurable'
+ 'product_sku': 'configurable',
+ 'product_id': '7'
}
]
},
@@ -63,7 +66,9 @@ define([
sidebar._removeItemAfter(elem);
expect(mocks['Magento_Customer/js/customer-data'].get).toHaveBeenCalledWith('cart');
- expect(jQuery('body').trigger).toHaveBeenCalledWith('ajax:removeFromCart', 'simple');
+ expect(jQuery('body').trigger).toHaveBeenCalledWith('ajax:removeFromCart', {
+ 'productIds': ['5']
+ });
});
it('Cart item doesn\'t exists', function () {
@@ -91,7 +96,7 @@ define([
sidebar._updateItemQtyAfter(elem);
expect(mocks['Magento_Customer/js/customer-data'].get).toHaveBeenCalledWith('cart');
- expect(jQuery('body').trigger).toHaveBeenCalledWith('ajax:updateCartItemQty', 'simple');
+ expect(jQuery('body').trigger).toHaveBeenCalledWith('ajax:updateCartItemQty');
expect(sidebar._hideItemButton).toHaveBeenCalledWith(elem);
});
diff --git a/dev/tests/static/framework/Magento/CodeMessDetector/Rule/Design/AllPurposeAction.php b/dev/tests/static/framework/Magento/CodeMessDetector/Rule/Design/AllPurposeAction.php
new file mode 100644
index 0000000000000..fb5938be61328
--- /dev/null
+++ b/dev/tests/static/framework/Magento/CodeMessDetector/Rule/Design/AllPurposeAction.php
@@ -0,0 +1,50 @@
+getFullQualifiedName(), true);
+ } catch (\Throwable $exception) {
+ //Couldn't load a class.
+ return;
+ }
+
+ if (in_array(ActionInterface::class, $impl, true)) {
+ $methodsDefined = false;
+ foreach ($impl as $i) {
+ if (preg_match('/\\\Http[a-z]+ActionInterface$/i', $i)) {
+ $methodsDefined = true;
+ break;
+ }
+ }
+ if (!$methodsDefined) {
+ $this->addViolation($node, [$node->getFullQualifiedName()]);
+ }
+ }
+ }
+}
diff --git a/dev/tests/static/framework/Magento/CodeMessDetector/Test/Unit/Rule/Design/AllPurposeActionTest.php b/dev/tests/static/framework/Magento/CodeMessDetector/Test/Unit/Rule/Design/AllPurposeActionTest.php
new file mode 100644
index 0000000000000..408853141e538
--- /dev/null
+++ b/dev/tests/static/framework/Magento/CodeMessDetector/Test/Unit/Rule/Design/AllPurposeActionTest.php
@@ -0,0 +1,134 @@
+createNodeMock($fakeAction);
+ $rule = new AllPurposeAction();
+ $this->expectsRuleViolation($rule, $violates);
+ $rule->apply($node);
+ }
+
+ /**
+ * @return array
+ */
+ public function getCases(): array
+ {
+ return [
+ [
+ new class implements ActionInterface, HttpGetActionInterface {
+ /**
+ * @inheritDoc
+ */
+ public function execute()
+ {
+ return null;
+ }
+ },
+ false
+ ],
+ [
+ new class implements ActionInterface {
+ /**
+ * @inheritDoc
+ */
+ public function execute()
+ {
+ return null;
+ }
+ },
+ true
+ ],
+ [
+ new class implements HttpGetActionInterface {
+ /**
+ * @inheritDoc
+ */
+ public function execute()
+ {
+ return null;
+ }
+ },
+ false
+ ],
+ [
+ new class {
+
+ },
+ false
+ ]
+ ];
+ }
+
+ /**
+ * @param object $dynamicObject
+ *
+ * @return ClassNode|MockObject
+ */
+ private function createNodeMock($dynamicObject): MockObject
+ {
+ $node = $this->getMockBuilder(ClassNode::class)
+ ->disableOriginalConstructor()
+ ->disableProxyingToOriginalMethods()
+ ->setMethods([
+ // disable name lookup from AST artifact
+ 'getNamespaceName',
+ 'getParentName',
+ 'getName',
+ 'getFullQualifiedName',
+ ])
+ ->getMock();
+ $node->expects($this->any())
+ ->method('getFullQualifiedName')
+ ->willReturn(get_class($dynamicObject));
+
+ return $node;
+ }
+
+ /**
+ * @param AllPurposeAction $rule
+ * @param bool $expects
+ * @return InvocationMocker
+ */
+ private function expectsRuleViolation(
+ AllPurposeAction $rule,
+ bool $expects
+ ): InvocationMocker {
+ /** @var Report|MockObject $report */
+ $report = $this->getMockBuilder(Report::class)->getMock();
+ if ($expects) {
+ $violationExpectation = $this->atLeastOnce();
+ } else {
+ $violationExpectation = $this->never();
+ }
+ $invokation = $report->expects($violationExpectation)
+ ->method('addRuleViolation');
+ $rule->setReport($report);
+
+ return $invokation;
+ }
+}
diff --git a/dev/tests/static/framework/Magento/CodeMessDetector/resources/rulesets/design.xml b/dev/tests/static/framework/Magento/CodeMessDetector/resources/rulesets/design.xml
index 61d4f7b3be81d..c9bfe4fe6e308 100644
--- a/dev/tests/static/framework/Magento/CodeMessDetector/resources/rulesets/design.xml
+++ b/dev/tests/static/framework/Magento/CodeMessDetector/resources/rulesets/design.xml
@@ -29,6 +29,31 @@ final class Foo
}
class Baz {
final public function bad() {}
+}
+ ]]>
+
+
+
+
+ ActionInterface
+to restrict incoming requests by methods.
+ ]]>
+
+ 2
+
+
+
diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpmd/ruleset.xml b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpmd/ruleset.xml
index 76f76e2b23c56..fddb1e6fdfc14 100644
--- a/dev/tests/static/testsuite/Magento/Test/Php/_files/phpmd/ruleset.xml
+++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/phpmd/ruleset.xml
@@ -47,5 +47,6 @@
+
diff --git a/lib/internal/Magento/Framework/Amqp/Config.php b/lib/internal/Magento/Framework/Amqp/Config.php
index 8fb827d9eb0d2..684c5cd38b1e4 100644
--- a/lib/internal/Magento/Framework/Amqp/Config.php
+++ b/lib/internal/Magento/Framework/Amqp/Config.php
@@ -131,10 +131,12 @@ public function __destruct()
public function getValue($key)
{
$this->load();
- return isset($this->data[$key]) ? $this->data[$key] : null;
+ return $this->data[$key] ?? null;
}
/**
+ * Create amqp connection
+ *
* @return AbstractConnection
*/
private function createConnection(): AbstractConnection
diff --git a/lib/internal/Magento/Framework/App/Action/Forward.php b/lib/internal/Magento/Framework/App/Action/Forward.php
index 7d6f956545b45..c81bc48ace4d5 100644
--- a/lib/internal/Magento/Framework/App/Action/Forward.php
+++ b/lib/internal/Magento/Framework/App/Action/Forward.php
@@ -10,6 +10,11 @@
use Magento\Framework\App\RequestInterface;
use Magento\Framework\App\ResponseInterface;
+/**
+ * Forward request further.
+ *
+ * @SuppressWarnings(PHPMD.AllPurposeAction)
+ */
class Forward extends AbstractAction
{
/**
diff --git a/lib/internal/Magento/Framework/App/Action/HttpConnectActionInterface.php b/lib/internal/Magento/Framework/App/Action/HttpConnectActionInterface.php
new file mode 100644
index 0000000000000..426fe584bade6
--- /dev/null
+++ b/lib/internal/Magento/Framework/App/Action/HttpConnectActionInterface.php
@@ -0,0 +1,19 @@
+load();
- return isset($this->statuses[$cacheType]) ? (bool)$this->statuses[$cacheType] : false;
+ return (bool)($this->statuses[$cacheType] ?? false);
}
/**
diff --git a/lib/internal/Magento/Framework/App/FrontController.php b/lib/internal/Magento/Framework/App/FrontController.php
index b00cb3ed6090f..ba23e010e3e3f 100644
--- a/lib/internal/Magento/Framework/App/FrontController.php
+++ b/lib/internal/Magento/Framework/App/FrontController.php
@@ -14,6 +14,7 @@
use Magento\Framework\Message\ManagerInterface as MessageManager;
use Magento\Framework\App\Action\AbstractAction;
use Psr\Log\LoggerInterface;
+use Magento\Framework\App\Request\Http as HttpRequest;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -45,6 +46,11 @@ class FrontController implements FrontControllerInterface
*/
private $logger;
+ /**
+ * @var bool
+ */
+ private $validatedRequest = false;
+
/**
* @param RouterListInterface $routerList
* @param ResponseInterface $response
@@ -72,13 +78,14 @@ public function __construct(
/**
* Perform action and generate response
*
- * @param RequestInterface $request
+ * @param RequestInterface|HttpRequest $request
* @return ResponseInterface|ResultInterface
* @throws \LogicException
*/
public function dispatch(RequestInterface $request)
{
\Magento\Framework\Profiler::start('routers_match');
+ $this->validatedRequest = false;
$routingCycleCounter = 0;
$result = null;
while (!$request->isDispatched() && $routingCycleCounter++ < 100) {
@@ -109,44 +116,56 @@ public function dispatch(RequestInterface $request)
}
/**
- * @param RequestInterface $request
+ * @param HttpRequest $request
* @param ActionInterface $actionInstance
* @throws NotFoundException
*
* @return ResponseInterface|ResultInterface
*/
private function processRequest(
- RequestInterface $request,
+ HttpRequest $request,
ActionInterface $actionInstance
) {
$request->setDispatched(true);
$this->response->setNoCacheHeaders();
- //Validating request.
- try {
- $this->requestValidator->validate(
- $request,
- $actionInstance
- );
+ $result = null;
+
+ //Validating a request only once.
+ if (!$this->validatedRequest) {
+ try {
+ $this->requestValidator->validate(
+ $request,
+ $actionInstance
+ );
+ } catch (InvalidRequestException $exception) {
+ //Validation failed - processing validation results.
+ $this->logger->debug(
+ 'Request validation failed for action "'
+ .get_class($actionInstance) .'"'
+ );
+ $result = $exception->getReplaceResult();
+ if ($messages = $exception->getMessages()) {
+ foreach ($messages as $message) {
+ $this->messages->addErrorMessage($message);
+ }
+ }
+ }
+ $this->validatedRequest = true;
+ }
+ //Validation did not produce a result to replace the action's.
+ if (!$result) {
if ($actionInstance instanceof AbstractAction) {
$result = $actionInstance->dispatch($request);
} else {
$result = $actionInstance->execute();
}
- } catch (InvalidRequestException $exception) {
- //Validation failed - processing validation results.
- $this->logger->debug(
- 'Request validation failed for action "'
- .get_class($actionInstance) .'"'
- );
- $result = $exception->getReplaceResult();
- if ($messages = $exception->getMessages()) {
- foreach ($messages as $message) {
- $this->messages->addErrorMessage($message);
- }
- }
}
+ //handling redirect to 404
+ if ($result instanceof NotFoundException) {
+ throw $result;
+ }
return $result;
}
}
diff --git a/lib/internal/Magento/Framework/App/Request/CompositeValidator.php b/lib/internal/Magento/Framework/App/Request/CompositeValidator.php
new file mode 100644
index 0000000000000..2b5205fddc9c4
--- /dev/null
+++ b/lib/internal/Magento/Framework/App/Request/CompositeValidator.php
@@ -0,0 +1,43 @@
+validators = $validators;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function validate(
+ RequestInterface $request,
+ ActionInterface $action
+ ): void {
+ foreach ($this->validators as $validator) {
+ $validator->validate($request, $action);
+ }
+ }
+}
diff --git a/lib/internal/Magento/Framework/App/Request/Http.php b/lib/internal/Magento/Framework/App/Request/Http.php
index 03a7200fbe203..4e709ed276954 100644
--- a/lib/internal/Magento/Framework/App/Request/Http.php
+++ b/lib/internal/Magento/Framework/App/Request/Http.php
@@ -95,6 +95,11 @@ class Http extends Request implements RequestContentInterface, RequestSafetyInte
*/
private $distroBaseUrl;
+ /**
+ * @var PathInfo
+ */
+ private $pathInfoService;
+
/**
* @param CookieReaderInterface $cookieReader
* @param StringUtils $converter
@@ -103,6 +108,7 @@ class Http extends Request implements RequestContentInterface, RequestSafetyInte
* @param ObjectManagerInterface $objectManager
* @param \Zend\Uri\UriInterface|string|null $uri
* @param array $directFrontNames
+ * @param PathInfo|null $pathInfoService
*/
public function __construct(
CookieReaderInterface $cookieReader,
@@ -111,94 +117,71 @@ public function __construct(
PathInfoProcessorInterface $pathInfoProcessor,
ObjectManagerInterface $objectManager,
$uri = null,
- $directFrontNames = []
+ $directFrontNames = [],
+ PathInfo $pathInfoService = null
) {
parent::__construct($cookieReader, $converter, $uri);
$this->routeConfig = $routeConfig;
$this->pathInfoProcessor = $pathInfoProcessor;
$this->objectManager = $objectManager;
$this->directFrontNames = $directFrontNames;
+ $this->pathInfoService = $pathInfoService ?: \Magento\Framework\App\ObjectManager::getInstance()->get(
+ PathInfo::class
+ );
}
/**
- * Returns ORIGINAL_PATH_INFO.
- * This value is calculated instead of reading PATH_INFO
- * directly from $_SERVER due to cross-platform differences.
+ * Return the ORIGINAL_PATH_INFO.
+ * This value is calculated and processed from $_SERVER due to cross-platform differences.
+ * instead of reading PATH_INFO
*
* @return string
*/
public function getOriginalPathInfo()
{
if (empty($this->originalPathInfo)) {
- $this->setPathInfo();
+ $originalPathInfoFromRequest = $this->pathInfoService->getPathInfo(
+ $this->getRequestUri(),
+ $this->getBaseUrl()
+ );
+ $this->originalPathInfo = (string)$this->pathInfoProcessor->process($this, $originalPathInfoFromRequest);
+ $this->requestString = $this->originalPathInfo
+ . $this->pathInfoService->getQueryString($this->getRequestUri());
}
return $this->originalPathInfo;
}
/**
- * Set the PATH_INFO string
- * Set the ORIGINAL_PATH_INFO string
- *
- * @param string|null $pathInfo
- * @return $this
- */
- public function setPathInfo($pathInfo = null)
- {
- if ($pathInfo === null) {
- $requestUri = $this->getRequestUri();
- if ('/' === $requestUri) {
- return $this;
- }
-
- $requestUri = $this->removeRepeatedSlashes($requestUri);
- $parsedRequestUri = explode('?', $requestUri, 2);
- $queryString = !isset($parsedRequestUri[1]) ? '' : '?' . $parsedRequestUri[1];
- $baseUrl = $this->getBaseUrl();
- $pathInfo = (string)substr($parsedRequestUri[0], (int)strlen($baseUrl));
-
- if ($this->isNoRouteUri($baseUrl, $pathInfo)) {
- $pathInfo = 'noroute';
- }
- $pathInfo = $this->pathInfoProcessor->process($this, $pathInfo);
- $this->originalPathInfo = (string)$pathInfo;
- $this->requestString = $pathInfo . $queryString;
- }
- $this->pathInfo = (string)$pathInfo;
- return $this;
- }
-
- /**
- * Remove repeated slashes from the start of the path.
+ * Return the path info
*
- * @param string $pathInfo
* @return string
*/
- private function removeRepeatedSlashes($pathInfo)
+ public function getPathInfo()
{
- $firstChar = (string)substr($pathInfo, 0, 1);
- if ($firstChar == '/') {
- $pathInfo = '/' . ltrim($pathInfo, '/');
+ if (empty($this->pathInfo)) {
+ $this->pathInfo = $this->getOriginalPathInfo();
}
-
- return $pathInfo;
+ return $this->pathInfo;
}
/**
- * Check is URI should be marked as no route, helps route to 404 URI like `index.phpadmin`.
+ * Set the PATH_INFO string.
+ *
+ * Set the ORIGINAL_PATH_INFO string.
*
- * @param string $baseUrl
- * @param string $pathInfo
- * @return bool
+ * @param string|null $pathInfo
+ * @return $this
*/
- private function isNoRouteUri($baseUrl, $pathInfo)
+ public function setPathInfo($pathInfo = null)
{
- $firstChar = (string)substr($pathInfo, 0, 1);
- return $baseUrl !== '' && !in_array($firstChar, ['/', '']);
+ $this->pathInfo = (string)$pathInfo;
+ return $this;
}
/**
- * Check if code declared as direct access frontend name
- * this mean what this url can be used without store code
+ * Check if code declared as direct access frontend name.
+ *
+ * This means what this url can be used without store code.
*
* @param string $code
* @return bool
@@ -284,8 +267,7 @@ public function getControllerModule()
}
/**
- * Collect properties changed by _forward in protected storage
- * before _forward was called first time.
+ * Collect properties changed by _forward in protected storage before _forward was called first time.
*
* @return $this
*/
@@ -427,6 +409,8 @@ public function getFullActionName($delimiter = '_')
}
/**
+ * Sleep
+ *
* @return array
*/
public function __sleep()
@@ -435,7 +419,7 @@ public function __sleep()
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function isSafeMethod()
{
diff --git a/lib/internal/Magento/Framework/App/Request/HttpMethodMap.php b/lib/internal/Magento/Framework/App/Request/HttpMethodMap.php
new file mode 100644
index 0000000000000..4e7216954b0d4
--- /dev/null
+++ b/lib/internal/Magento/Framework/App/Request/HttpMethodMap.php
@@ -0,0 +1,68 @@
+map = $this->processMap($map);
+ }
+
+ /**
+ * Filter given map.
+ *
+ * @param array $map
+ * @throws \InvalidArgumentException
+ *
+ * @return string[]
+ */
+ private function processMap(array $map): array
+ {
+ $filtered = [];
+ foreach ($map as $method => $interface) {
+ $interface = trim(preg_replace('/^\\\+/', '', $interface));
+ if (!(interface_exists($interface) || class_exists($interface))) {
+ throw new \InvalidArgumentException(
+ "Interface '$interface' does not exist"
+ );
+ }
+ if (!$method) {
+ throw new \InvalidArgumentException('Invalid method given');
+ }
+
+ $filtered[$method] = $interface;
+ }
+
+ return $filtered;
+ }
+
+ /**
+ * Where keys are methods' names and values are interfaces' names.
+ *
+ * @return string[]
+ *
+ * @see \Zend\Http\Request Has list of methods as METHOD_* constants.
+ */
+ public function getMap(): array
+ {
+ return $this->map;
+ }
+}
diff --git a/lib/internal/Magento/Framework/App/Request/HttpMethodValidator.php b/lib/internal/Magento/Framework/App/Request/HttpMethodValidator.php
new file mode 100644
index 0000000000000..d3eb514caad1e
--- /dev/null
+++ b/lib/internal/Magento/Framework/App/Request/HttpMethodValidator.php
@@ -0,0 +1,96 @@
+map = $map;
+ $this->log = $logger;
+ }
+
+ /**
+ * Create exception when invalid HTTP method used.
+ *
+ * @param Http $request
+ * @param ActionInterface $action
+ * @throws InvalidRequestException
+ *
+ * @return void
+ */
+ private function throwException(
+ Http $request,
+ ActionInterface $action
+ ): void {
+ $uri = $request->getRequestUri();
+ $method = $request->getMethod();
+ if ($action instanceof InterceptorInterface) {
+ $actionClass = get_parent_class($action);
+ } else {
+ $actionClass = get_class($action);
+ }
+ $this->log->debug(
+ "URI '$uri'' cannot be accessed with $method method ($actionClass)"
+ );
+
+ throw new InvalidRequestException(
+ new NotFoundException(new Phrase('Page not found.'))
+ );
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function validate(
+ RequestInterface $request,
+ ActionInterface $action
+ ): void {
+ if ($request instanceof Http) {
+ $method = $request->getMethod();
+ $map = $this->map->getMap();
+ //If we don't have an interface for the HTTP method or
+ //the action has HTTP method limitations and doesn't allow the
+ //received one then the request is invalid.
+ if (!array_key_exists($method, $map)
+ || (array_intersect($map, class_implements($action, true))
+ && !$action instanceof $map[$method]
+ )
+ ) {
+ $this->throwException($request, $action);
+ }
+ }
+ }
+}
diff --git a/lib/internal/Magento/Framework/App/Request/InvalidRequestException.php b/lib/internal/Magento/Framework/App/Request/InvalidRequestException.php
index 3d408b0050686..f15ce494e9bb4 100644
--- a/lib/internal/Magento/Framework/App/Request/InvalidRequestException.php
+++ b/lib/internal/Magento/Framework/App/Request/InvalidRequestException.php
@@ -10,6 +10,7 @@
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\Controller\ResultInterface;
+use Magento\Framework\Exception\NotFoundException;
use Magento\Framework\Exception\RuntimeException;
use Magento\Framework\Phrase;
@@ -29,8 +30,9 @@ class InvalidRequestException extends RuntimeException
private $messages;
/**
- * @param ResponseInterface|ResultInterface $replaceResult Use this result
- * instead of calling action instance.
+ * @param ResponseInterface|ResultInterface|NotFoundException $replaceResult
+ * Use this result instead of calling an action instance,
+ * if NotFoundException is given the the default 404 mechanism will be triggered.
* @param Phrase[]|null $messages Messages to show to client
* as error messages.
*/
@@ -43,7 +45,7 @@ public function __construct($replaceResult, ?array $messages = null)
}
/**
- * @return ResponseInterface|ResultInterface
+ * @return ResponseInterface|ResultInterface|NotFoundException
*/
public function getReplaceResult()
{
diff --git a/lib/internal/Magento/Framework/App/Request/PathInfo.php b/lib/internal/Magento/Framework/App/Request/PathInfo.php
new file mode 100644
index 0000000000000..76a12d6aefe98
--- /dev/null
+++ b/lib/internal/Magento/Framework/App/Request/PathInfo.php
@@ -0,0 +1,80 @@
+removeRepeatedSlashes($requestUri);
+ $parsedRequestUri = explode('?', $requestUri, 2);
+ $pathInfo = (string)substr(current($parsedRequestUri), (int)strlen($baseUrl));
+
+ if ($this->isNoRouteUri($baseUrl, $pathInfo)) {
+ $pathInfo = \Magento\Framework\App\Router\Base::NO_ROUTE;
+ }
+ return $pathInfo;
+ }
+
+ /**
+ * Get query string using from the request URI
+ *
+ * @param string $requestUri
+ * @return string
+ */
+ public function getQueryString(string $requestUri) : string
+ {
+ $requestUri = $this->removeRepeatedSlashes($requestUri);
+ $parsedRequestUri = explode('?', $requestUri, 2);
+ $queryString = !isset($parsedRequestUri[1]) ? '' : '?' . $parsedRequestUri[1];
+ return $queryString;
+ }
+
+ /**
+ * Remove repeated slashes from the start of the path.
+ *
+ * @param string $pathInfo
+ * @return string
+ */
+ private function removeRepeatedSlashes($pathInfo) : string
+ {
+ $firstChar = (string)substr($pathInfo, 0, 1);
+ if ($firstChar == '/') {
+ $pathInfo = '/' . ltrim($pathInfo, '/');
+ }
+
+ return $pathInfo;
+ }
+
+ /**
+ * Check is URI should be marked as no route, helps route to 404 URI like `index.phpadmin`.
+ *
+ * @param string $baseUrl
+ * @param string $pathInfo
+ * @return bool
+ */
+ private function isNoRouteUri($baseUrl, $pathInfo) : bool
+ {
+ $firstChar = (string)substr($pathInfo, 0, 1);
+ return $baseUrl !== '' && !in_array($firstChar, ['/', '']);
+ }
+}
diff --git a/lib/internal/Magento/Framework/App/Router/Base.php b/lib/internal/Magento/Framework/App/Router/Base.php
index ed9def8e1cf55..f810adcfd3491 100644
--- a/lib/internal/Magento/Framework/App/Router/Base.php
+++ b/lib/internal/Magento/Framework/App/Router/Base.php
@@ -8,11 +8,18 @@
namespace Magento\Framework\App\Router;
/**
+ * Base router implementation.
+ *
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Base implements \Magento\Framework\App\RouterInterface
{
+ /**
+ * No route constant used for request
+ */
+ const NO_ROUTE = 'noroute';
+
/**
* @var \Magento\Framework\App\ActionFactory
*/
@@ -303,7 +310,7 @@ protected function matchAction(\Magento\Framework\App\RequestInterface $request,
if ($actionInstance === null) {
return null;
}
- $action = 'noroute';
+ $action = self::NO_ROUTE;
}
// set values only after all the checks are done
@@ -333,6 +340,7 @@ public function getActionClassName($module, $actionPath)
/**
* Check that request uses https protocol if it should.
+ *
* Function redirects user to correct URL if needed.
*
* @param \Magento\Framework\App\RequestInterface $request
diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Request/HttpMethodMapTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Request/HttpMethodMapTest.php
new file mode 100644
index 0000000000000..6215da3ae901d
--- /dev/null
+++ b/lib/internal/Magento/Framework/App/Test/Unit/Request/HttpMethodMapTest.php
@@ -0,0 +1,49 @@
+ '\\Throwable', 'method2' => 'DateTime']
+ );
+ $this->assertEquals(
+ ['method1' => \Throwable::class, 'method2' => \DateTime::class],
+ $map->getMap()
+ );
+ }
+
+ /**
+ * Test validation of interface names.
+ *
+ * @expectedException \InvalidArgumentException
+ */
+ public function testExisting()
+ {
+ new HttpMethodMap(['method1' => 'NonExistingClass']);
+ }
+
+ /**
+ * Test validation of method names.
+ *
+ * @expectedException \InvalidArgumentException
+ */
+ public function testMethod()
+ {
+ new HttpMethodMap([\Throwable::class]);
+ }
+}
diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Request/HttpTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Request/HttpTest.php
index 62445d4244fb7..535e74e9a3bdb 100644
--- a/lib/internal/Magento/Framework/App/Test/Unit/Request/HttpTest.php
+++ b/lib/internal/Magento/Framework/App/Test/Unit/Request/HttpTest.php
@@ -10,32 +10,41 @@
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Request\Http;
+/**
+ * @SuppressWarnings(PHPMD.TooManyMethods)
+ * @SuppressWarnings(PHPMD.TooManyPublicMethods)
+ */
class HttpTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \Magento\Framework\App\Request\Http
*/
- protected $_model;
+ private $model;
/**
* @var \Magento\Framework\App\Route\ConfigInterface\Proxy | \PHPUnit_Framework_MockObject_MockObject
*/
- protected $_routerListMock;
+ private $routerListMock;
/**
* @var \Magento\Framework\App\Request\PathInfoProcessorInterface | \PHPUnit_Framework_MockObject_MockObject
*/
- protected $_infoProcessorMock;
+ private $infoProcessorMock;
+
+ /**
+ * @var \Magento\Framework\App\Request\PathInfo
+ */
+ private $pathInfo;
/**
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager | \PHPUnit_Framework_MockObject_MockObject
*/
- protected $objectManagerMock;
+ private $objectManagerMock;
/**
* @var \Magento\Framework\Stdlib\StringUtils | \PHPUnit_Framework_MockObject_MockObject
*/
- protected $converterMock;
+ private $converterMock;
/**
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
@@ -49,12 +58,12 @@ class HttpTest extends \PHPUnit\Framework\TestCase
protected function setUp()
{
- $this->_routerListMock = $this->createPartialMock(
+ $this->routerListMock = $this->createPartialMock(
\Magento\Framework\App\Route\ConfigInterface\Proxy::class,
['getRouteFrontName', 'getRouteByFrontName', '__wakeup']
);
- $this->_infoProcessorMock = $this->createMock(\Magento\Framework\App\Request\PathInfoProcessorInterface::class);
- $this->_infoProcessorMock->expects($this->any())->method('process')->will($this->returnArgument(1));
+ $this->infoProcessorMock = $this->createMock(\Magento\Framework\App\Request\PathInfoProcessorInterface::class);
+ $this->infoProcessorMock->expects($this->any())->method('process')->will($this->returnArgument(1));
$this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
$this->converterMock = $this->getMockBuilder(\Magento\Framework\Stdlib\StringUtils::class)
->disableOriginalConstructor()
@@ -66,6 +75,7 @@ protected function setUp()
$this->serverArray = $_SERVER;
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $this->pathInfo = $this->objectManager->getObject(\Magento\Framework\App\Request\PathInfo::class);
}
public function tearDown()
@@ -81,8 +91,9 @@ private function getModel($uri = null, $appConfigMock = true)
$model = $this->objectManager->getObject(
\Magento\Framework\App\Request\Http::class,
[
- 'routeConfig' => $this->_routerListMock,
- 'pathInfoProcessor' => $this->_infoProcessorMock,
+ 'routeConfig' => $this->routerListMock,
+ 'pathInfoProcessor' => $this->infoProcessorMock,
+ 'pathInfoService' => $this->pathInfo,
'objectManager' => $this->objectManagerMock,
'converter' => $this->converterMock,
'uri' => $uri,
@@ -100,91 +111,91 @@ private function getModel($uri = null, $appConfigMock = true)
public function testGetOriginalPathInfoWithTestUri()
{
$uri = 'http://test.com/value?key=value';
- $this->_model = $this->getModel($uri);
- $this->assertEquals('/value', $this->_model->getOriginalPathInfo());
+ $this->model = $this->getModel($uri);
+ $this->assertEquals('/value', $this->model->getOriginalPathInfo());
}
public function testGetOriginalPathInfoWithEmptyUri()
{
- $this->_model = $this->getModel();
- $this->assertEmpty($this->_model->getOriginalPathInfo());
+ $this->model = $this->getModel();
+ $this->assertEmpty($this->model->getOriginalPathInfo());
}
public function testGetBasePathWithPath()
{
- $this->_model = $this->getModel();
- $this->_model->setBasePath('http:\/test.com\one/two');
- $this->assertEquals('http://test.com/one/two', $this->_model->getBasePath());
+ $this->model = $this->getModel();
+ $this->model->setBasePath('http:\/test.com\one/two');
+ $this->assertEquals('http://test.com/one/two', $this->model->getBasePath());
}
public function testGetBasePathWithoutPath()
{
- $this->_model = $this->getModel();
- $this->_model->setBasePath(null);
- $this->assertEquals('/', $this->_model->getBasePath());
+ $this->model = $this->getModel();
+ $this->model->setBasePath(null);
+ $this->assertEquals('/', $this->model->getBasePath());
}
public function testSetRouteNameWithRouter()
{
$router = $this->createMock(\Magento\Framework\App\Route\ConfigInterface::class);
- $this->_routerListMock->expects($this->any())->method('getRouteFrontName')->will($this->returnValue($router));
- $this->_model = $this->getModel();
- $this->_model->setRouteName('RouterName');
- $this->assertEquals('RouterName', $this->_model->getRouteName());
+ $this->routerListMock->expects($this->any())->method('getRouteFrontName')->will($this->returnValue($router));
+ $this->model = $this->getModel();
+ $this->model->setRouteName('RouterName');
+ $this->assertEquals('RouterName', $this->model->getRouteName());
}
public function testSetRouteNameWithNullRouterValue()
{
- $this->_model = $this->getModel();
- $this->_routerListMock->expects($this->once())->method('getRouteFrontName')->will($this->returnValue(null));
- $this->_model->setRouteName('RouterName');
+ $this->model = $this->getModel();
+ $this->routerListMock->expects($this->once())->method('getRouteFrontName')->will($this->returnValue(null));
+ $this->model->setRouteName('RouterName');
}
public function testGetFrontName()
{
$uri = 'http://test.com/one/two';
- $this->_model = $this->getModel($uri);
- $this->assertEquals('one', $this->_model->getFrontName());
+ $this->model = $this->getModel($uri);
+ $this->assertEquals('one', $this->model->getFrontName());
}
public function testGetRouteNameWithNullValueRouteName()
{
- $this->_model = $this->getModel();
- $this->_model->setRouteName('RouteName');
- $this->assertEquals('RouteName', $this->_model->getRouteName());
+ $this->model = $this->getModel();
+ $this->model->setRouteName('RouteName');
+ $this->assertEquals('RouteName', $this->model->getRouteName());
}
public function testGetRouteName()
{
- $this->_model = $this->getModel();
+ $this->model = $this->getModel();
$expected = 'RouteName';
- $this->_model->setRouteName($expected);
- $this->assertEquals($expected, $this->_model->getRouteName());
+ $this->model->setRouteName($expected);
+ $this->assertEquals($expected, $this->model->getRouteName());
}
public function testGetFullActionName()
{
- $this->_model = $this->getModel();
+ $this->model = $this->getModel();
/* empty request */
- $this->assertEquals('__', $this->_model->getFullActionName());
- $this->_model->setRouteName('test')->setControllerName('controller')->setActionName('action');
- $this->assertEquals('test/controller/action', $this->_model->getFullActionName('/'));
+ $this->assertEquals('__', $this->model->getFullActionName());
+ $this->model->setRouteName('test')->setControllerName('controller')->setActionName('action');
+ $this->assertEquals('test/controller/action', $this->model->getFullActionName('/'));
}
public function testInitForward()
{
- $expected = $this->_initForward();
- $this->assertEquals($expected, $this->_model->getBeforeForwardInfo());
+ $expected = $this->initForward();
+ $this->assertEquals($expected, $this->model->getBeforeForwardInfo());
}
public function testGetBeforeForwardInfo()
{
- $beforeForwardInfo = $this->_initForward();
- $this->assertNull($this->_model->getBeforeForwardInfo('not_existing_forward_info_key'));
+ $beforeForwardInfo = $this->initForward();
+ $this->assertNull($this->model->getBeforeForwardInfo('not_existing_forward_info_key'));
foreach (array_keys($beforeForwardInfo) as $key) {
- $this->assertEquals($beforeForwardInfo[$key], $this->_model->getBeforeForwardInfo($key));
+ $this->assertEquals($beforeForwardInfo[$key], $this->model->getBeforeForwardInfo($key));
}
- $this->assertEquals($beforeForwardInfo, $this->_model->getBeforeForwardInfo());
+ $this->assertEquals($beforeForwardInfo, $this->model->getBeforeForwardInfo());
}
/**
@@ -192,9 +203,9 @@ public function testGetBeforeForwardInfo()
*
* @return array Contents of $_beforeForwardInfo
*/
- protected function _initForward()
+ private function initForward()
{
- $this->_model = $this->getModel();
+ $this->model = $this->getModel();
$beforeForwardInfo = [
'params' => ['one' => '111', 'two' => '222'],
'action_name' => 'ActionName',
@@ -202,36 +213,36 @@ protected function _initForward()
'module_name' => 'ModuleName',
'route_name' => 'RouteName'
];
- $this->_model->setParams($beforeForwardInfo['params']);
- $this->_model->setActionName($beforeForwardInfo['action_name']);
- $this->_model->setControllerName($beforeForwardInfo['controller_name']);
- $this->_model->setModuleName($beforeForwardInfo['module_name']);
- $this->_model->setRouteName($beforeForwardInfo['route_name']);
- $this->_model->initForward();
+ $this->model->setParams($beforeForwardInfo['params']);
+ $this->model->setActionName($beforeForwardInfo['action_name']);
+ $this->model->setControllerName($beforeForwardInfo['controller_name']);
+ $this->model->setModuleName($beforeForwardInfo['module_name']);
+ $this->model->setRouteName($beforeForwardInfo['route_name']);
+ $this->model->initForward();
return $beforeForwardInfo;
}
public function testIsAjax()
{
- $this->_model = $this->getModel();
+ $this->model = $this->getModel();
- $this->assertFalse($this->_model->isAjax());
+ $this->assertFalse($this->model->isAjax());
- $this->_model->clearParams();
- $this->_model->setParam('ajax', 1);
- $this->assertTrue($this->_model->isAjax());
+ $this->model->clearParams();
+ $this->model->setParam('ajax', 1);
+ $this->assertTrue($this->model->isAjax());
- $this->_model->clearParams();
- $this->_model->setParam('isAjax', 1);
- $this->assertTrue($this->_model->isAjax());
+ $this->model->clearParams();
+ $this->model->setParam('isAjax', 1);
+ $this->assertTrue($this->model->isAjax());
- $this->_model->clearParams();
- $this->_model->getHeaders()->addHeaderLine('X-Requested-With', 'XMLHttpRequest');
- $this->assertTrue($this->_model->isAjax());
+ $this->model->clearParams();
+ $this->model->getHeaders()->addHeaderLine('X-Requested-With', 'XMLHttpRequest');
+ $this->assertTrue($this->model->isAjax());
- $this->_model->getHeaders()->clearHeaders();
- $this->_model->getHeaders()->addHeaderLine('X-Requested-With', 'NotXMLHttpRequest');
- $this->assertFalse($this->_model->isAjax());
+ $this->model->getHeaders()->clearHeaders();
+ $this->model->getHeaders()->addHeaderLine('X-Requested-With', 'NotXMLHttpRequest');
+ $this->assertFalse($this->model->isAjax());
}
/**
@@ -243,8 +254,8 @@ public function testGetDistroBaseUrl($serverVariables, $expectedResult)
{
$originalServerValue = $_SERVER;
$_SERVER = $serverVariables;
- $this->_model = $this->getModel();
- $this->assertEquals($expectedResult, $this->_model->getDistroBaseUrl());
+ $this->model = $this->getModel();
+ $this->assertEquals($expectedResult, $this->model->getDistroBaseUrl());
$_SERVER = $originalServerValue;
}
@@ -338,7 +349,7 @@ public function serverVariablesProvider()
*/
public function testIsSecure($isSecure, $serverHttps, $headerOffloadKey, $headerOffloadValue, $configCall)
{
- $this->_model = $this->getModel(null, false);
+ $this->model = $this->getModel(null, false);
$configOffloadHeader = 'Header-From-Proxy';
$configMock = $this->getMockBuilder(\Magento\Framework\App\Config::class)
->disableOriginalConstructor()
@@ -351,13 +362,13 @@ public function testIsSecure($isSecure, $serverHttps, $headerOffloadKey, $header
ScopeConfigInterface::SCOPE_TYPE_DEFAULT
)->willReturn($configOffloadHeader);
- $this->objectManager->setBackwardCompatibleProperty($this->_model, 'appConfig', $configMock);
- $this->objectManager->setBackwardCompatibleProperty($this->_model, 'sslOffloadHeader', null);
+ $this->objectManager->setBackwardCompatibleProperty($this->model, 'appConfig', $configMock);
+ $this->objectManager->setBackwardCompatibleProperty($this->model, 'sslOffloadHeader', null);
- $this->_model->getServer()->set($headerOffloadKey, $headerOffloadValue);
- $this->_model->getServer()->set('HTTPS', $serverHttps);
+ $this->model->getServer()->set($headerOffloadKey, $headerOffloadValue);
+ $this->model->getServer()->set('HTTPS', $serverHttps);
- $this->assertSame($isSecure, $this->_model->isSecure());
+ $this->assertSame($isSecure, $this->model->isSecure());
}
/**
@@ -367,9 +378,9 @@ public function testIsSecure($isSecure, $serverHttps, $headerOffloadKey, $header
*/
public function testIsSafeMethodTrue($httpMethod)
{
- $this->_model = $this->getModel();
+ $this->model = $this->getModel();
$_SERVER['REQUEST_METHOD'] = $httpMethod;
- $this->assertEquals(true, $this->_model->isSafeMethod());
+ $this->assertEquals(true, $this->model->isSafeMethod());
}
/**
@@ -379,9 +390,9 @@ public function testIsSafeMethodTrue($httpMethod)
*/
public function testIsSafeMethodFalse($httpMethod)
{
- $this->_model = $this->getModel();
+ $this->model = $this->getModel();
$_SERVER['REQUEST_METHOD'] = $httpMethod;
- $this->assertEquals(false, $this->_model->isSafeMethod());
+ $this->assertEquals(false, $this->model->isSafeMethod());
}
/**
@@ -449,12 +460,25 @@ public function isSecureDataProvider()
* @param string $basePath$
* @param string $expected
*/
- public function testSetPathInfo($requestUri, $basePath, $expected)
+ public function testGetPathInfo($requestUri, $basePath, $expected)
+ {
+ $this->model = $this->getModel($requestUri);
+ $this->model->setBaseUrl($basePath);
+ $this->assertEquals($expected, $this->model->getPathInfo());
+ $this->assertEquals($expected, $this->model->getOriginalPathInfo());
+ }
+
+ public function testSetPathInfo()
{
- $this->_model = $this->getModel($requestUri);
- $this->_model->setBaseUrl($basePath);
- $this->_model->setPathInfo();
- $this->assertEquals($expected, $this->_model->getPathInfo());
+ $requestUri = 'http://svr.com//module/route/mypage/myproduct?param1=1';
+ $basePath = '/module/route/';
+ $this->model = $this->getModel($requestUri);
+ $this->model->setBaseUrl($basePath);
+ $expected = '/mypage/myproduct';
+ $this->assertEquals($expected, $this->model->getOriginalPathInfo());
+ $this->model->setPathInfo('http://svr.com/something/route?param1=1');
+ $this->assertEquals('http://svr.com/something/route?param1=1', $this->model->getPathInfo());
+ $this->assertEquals($expected, $this->model->getOriginalPathInfo());
}
/**
diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Editor.php b/lib/internal/Magento/Framework/Data/Form/Element/Editor.php
index 39a0479f7540e..c438edf3aa9ac 100644
--- a/lib/internal/Magento/Framework/Data/Form/Element/Editor.php
+++ b/lib/internal/Magento/Framework/Data/Form/Element/Editor.php
@@ -50,6 +50,8 @@ public function __construct(
}
/**
+ * Returns buttons translation
+ *
* @return array
*/
protected function getButtonTranslations()
@@ -64,6 +66,8 @@ protected function getButtonTranslations()
}
/**
+ * Returns JS config
+ *
* @return bool|string
* @throws \InvalidArgumentException
*/
@@ -80,8 +84,9 @@ protected function getJsonConfig()
/**
* Fetch config options from plugin. If $key is passed, return only that option key's value
+ *
* @param string $pluginName
- * @param null $key
+ * @param string|null $key
* @return mixed all options or single option if $key is passed; null if nonexistent
*/
public function getPluginConfigOptions($pluginName, $key = null)
@@ -101,13 +106,15 @@ public function getPluginConfigOptions($pluginName, $key = null)
$pluginOptions = $plugins[$pluginArrIndex]['options'];
if ($key !== null) {
- return isset($pluginOptions[$key]) ? $pluginOptions[$key] : null;
+ return $pluginOptions[$key] ?? null;
} else {
return $pluginOptions;
}
}
/**
+ * Returns element html
+ *
* @return string
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
@@ -200,6 +207,8 @@ public function getElementHtml()
}
/**
+ * Returns theme
+ *
* @return mixed
*/
public function getTheme()
@@ -343,6 +352,8 @@ protected function _checkPluginButtonOptions($pluginOptions)
}
/**
+ * Convert options
+ *
* Convert options by replacing template constructions ( like {{var_name}} )
* with data from this element object
*
@@ -389,6 +400,7 @@ protected function _getButtonHtml($data)
/**
* Wraps Editor HTML into div if 'use_container' config option is set to true
+ *
* If 'no_display' config option is set to true, the div will be invisible
*
* @param string $html HTML code to wrap
@@ -463,6 +475,8 @@ public function isHidden()
}
/**
+ * Is Toggle Button Visible
+ *
* @return bool
*/
protected function isToggleButtonVisible()
diff --git a/lib/internal/Magento/Framework/Filter/Template/Tokenizer/Variable.php b/lib/internal/Magento/Framework/Filter/Template/Tokenizer/Variable.php
index 67c2d17abe208..574ef9faf74a5 100644
--- a/lib/internal/Magento/Framework/Filter/Template/Tokenizer/Variable.php
+++ b/lib/internal/Magento/Framework/Filter/Template/Tokenizer/Variable.php
@@ -313,6 +313,6 @@ public function getNumber()
if (!$this->isNumeric()) {
$this->prev();
}
- return floatval($value);
+ return (float)$value;
}
}
diff --git a/lib/internal/Magento/Framework/GraphQl/Schema/Type/Entity/DefaultMapper.php b/lib/internal/Magento/Framework/GraphQl/Schema/Type/Entity/DefaultMapper.php
index 7e3f2ac6db638..cacc1f9e28c02 100644
--- a/lib/internal/Magento/Framework/GraphQl/Schema/Type/Entity/DefaultMapper.php
+++ b/lib/internal/Magento/Framework/GraphQl/Schema/Type/Entity/DefaultMapper.php
@@ -26,10 +26,10 @@ public function __construct(array $map = [])
}
/**
- * {@inheritDoc}
+ * @inheritdoc
*/
public function getMappedTypes(string $entityName) : array
{
- return isset($this->map[$entityName]) ? $this->map[$entityName] : [];
+ return $this->map[$entityName] ?? [];
}
}
diff --git a/lib/internal/Magento/Framework/GraphQl/Schema/Type/Enum/DefaultDataMapper.php b/lib/internal/Magento/Framework/GraphQl/Schema/Type/Enum/DefaultDataMapper.php
index f7b39ba64207b..f560fcb0de774 100644
--- a/lib/internal/Magento/Framework/GraphQl/Schema/Type/Enum/DefaultDataMapper.php
+++ b/lib/internal/Magento/Framework/GraphQl/Schema/Type/Enum/DefaultDataMapper.php
@@ -26,10 +26,10 @@ public function __construct(array $map)
}
/**
- * {@inheritDoc}
+ * @inheritdoc
*/
public function getMappedEnums(string $enumName) : array
{
- return isset($this->map[$enumName]) ? $this->map[$enumName] : [];
+ return $this->map[$enumName] ?? [];
}
}
diff --git a/lib/internal/Magento/Framework/MessageQueue/Config.php b/lib/internal/Magento/Framework/MessageQueue/Config.php
index e29b5d06bee6c..9a925e1417c12 100644
--- a/lib/internal/Magento/Framework/MessageQueue/Config.php
+++ b/lib/internal/Magento/Framework/MessageQueue/Config.php
@@ -30,18 +30,16 @@ public function __construct(Config\Data $queueConfigData)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getExchangeByTopic($topicName)
{
$publisherConfig = $this->getPublisherConfigByTopic($topicName);
- return isset($publisherConfig[ConfigInterface::PUBLISHER_EXCHANGE])
- ? $publisherConfig[ConfigInterface::PUBLISHER_EXCHANGE]
- : null;
+ return $publisherConfig[ConfigInterface::PUBLISHER_EXCHANGE] ?? null;
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getQueuesByTopic($topic)
{
@@ -67,7 +65,7 @@ public function getQueuesByTopic($topic)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getConnectionByTopic($topic)
{
@@ -76,13 +74,11 @@ public function getConnectionByTopic($topic)
} catch (\Magento\Framework\Exception\LocalizedException $e) {
return null;
}
- return isset($publisherConfig[ConfigInterface::PUBLISHER_CONNECTION])
- ? $publisherConfig[ConfigInterface::PUBLISHER_CONNECTION]
- : null;
+ return $publisherConfig[ConfigInterface::PUBLISHER_CONNECTION] ?? null;
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getConnectionByConsumer($consumer)
{
@@ -98,7 +94,7 @@ public function getConnectionByConsumer($consumer)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getMessageSchemaType($topic)
{
@@ -109,7 +105,7 @@ public function getMessageSchemaType($topic)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getConsumerNames()
{
@@ -118,7 +114,7 @@ public function getConsumerNames()
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getConsumer($name)
{
@@ -127,7 +123,7 @@ public function getConsumer($name)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getBinds()
{
@@ -135,7 +131,7 @@ public function getBinds()
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getPublishers()
{
@@ -143,7 +139,7 @@ public function getPublishers()
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getConsumers()
{
@@ -151,7 +147,7 @@ public function getConsumers()
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getTopic($name)
{
@@ -159,7 +155,7 @@ public function getTopic($name)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getPublisher($name)
{
@@ -167,7 +163,7 @@ public function getPublisher($name)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getResponseQueueName($topicName)
{
diff --git a/lib/internal/Magento/Framework/MessageQueue/Consumer/Config/Env/Reader.php b/lib/internal/Magento/Framework/MessageQueue/Consumer/Config/Env/Reader.php
index aa318ba5f19cf..a75aa1ea8ead2 100644
--- a/lib/internal/Magento/Framework/MessageQueue/Consumer/Config/Env/Reader.php
+++ b/lib/internal/Magento/Framework/MessageQueue/Consumer/Config/Env/Reader.php
@@ -33,8 +33,6 @@ public function __construct(\Magento\Framework\MessageQueue\Config\Reader\Env $e
public function read($scope = null)
{
$configData = $this->envConfig->read($scope);
- return isset($configData[\Magento\Framework\MessageQueue\Config\Reader\Env::ENV_CONSUMERS])
- ? $configData[\Magento\Framework\MessageQueue\Config\Reader\Env::ENV_CONSUMERS]
- : [];
+ return $configData[\Magento\Framework\MessageQueue\Config\Reader\Env::ENV_CONSUMERS] ?? [];
}
}
diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Real.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Real.php
index cdb740ea0a92d..e0728b9a34fee 100644
--- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Real.php
+++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Factories/Real.php
@@ -39,7 +39,7 @@ class Real implements FactoryInterface
* Constructor.
*
* @param ObjectManagerInterface $objectManager
- * @param string $className
+ * @param string $className
*/
public function __construct(
ObjectManagerInterface $objectManager,
@@ -50,7 +50,7 @@ public function __construct(
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function create(array $data)
{
@@ -63,7 +63,7 @@ public function create(array $data)
}
if (isset($data['default'])) {
- $data['default'] = floatval($data['default']);
+ $data['default'] = (float)$data['default'];
}
return $this->objectManager->create($this->className, $data);
diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Schema.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Schema.php
index 3e68b985283cf..fbbe188d127ae 100644
--- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Schema.php
+++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Schema.php
@@ -63,14 +63,15 @@ public function addTable(Table $table)
/**
* Retrieve table by it name.
+ *
* Return false if table is not present in schema.
*
- * @param $name
+ * @param string $name
* @return bool|Table
*/
public function getTableByName($name)
{
$name = $this->resourceConnection->getTableName($name);
- return isset($this->tables[$name]) ? $this->tables[$name] : false;
+ return $this->tables[$name] ?? false;
}
}
diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Table.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Table.php
index 4f020b1a0320f..b4e1e978ea674 100644
--- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Table.php
+++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Dto/Table.php
@@ -87,11 +87,11 @@ class Table extends GenericElement implements
* @param string $engine
* @param string $charset
* @param string $collation
+ * @param string $onCreate
* @param string|null $comment
* @param array $columns
* @param array $indexes
* @param array $constraints
- * @param string $onCreate
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
@@ -123,6 +123,7 @@ public function __construct(
/**
* Return different table constraints.
+ *
* It can be constraint like unique key or reference to another table, etc
*
* @return Constraint[]
@@ -133,12 +134,14 @@ public function getConstraints()
}
/**
+ * Returns constraint by name
+ *
* @param string $name
* @return Constraint | bool
*/
public function getConstraintByName($name)
{
- return isset($this->constraints[$name]) ? $this->constraints[$name] : false;
+ return $this->constraints[$name] ?? false;
}
/**
@@ -160,6 +163,8 @@ public function getReferenceConstraints()
}
/**
+ * Returns primary constraint
+ *
* As primary constraint always have one name
* and can be only one for table
* it name is allocated into it constraint
@@ -168,9 +173,7 @@ public function getReferenceConstraints()
*/
public function getPrimaryConstraint()
{
- return isset($this->constraints[Internal::PRIMARY_NAME]) ?
- $this->constraints[Internal::PRIMARY_NAME] :
- false;
+ return $this->constraints[Internal::PRIMARY_NAME] ?? false;
}
/**
@@ -191,16 +194,19 @@ public function getInternalConstraints() : array
}
/**
+ * Returns index by name
+ *
* @param string $name
* @return Index | bool
*/
public function getIndexByName($name)
{
- return isset($this->indexes[$name]) ? $this->indexes[$name] : false;
+ return $this->indexes[$name] ?? false;
}
/**
* Return all columns.
+ *
* Note, table always must have columns
*
* @return Column[]
@@ -231,6 +237,8 @@ public function getResource()
}
/**
+ * Add constraints
+ *
* This is workaround, as any DTO object couldnt be changed after instantiation.
* However there is case, when we have 2 tables with constraints in different tables,
* that depends to each other table. So we need to setup DTO first and only then pass
@@ -280,6 +288,7 @@ public function getColumnByName($nameOrId)
/**
* Retrieve elements by specific type
+ *
* Allowed types: columns, constraints, indexes...
*
* @param string $type
@@ -295,6 +304,8 @@ public function getElementsByType($type)
}
/**
+ * Add indexes
+ *
* This is workaround, as any DTO object couldnt be changed after instantiation.
* However there is case, when we depends on column definition we need modify our indexes
*
@@ -314,6 +325,8 @@ public function getElementType()
}
/**
+ * Returns engine name
+ *
* @return string
*/
public function getEngine(): string
@@ -356,6 +369,8 @@ public function getCollation() : string
}
/**
+ * Returns name without prefix
+ *
* @return string
*/
public function getNameWithoutPrefix(): string
@@ -364,6 +379,8 @@ public function getNameWithoutPrefix(): string
}
/**
+ * Returns comment
+ *
* @return null|string
*/
public function getComment()
diff --git a/lib/web/images/logo.svg b/lib/web/images/logo.svg
index 013d6e7c5a107..e4f627809b627 100644
--- a/lib/web/images/logo.svg
+++ b/lib/web/images/logo.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
diff --git a/lib/web/images/magento-logo.svg b/lib/web/images/magento-logo.svg
index 0d5cc0e6233d6..e4f627809b627 100644
--- a/lib/web/images/magento-logo.svg
+++ b/lib/web/images/magento-logo.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
diff --git a/lib/web/mage/adminhtml/tools.js b/lib/web/mage/adminhtml/tools.js
index ed4bab7102ae5..27f6efcfc5876 100644
--- a/lib/web/mage/adminhtml/tools.js
+++ b/lib/web/mage/adminhtml/tools.js
@@ -348,7 +348,7 @@ var Fieldset = {
},
saveState: function (url, parameters) {
new Ajax.Request(url, {
- method: 'get',
+ method: 'post',
parameters: Object.toQueryString(parameters),
loaderArea: false
});
diff --git a/pub/errors/default/images/logo.gif b/pub/errors/default/images/logo.gif
index f1f7fcaf4f020..0cca183e08da2 100644
Binary files a/pub/errors/default/images/logo.gif and b/pub/errors/default/images/logo.gif differ
diff --git a/setup/performance-toolkit/benchmark.jmx b/setup/performance-toolkit/benchmark.jmx
index 7e9ed5377f154..3b74af8a111d6 100644
--- a/setup/performance-toolkit/benchmark.jmx
+++ b/setup/performance-toolkit/benchmark.jmx
@@ -4940,7 +4940,7 @@ vars.put("totalProductsAdded", String.valueOf(productsAdded));
- You added ${product_name} to your shopping cart.
+ You added ${product_name} to your shopping cart.
Assertion.response_data
false
@@ -5306,7 +5306,7 @@ vars.put("totalProductsAdded", String.valueOf(productsAdded));
- You added ${product_name} to your shopping cart.
+ You added ${product_name} to your shopping cart.
Assertion.response_data
false
@@ -6821,7 +6821,7 @@ vars.put("totalProductsAdded", String.valueOf(productsAdded));
- You added ${product_name} to your shopping cart.
+ You added ${product_name} to your shopping cart.
Assertion.response_data
false
@@ -7187,7 +7187,7 @@ vars.put("totalProductsAdded", String.valueOf(productsAdded));
- You added ${product_name} to your shopping cart.
+ You added ${product_name} to your shopping cart.
Assertion.response_data
false
@@ -8139,7 +8139,7 @@ vars.put("totalProductsAdded", String.valueOf(productsAdded));
- You added ${product_name} to your shopping cart.
+ You added ${product_name} to your shopping cart.
Assertion.response_data
false
@@ -8505,7 +8505,7 @@ vars.put("totalProductsAdded", String.valueOf(productsAdded));
- You added ${product_name} to your shopping cart.
+ You added ${product_name} to your shopping cart.
Assertion.response_data
false
@@ -9963,7 +9963,7 @@ vars.put("totalProductsAdded", String.valueOf(productsAdded));
- You added ${product_name} to your shopping cart.
+ You added ${product_name} to your shopping cart.
Assertion.response_data
false
@@ -10329,7 +10329,7 @@ vars.put("totalProductsAdded", String.valueOf(productsAdded));
- You added ${product_name} to your shopping cart.
+ You added ${product_name} to your shopping cart.
Assertion.response_data
false
@@ -32071,7 +32071,15 @@ vars.put("new_parent_category_id", props.get("admin_category_ids_list").get(cate
-
+
+
+ true
+ ${admin_form_key}
+ =
+ true
+ form_key
+
+
@@ -32080,7 +32088,7 @@ vars.put("new_parent_category_id", props.get("admin_category_ids_list").get(cate
${request_protocol}
${base_path}${admin_path}/catalog/category/delete/id/${admin_category_id}/
- GET
+ POST
true
false
true
diff --git a/setup/pub/images/magento-logo.svg b/setup/pub/images/magento-logo.svg
index 6dcc79d33b294..e4f627809b627 100644
--- a/setup/pub/images/magento-logo.svg
+++ b/setup/pub/images/magento-logo.svg
@@ -1,18 +1 @@
-
-
-
-
+