Skip to content

Commit b7dbcbc

Browse files
Merge branch 'MC-36372' into 2.4-develop-com-pr15
2 parents c651bf4 + 5c6e78a commit b7dbcbc

File tree

7 files changed

+519
-2
lines changed

7 files changed

+519
-2
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Setup\Patch\Data;
8+
9+
use Magento\Catalog\Setup\CategorySetup;
10+
use Magento\Catalog\Setup\CategorySetupFactory;
11+
use Magento\Framework\Setup\ModuleDataSetupInterface;
12+
use Magento\Framework\Setup\Patch\DataPatchInterface;
13+
14+
/**
15+
* Reorder Short Description/Description Product Attributes
16+
*/
17+
class UpdateProductDescriptionOrder implements DataPatchInterface
18+
{
19+
/**
20+
* @var ModuleDataSetupInterface
21+
*/
22+
private $moduleDataSetup;
23+
24+
/**
25+
* @var CategorySetupFactory
26+
*/
27+
private $categorySetupFactory;
28+
29+
/**
30+
* @param ModuleDataSetupInterface $moduleDataSetup
31+
* @param CategorySetupFactory $categorySetupFactory
32+
*/
33+
public function __construct(
34+
ModuleDataSetupInterface $moduleDataSetup,
35+
CategorySetupFactory $categorySetupFactory
36+
) {
37+
$this->moduleDataSetup = $moduleDataSetup;
38+
$this->categorySetupFactory = $categorySetupFactory;
39+
}
40+
41+
/**
42+
* @inheritdoc
43+
*/
44+
public function apply()
45+
{
46+
/** @var CategorySetup $categorySetup */
47+
$categorySetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
48+
$entityTypeId = $categorySetup->getEntityTypeId(\Magento\Catalog\Model\Product::ENTITY);
49+
50+
// Content
51+
$categorySetup->updateAttribute(
52+
$entityTypeId,
53+
'short_description',
54+
'frontend_label',
55+
'Short Description',
56+
100
57+
);
58+
$categorySetup->updateAttribute(
59+
$entityTypeId,
60+
'description',
61+
'frontend_label',
62+
'Description',
63+
110
64+
);
65+
66+
return $this;
67+
}
68+
69+
/**
70+
* @inheritdoc
71+
*/
72+
public static function getDependencies()
73+
{
74+
return [
75+
UpdateMediaAttributesBackendTypes::class,
76+
];
77+
}
78+
79+
/**
80+
* @inheritdoc
81+
*/
82+
public function getAliases()
83+
{
84+
return [];
85+
}
86+
}

app/code/Magento/Catalog/Test/Mftf/Test/AdminAddImageToWYSIWYGProductTest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<actionGroup ref="FillMainProductFormActionGroup" stepKey="fillBasicProductInfo" />
3333

3434
<click selector="{{AdminProductFormSection.contentTab}}" stepKey="clickContentTab" />
35+
<scrollTo selector="{{ProductDescriptionWYSIWYGToolbarSection.showHideBtn}}" y="-150" x="0" stepKey="scrollToDescription" />
3536
<waitForElementVisible selector="{{ProductDescriptionWYSIWYGToolbarSection.TinyMCE4}}" stepKey="waitForDescription" />
3637
<click selector="{{ProductDescriptionWYSIWYGToolbarSection.InsertImageIcon}}" stepKey="clickInsertImageIcon1" />
3738
<click selector="{{ProductDescriptionWYSIWYGToolbarSection.Browse}}" stepKey="clickBrowse1" />
@@ -67,7 +68,7 @@
6768
<fillField selector="{{ProductDescriptionWYSIWYGToolbarSection.ImageDescription}}" userInput="{{ImageUpload1.content}}" stepKey="fillImageDescription1" />
6869
<fillField selector="{{ProductDescriptionWYSIWYGToolbarSection.Height}}" userInput="{{ImageUpload1.height}}" stepKey="fillImageHeight1" />
6970
<click selector="{{ProductDescriptionWYSIWYGToolbarSection.OkBtn}}" stepKey="clickOkBtn1" />
70-
<scrollTo selector="{{ProductDescriptionWYSIWYGToolbarSection.TinyMCE4}}" stepKey="scrollToTinyMCE4" />
71+
<scrollTo selector="{{ProductShortDescriptionWYSIWYGToolbarSection.showHideBtn}}" y="-150" x="0" stepKey="scrollToTinyMCE4" />
7172
<click selector="{{ProductShortDescriptionWYSIWYGToolbarSection.InsertImageIcon}}" stepKey="clickInsertImageIcon2" />
7273
<click selector="{{ProductShortDescriptionWYSIWYGToolbarSection.Browse}}" stepKey="clickBrowse2" />
7374
<waitForLoadingMaskToDisappear stepKey="waitForLoading13"/>

app/code/Magento/Catalog/Test/Mftf/Test/VerifyTinyMCEv4IsNativeWYSIWYGOnProductTest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<see selector="{{ProductDescriptionWYSIWYGToolbarSection.InsertImageBtn}}" userInput="Insert Image..." stepKey="seeInsertImage1"/>
4545
<dontSee selector="{{TinyMCESection.InsertWidgetBtn}}" stepKey="insertWidget1" />
4646
<dontSee selector="{{TinyMCESection.InsertVariableBtn}}" stepKey="insertVariable1" />
47-
<scrollTo selector="{{ProductDescriptionWYSIWYGToolbarSection.showHideBtn}}" stepKey="scrollToDesShowHideBtn2" />
47+
<scrollTo selector="{{ProductShortDescriptionWYSIWYGToolbarSection.showHideBtn}}" y="-150" x="0" stepKey="scrollToDesShowHideBtn2" />
4848
<click selector="{{ProductShortDescriptionWYSIWYGToolbarSection.showHideBtn}}" stepKey="clickShowHideBtn2" />
4949
<waitForElementVisible selector="{{ProductShortDescriptionWYSIWYGToolbarSection.InsertImageBtn}}" stepKey="waitForInsertImage2" />
5050
<see selector="{{ProductShortDescriptionWYSIWYGToolbarSection.InsertImageBtn}}" userInput="Insert Image..." stepKey="seeInsertImage2"/>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Sales\Block\Adminhtml\Order\Address;
9+
10+
use Magento\Framework\ObjectManagerInterface;
11+
use Magento\Framework\Registry;
12+
use Magento\Framework\View\LayoutInterface;
13+
use Magento\Sales\Api\Data\OrderInterfaceFactory;
14+
use Magento\TestFramework\Helper\Bootstrap;
15+
use PHPUnit\Framework\TestCase;
16+
17+
/**
18+
* Checks order address edit form block
19+
*
20+
* @see \Magento\Sales\Block\Adminhtml\Order\Address\Form
21+
*
22+
* @magentoAppArea adminhtml
23+
*/
24+
class FormTest extends TestCase
25+
{
26+
/** @var ObjectManagerInterface */
27+
private $objectManager;
28+
29+
/** @var Form */
30+
private $block;
31+
32+
/** @var Registry */
33+
private $registry;
34+
35+
/** @var OrderInterfaceFactory */
36+
private $orderFactory;
37+
38+
/**
39+
* @inheritdoc
40+
*/
41+
protected function setUp(): void
42+
{
43+
parent::setUp();
44+
45+
$this->objectManager = Bootstrap::getObjectManager();
46+
$this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Form::class);
47+
$this->orderFactory = $this->objectManager->get(OrderInterfaceFactory::class);
48+
$this->registry = $this->objectManager->get(Registry::class);
49+
}
50+
51+
/**
52+
* @return void
53+
*/
54+
protected function tearDown(): void
55+
{
56+
$this->registry->unregister('order_address');
57+
58+
parent::tearDown();
59+
}
60+
61+
/**
62+
* @magentoDataFixture Magento/Sales/_files/order.php
63+
*
64+
* @return void
65+
*/
66+
public function testGetFormValues(): void
67+
{
68+
$this->registry->unregister('order_address');
69+
$order = $this->orderFactory->create()->loadByIncrementId(100000001);
70+
$address = $order->getShippingAddress();
71+
$this->registry->register('order_address', $address);
72+
$formValues = $this->block->getFormValues();
73+
$this->assertEquals($address->getData(), $formValues);
74+
}
75+
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Sales\Block\Adminhtml\Order;
9+
10+
use Magento\Framework\ObjectManagerInterface;
11+
use Magento\Framework\Registry;
12+
use Magento\Framework\View\LayoutInterface;
13+
use Magento\Sales\Api\Data\OrderAddressInterface;
14+
use Magento\Sales\Api\Data\OrderInterface;
15+
use Magento\Sales\Model\Order\Address as AddressType;
16+
use Magento\Sales\Model\OrderFactory;
17+
use Magento\TestFramework\Helper\Bootstrap;
18+
use PHPUnit\Framework\TestCase;
19+
20+
/**
21+
* Checks order address edit block
22+
*
23+
* @see \Magento\Sales\Block\Adminhtml\Order\Address
24+
*
25+
* @magentoAppArea adminhtml
26+
*/
27+
class AddressTest extends TestCase
28+
{
29+
/** @var ObjectManagerInterface */
30+
private $objectManager;
31+
32+
/** @var Address */
33+
private $block;
34+
35+
/** @var Registry */
36+
private $registry;
37+
38+
/** @var OrderFactory */
39+
private $orderFactory;
40+
41+
/**
42+
* @inheritdoc
43+
*/
44+
protected function setUp(): void
45+
{
46+
parent::setUp();
47+
48+
$this->objectManager = Bootstrap::getObjectManager();
49+
$this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Address::class);
50+
$this->registry = $this->objectManager->get(Registry::class);
51+
$this->orderFactory = $this->objectManager->get(OrderFactory::class);
52+
}
53+
54+
/**
55+
* @inheritdoc
56+
*/
57+
protected function tearDown(): void
58+
{
59+
$this->registry->unregister('order_address');
60+
61+
parent::tearDown();
62+
}
63+
64+
/**
65+
* @dataProvider addressTypeProvider
66+
*
67+
* @magentoDataFixture Magento/Sales/_files/order.php
68+
*
69+
* @param string $type
70+
* @return void
71+
*/
72+
public function testGetHeaderText(string $type): void
73+
{
74+
$order = $this->orderFactory->create()->loadByIncrementId(100000001);
75+
$address = $this->getAddressByType($order, $type);
76+
$this->registry->unregister('order_address');
77+
$this->registry->register('order_address', $address);
78+
$text = $this->block->getHeaderText();
79+
$this->assertEquals(
80+
(string)__('Edit Order %1 %2 Address', $order->getIncrementId(), ucfirst($type)),
81+
(string)$text
82+
);
83+
}
84+
85+
/**
86+
* @return array
87+
*/
88+
public function addressTypeProvider(): array
89+
{
90+
return [
91+
'billing_address' => [
92+
AddressType::TYPE_BILLING,
93+
],
94+
'shipping_address' => [
95+
AddressType::TYPE_SHIPPING,
96+
]
97+
];
98+
}
99+
100+
/**
101+
* Get address by address type
102+
*
103+
* @param OrderInterface $order
104+
* @param string $type
105+
* @return OrderAddressInterface|null
106+
*/
107+
private function getAddressByType(OrderInterface $order, string $type): ?OrderAddressInterface
108+
{
109+
return $type === AddressType::TYPE_BILLING ? $order->getBillingAddress() : $order->getShippingAddress();
110+
}
111+
}

0 commit comments

Comments
 (0)