Skip to content

Commit

Permalink
🔃 [Magento Community Engineering] Community Contributions - 2.3-develop
Browse files Browse the repository at this point in the history
Accepted Community Pull Requests:
 - #25382: [GiftMessage] Covering the SalesEventOrderToQuoteObserver by Unit Test (by @eduard13)
 - #25393: fix additional product options tooltip visibility (by @torhoehn)
 - #25368: View details toggle arrow not in single line for config product check� (by @cedarvinda)
 - #25357: Fixed Magento installation with MySQL 8. (by @akaplya)


Fixed GitHub Issues:
 - #25392: Product Additional Options Tooltip not fully visible (reported by @torhoehn) has been fixed in #25393 by @torhoehn in 2.3-develop branch
   Related commits:
     1. 3b795b9

 - #25366: View details toggle arrow not in single line for config product checkout page > minicart (reported by @cedarvinda) has been fixed in #25368 by @cedarvinda in 2.3-develop branch
   Related commits:
     1. d9e525a
     2. fddc005
     3. 6f5387c

 - #25294: Unable to apply data patch Magento\CatalogSearch\Setup\Patch\Data\SetInitialSearchWeightForAttributes for module Magento_CatalogSearch. (reported by @TomashKhamlai) has been fixed in #25357 by @akaplya in 2.3-develop branch
   Related commits:
     1. c4c36dc
     2. 9f13b47
     3. 417b1d5
     4. 72098ed
     5. a70d66b
  • Loading branch information
magento-engcom-team authored Nov 7, 2019
2 parents 5947b35 + 042c25c commit 7324325
Show file tree
Hide file tree
Showing 24 changed files with 775 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,17 @@
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity(x, '4')}}" userInput="2" stepKey="fillQuantity5" after="fillQuantity4"/>
<fillField selector="{{AdminProductFormBundleSection.bundleOptionXProductYQuantity(x, '5')}}" userInput="2" stepKey="fillQuantity6" after="fillQuantity5"/>
</actionGroup>

<actionGroup name="deleteBundleOptionByIndex">
<annotations>
<description>Requires Navigation to Product Creation page. Removes any Bundle Option by index specified in arguments. 'deleteIndex' refers to Bundle option number.</description>
</annotations>
<arguments>
<argument name="deleteIndex" type="string"/>
</arguments>

<conditionalClick selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" dependentSelector="{{AdminProductFormBundleSection.bundleItemsToggle}}" visible="false" stepKey="conditionallyOpenSectionBundleItems"/>
<scrollTo selector="{{AdminProductFormBundleSection.bundleItemsToggle}}" stepKey="scrollUpABit"/>
<click selector="{{AdminProductFormBundleSection.deleteOption(deleteIndex)}}" stepKey="clickDeleteOption"/>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
<element name="currentBundleOption" type="text" selector="//div[@data-index='bundle-items']//div[contains(@class, 'admin__collapsible-title')]/span"/>
<!--AddingAnOption-->
<element name="addOptions" type="button" selector="//tr[@data-repeat-index='0']//td[4]" timeout="30"/>
<!--DragAnOption -->
<element name="dragOption" type="block" selector="//tr[{{dragIndex}}]//div[contains(@class, 'draggable-handle')]" timeout="30" parameterized="true"/>
<!--DeleteAnOption -->
<element name="deleteOption" type="button" selector="//tr[{{deleteIndex}}]//button[@data-index='delete_button']" timeout="30" parameterized="true"/>
<!--SEODropdownTab-->
<element name="seoDropdown" type="button" selector="//div[@data-index='search-engine-optimization']"/>
<element name="seoDependent" type="button" selector="//div[@data-index='search-engine-optimization']//div[contains(@class, '_show')]"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,116 @@
<argument name="websiteName" value="$createWebsite.website[name]$"/>
</actionGroup>
</test>
<test name="AdminCreateAndEditBundleProductOptionsNegativeTest">
<annotations>
<features value="Bundle"/>
<stories value="Modify bundle product in Admin"/>
<title value="Admin should be able to remove any bundle option a bundle product"/>
<description value="Admin should be able to set/edit other product information when creating/editing a bundle product"/>
<severity value="MAJOR"/>
<testCaseId value="MC-224"/>
<skip>
<issueId value="https://github.com/magento/magento2/issues/25468"/>
</skip>
<group value="Catalog"/>
</annotations>
<before>
<!-- Create a Website -->
<createData entity="customWebsite" stepKey="createWebsite"/>

<!-- Create first simple product for a bundle option -->
<createData entity="SimpleProduct2" stepKey="createFirstSimpleProduct"/>

<!-- Create second simple product for a bundle option -->
<createData entity="SimpleProduct2" stepKey="createSecondSimpleProduct"/>

<!-- Login as admin -->
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
</before>
<after>
<!-- Delete the simple product -->
<deleteData createDataKey="createFirstSimpleProduct" stepKey="deleteFirstSimpleProduct"/>

<!-- Delete the simple product -->
<deleteData createDataKey="createSecondSimpleProduct" stepKey="deleteSecondSimpleProduct"/>

<!-- Delete a Website -->
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteWebsite">
<argument name="websiteName" value="Second Website"/>
</actionGroup>

<!-- Log out -->
<actionGroup ref="logout" stepKey="logout"/>
</after>

<!-- Create new bundle product -->
<actionGroup ref="GoToSpecifiedCreateProductPage" stepKey="createBundleProduct">
<argument name="productType" value="bundle"/>
</actionGroup>

<!-- Fill all main fields -->
<actionGroup ref="fillMainBundleProductForm" stepKey="fillMainProductFields"/>

<!-- Add first bundle option to the product -->
<actionGroup ref="addBundleOptionWithTwoProducts" stepKey="addFirstBundleOption">
<argument name="x" value="0"/>
<argument name="n" value="1"/>
<argument name="prodOneSku" value="$$createFirstSimpleProduct.sku$$"/>
<argument name="prodTwoSku" value="$$createSecondSimpleProduct.sku$$"/>
<argument name="optionTitle" value="{{RadioButtonsOption.title}}"/>
<argument name="inputType" value="{{RadioButtonsOption.type}}"/>
</actionGroup>

<!-- Add second bundle option to the product -->
<actionGroup ref="addBundleOptionWithTwoProducts" stepKey="addSecondBundleOption">
<argument name="x" value="1"/>
<argument name="n" value="2"/>
<argument name="prodOneSku" value="$$createFirstSimpleProduct.sku$$"/>
<argument name="prodTwoSku" value="$$createSecondSimpleProduct.sku$$"/>
<argument name="optionTitle" value="{{CheckboxOption.title}}"/>
<argument name="inputType" value="{{CheckboxOption.type}}"/>
</actionGroup>

<!-- Add third bundle option to the product -->
<actionGroup ref="addBundleOptionWithTwoProducts" stepKey="addThirdBundleOption">
<argument name="x" value="2"/>
<argument name="n" value="3"/>
<argument name="prodOneSku" value="$$createFirstSimpleProduct.sku$$"/>
<argument name="prodTwoSku" value="$$createSecondSimpleProduct.sku$$"/>
<argument name="optionTitle" value="{{RadioButtonsOption.title}}"/>
<argument name="inputType" value="{{RadioButtonsOption.type}}"/>
</actionGroup>

<!-- Set product in created Website -->
<actionGroup ref="AdminAssignProductInWebsiteActionGroup" stepKey="selectProductInWebsites">
<argument name="website" value="$createWebsite.website[name]$"/>
</actionGroup>

<!-- Save product form -->
<actionGroup ref="saveProductForm" stepKey="saveWithThreeOptions"/>

<!-- Open created product -->
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSimpleProduct">
<argument name="product" value="BundleProduct"/>
</actionGroup>
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProduct">
<argument name="product" value="BundleProduct"/>
</actionGroup>

<!-- Remove second option -->
<actionGroup ref="deleteBundleOptionByIndex" stepKey="deleteSecondOption">
<argument name="deleteIndex" value="1"/>
</actionGroup>

<!-- Save product form -->
<actionGroup ref="saveProductForm" stepKey="clickSaveProduct"/>
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveWithTwoOptions"/>
<seeElement selector="{{AdminCategoryMessagesSection.SuccessMessage}}" stepKey="messageYouSavedTheProductIsShown"/>

<!-- Delete created bundle product -->
<actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteProduct">
<argument name="product" value="BundleProduct"/>
</actionGroup>
</test>
</tests>

Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@

namespace Magento\CatalogSearch\Setup\Patch\Data;

use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
use Magento\Framework\App\State;
use Magento\Framework\Indexer\IndexerInterfaceFactory;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
use Magento\Framework\Indexer\IndexerInterfaceFactory;
use Magento\Catalog\Api\ProductAttributeRepositoryInterface;

/**
* This patch sets up search weight for the product's system attributes, reindex required after patch applying.
*
* @deprecated
* @see \Magento\ElasticSearch
*/
class SetInitialSearchWeightForAttributes implements DataPatchInterface, PatchVersionInterface
{

/**
* @var IndexerInterfaceFactory
*/
Expand Down Expand Up @@ -50,7 +53,7 @@ public function __construct(
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function apply()
{
Expand All @@ -60,29 +63,31 @@ public function apply()
$this->state->emulateAreaCode(
\Magento\Framework\App\Area::AREA_CRONTAB,
function () use ($indexer) {
$indexer->reindexAll();
$indexer->getState()
->setStatus(\Magento\Framework\Indexer\StateInterface::STATUS_INVALID)
->save();
}
);
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public static function getDependencies()
{
return [];
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public static function getVersion()
{
return '2.0.0';
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getAliases()
{
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/Checkout/Model/DefaultConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@ private function getQuoteData()
if ($this->checkoutSession->getQuote()->getId()) {
$quote = $this->quoteRepository->get($this->checkoutSession->getQuote()->getId());
$quoteData = $quote->toArray();
if (null !== $quote->getExtensionAttributes()) {
$quoteData['extension_attributes'] = $quote->getExtensionAttributes()->__toArray();
}
$quoteData['is_virtual'] = $quote->getIsVirtual();

if (!$quote->getCustomer()->getId()) {
Expand Down
43 changes: 28 additions & 15 deletions app/code/Magento/Checkout/Model/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Quote\Api\Data\CartInterface;
use Magento\Quote\Model\Quote;
use Magento\Quote\Model\QuoteIdMaskFactory;
use Psr\Log\LoggerInterface;
Expand All @@ -21,9 +23,6 @@
*/
class Session extends \Magento\Framework\Session\SessionManager
{
/**
* Checkout state begin
*/
const CHECKOUT_STATE_BEGIN = 'begin';

/**
Expand Down Expand Up @@ -228,7 +227,7 @@ public function setLoadInactive($load = true)
*
* @return Quote
* @throws \Magento\Framework\Exception\LocalizedException
* @throws \Magento\Framework\Exception\NoSuchEntityException
* @throws NoSuchEntityException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
Expand Down Expand Up @@ -273,21 +272,17 @@ public function getQuote()
*/
$quote = $this->quoteRepository->get($this->getQuoteId());
}
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
} catch (NoSuchEntityException $e) {
$this->setQuoteId(null);
}
}

if (!$this->getQuoteId()) {
if ($this->_customerSession->isLoggedIn() || $this->_customer) {
$customerId = $this->_customer
? $this->_customer->getId()
: $this->_customerSession->getCustomerId();
try {
$quote = $this->quoteRepository->getActiveForCustomer($customerId);
$this->setQuoteId($quote->getId());
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
$this->logger->critical($e);
$quoteByCustomer = $this->getQuoteByCustomer();
if ($quoteByCustomer !== null) {
$this->setQuoteId($quoteByCustomer->getId());
$quote = $quoteByCustomer;
}
} else {
$quote->setIsCheckoutCart(true);
Expand Down Expand Up @@ -375,7 +370,7 @@ public function loadCustomerQuote()

try {
$customerQuote = $this->quoteRepository->getForCustomer($this->_customerSession->getCustomerId());
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
} catch (NoSuchEntityException $e) {
$customerQuote = $this->quoteFactory->create();
}
$customerQuote->setStoreId($this->_storeManager->getStore()->getId());
Expand Down Expand Up @@ -558,7 +553,7 @@ public function restoreQuote()
$this->replaceQuote($quote)->unsLastRealOrderId();
$this->_eventManager->dispatch('restore_quote', ['order' => $order, 'quote' => $quote]);
return true;
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
} catch (NoSuchEntityException $e) {
$this->logger->critical($e);
}
}
Expand Down Expand Up @@ -588,4 +583,22 @@ protected function isQuoteMasked()
{
return $this->isQuoteMasked;
}

/**
* Returns quote for customer if there is any
*/
private function getQuoteByCustomer(): ?CartInterface
{
$customerId = $this->_customer
? $this->_customer->getId()
: $this->_customerSession->getCustomerId();

try {
$quote = $this->quoteRepository->getActiveForCustomer($customerId);
} catch (NoSuchEntityException $e) {
$quote = null;
}

return $quote;
}
}
65 changes: 64 additions & 1 deletion app/code/Magento/Checkout/Test/Unit/Model/SessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
*/
namespace Magento\Checkout\Test\Unit\Model;

use \Magento\Checkout\Model\Session;
use Magento\Checkout\Model\Session;
use Magento\Framework\Exception\NoSuchEntityException;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Expand Down Expand Up @@ -374,6 +375,68 @@ public function testGetStepData()
$this->assertEquals($stepData['complex']['key'], $session->getStepData('complex', 'key'));
}

/**
* Ensure that if quote not exist for customer quote will be null
*
* @return void
*/
public function testGetQuote(): void
{
$storeManager = $this->getMockForAbstractClass(\Magento\Store\Model\StoreManagerInterface::class);
$customerSession = $this->createMock(\Magento\Customer\Model\Session::class);
$quoteRepository = $this->createMock(\Magento\Quote\Api\CartRepositoryInterface::class);
$quoteFactory = $this->createMock(\Magento\Quote\Model\QuoteFactory::class);
$quote = $this->createMock(\Magento\Quote\Model\Quote::class);
$logger = $this->createMock(\Psr\Log\LoggerInterface::class);
$loggerMethods = get_class_methods(\Psr\Log\LoggerInterface::class);

$quoteFactory->expects($this->once())
->method('create')
->willReturn($quote);
$customerSession->expects($this->exactly(3))
->method('isLoggedIn')
->willReturn(true);
$store = $this->getMockBuilder(\Magento\Store\Model\Store::class)
->disableOriginalConstructor()
->setMethods(['getWebsiteId', '__wakeup'])
->getMock();
$storeManager->expects($this->any())
->method('getStore')
->will($this->returnValue($store));
$storage = $this->getMockBuilder(\Magento\Framework\Session\Storage::class)
->disableOriginalConstructor()
->setMethods(['setData', 'getData'])
->getMock();
$storage->expects($this->at(0))
->method('getData')
->willReturn(1);
$quoteRepository->expects($this->once())
->method('getActiveForCustomer')
->willThrowException(new NoSuchEntityException());

foreach ($loggerMethods as $method) {
$logger->expects($this->never())->method($method);
}

$quote->expects($this->once())
->method('setCustomer')
->with(null);

$constructArguments = $this->_helper->getConstructArguments(
\Magento\Checkout\Model\Session::class,
[
'storeManager' => $storeManager,
'quoteRepository' => $quoteRepository,
'customerSession' => $customerSession,
'storage' => $storage,
'quoteFactory' => $quoteFactory,
'logger' => $logger
]
);
$this->_session = $this->_helper->getObject(\Magento\Checkout\Model\Session::class, $constructArguments);
$this->_session->getQuote();
}

public function testSetStepData()
{
$stepData = [
Expand Down
Loading

0 comments on commit 7324325

Please sign in to comment.