Skip to content

Commit 393ef91

Browse files
committed
MC-5233: DateTime product attributes support
1 parent 29d2f6c commit 393ef91

File tree

8 files changed

+38
-23
lines changed

8 files changed

+38
-23
lines changed

app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use PHPUnit\Framework\TestCase;
2020

2121
/**
22-
* ColumnFactory test.
22+
* Test to Create columns factory on product grid page
2323
*/
2424
class ColumnFactoryTest extends TestCase
2525
{
@@ -206,6 +206,7 @@ public function testCreateDateColumn(
206206
'component' => 'Magento_Ui/js/grid/columns/date',
207207
'timezone' => $expectedTimezone,
208208
'dateFormat' => $expectedDateFormat,
209+
'__disableTmpl' => ['label' => true],
209210
'options' => [
210211
'showsTime' => $showsTime
211212
]

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
use PHPUnit\Framework\MockObject\MockObject;
4242

4343
/**
44-
* Class EavTest
44+
* Class to test Data provider for eav attributes on product page
4545
*
4646
* @method Eav getModel
4747
* @SuppressWarnings(PHPMD.TooManyFields)
@@ -692,6 +692,7 @@ public function setupAttributeMetaDataProvider()
692692
'scopeLabel' => '',
693693
'globalScope' => false,
694694
'sortOrder' => 0,
695+
'__disableTmpl' => ['label' => true, 'code' => true]
695696
],
696697
'locked' => false,
697698
'frontendInput' => 'datetime',

app/code/Magento/Catalog/Ui/Component/ColumnFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Magento\Ui\Component\Listing\Columns\ColumnInterface;
1616

1717
/**
18-
* Column Factory
18+
* Create columns factory on product grid page
1919
*
2020
* @api
2121
* @since 100.0.2

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
use Magento\Eav\Model\ResourceModel\Entity\Attribute\CollectionFactory as AttributeCollectionFactory;
4141

4242
/**
43-
* Class Eav
43+
* Data provider for eav attributes on product page
4444
*
4545
* @api
4646
*

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/js.phtml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
use Magento\Catalog\Helper\Data;
67

78
// phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis
89
?>
@@ -63,7 +64,12 @@ function bindAttributeInputType()
6364
{
6465
checkOptionsPanelVisibility();
6566
switchDefaultValueField();
66-
if($('frontend_input') && ($('frontend_input').value=='boolean' || $('frontend_input').value=='select' || $('frontend_input').value=='multiselect' || $('frontend_input').value=='price')){
67+
if ($('frontend_input')
68+
&& ($('frontend_input').value=='boolean'
69+
|| $('frontend_input').value=='select'
70+
|| $('frontend_input').value=='multiselect'
71+
|| $('frontend_input').value=='price')
72+
){
6773
if($('is_filterable') && !$('is_filterable').getAttribute('readonly')){
6874
$('is_filterable').disabled = false;
6975
}
@@ -75,8 +81,7 @@ function bindAttributeInputType()
7581
if($('backend_type').options[i].value=='int') $('backend_type').selectedIndex = i;
7682
}
7783
}
78-
}
79-
else {
84+
} else {
8085
if($('is_filterable')){
8186
$('is_filterable').selectedIndex=0;
8287
$('is_filterable').disabled = true;
@@ -203,21 +208,22 @@ function switchDefaultValueField()
203208
setRowVisibility('frontend_class', false);
204209
break;
205210

206-
<?php foreach ($this->helper(Magento\Catalog\Helper\Data::class)->getAttributeHiddenFields() as $type => $fields) :?>
211+
<?php // phpcs:ignore Magento2.Templates.ThisInTemplate ?>
212+
<?php foreach ($this->helper(Data::class)->getAttributeHiddenFields() as $type => $fields): ?>
207213
case '<?= $block->escapeJs($type) ?>':
208214
var isFrontTabHidden = false;
209-
<?php foreach ($fields as $one) :?>
210-
<?php if ($one == '_front_fieldset') :?>
215+
<?php foreach ($fields as $one): ?>
216+
<?php if ($one == '_front_fieldset'): ?>
211217
getFrontTab().hide();
212218
isFrontTabHidden = true;
213-
<?php elseif ($one == '_default_value') :?>
219+
<?php elseif ($one == '_default_value'): ?>
214220
defaultValueTextVisibility =
215221
defaultValueTextareaVisibility =
216222
defaultValueDateVisibility =
217223
defaultValueYesnoVisibility = false;
218-
<?php elseif ($one == '_scope') :?>
224+
<?php elseif ($one == '_scope'): ?>
219225
scopeVisibility = false;
220-
<?php else :?>
226+
<?php else: ?>
221227
setRowVisibility('<?= $block->escapeJs($one) ?>', false);
222228
<?php endif; ?>
223229
<?php endforeach; ?>

app/code/Magento/Eav/Test/Unit/Model/Entity/AttributeTest.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,21 @@
55
*/
66
namespace Magento\Eav\Test\Unit\Model\Entity;
77

8+
use Magento\Eav\Model\Entity\Attribute;
9+
use Magento\Eav\Model\Entity\Attribute\FrontendLabel;
10+
use Magento\Eav\Model\Entity\Attribute\FrontendLabelFactory;
11+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
12+
use PHPUnit\Framework\MockObject\MockObject;
13+
use PHPUnit\Framework\TestCase;
14+
815
/**
9-
* Class AttributeTest.
16+
* Test for EAV Entity attribute model
1017
*/
11-
class AttributeTest extends \PHPUnit\Framework\TestCase
18+
class AttributeTest extends TestCase
1219
{
1320
/**
1421
* Attribute model to be tested
15-
* @var \Magento\Eav\Model\Entity\Attribute|\PHPUnit_Framework_MockObject_MockObject
22+
* @var Attribute|MockObject
1623
*/
1724
protected $_model;
1825

@@ -21,7 +28,7 @@ class AttributeTest extends \PHPUnit\Framework\TestCase
2128
*/
2229
protected function setUp()
2330
{
24-
$this->_model = $this->createPartialMock(\Magento\Eav\Model\Entity\Attribute::class, ['__wakeup']);
31+
$this->_model = $this->createPartialMock(Attribute::class, ['__wakeup']);
2532
}
2633

2734
/**
@@ -132,7 +139,7 @@ public function testGetFrontendLabels()
132139
{
133140
$attributeId = 1;
134141
$storeLabels = ['test_attribute_store1'];
135-
$frontendLabelFactory = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\FrontendLabelFactory::class)
142+
$frontendLabelFactory = $this->getMockBuilder(FrontendLabelFactory::class)
136143
->disableOriginalConstructor()
137144
->setMethods(['create'])
138145
->getMock();
@@ -144,15 +151,15 @@ public function testGetFrontendLabels()
144151
'_resource' => $resource,
145152
'frontendLabelFactory' => $frontendLabelFactory,
146153
];
147-
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
148-
$this->_model = $objectManager->getObject(\Magento\Eav\Model\Entity\Attribute::class, $arguments);
154+
$objectManager = new ObjectManager($this);
155+
$this->_model = $objectManager->getObject(Attribute::class, $arguments);
149156
$this->_model->setAttributeId($attributeId);
150157

151158
$resource->expects($this->once())
152159
->method('getStoreLabelsByAttributeId')
153160
->with($attributeId)
154161
->willReturn($storeLabels);
155-
$frontendLabel = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\FrontendLabel::class)
162+
$frontendLabel = $this->getMockBuilder(FrontendLabel::class)
156163
->setMethods(['setStoreId', 'setLabel'])
157164
->disableOriginalConstructor()
158165
->getMock();

app/code/Magento/Ui/Component/Form/Element/DataType/Date.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Magento\Framework\View\Element\UiComponent\ContextInterface;
1212

1313
/**
14-
* Class Date
14+
* UI component date type
1515
*/
1616
class Date extends AbstractDataType
1717
{

app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use PHPUnit\Framework\MockObject\MockObject;
1717

1818
/**
19-
* Class DateTest
19+
* Test for Date grid filter functionality
2020
*/
2121
class DateTest extends \PHPUnit\Framework\TestCase
2222
{

0 commit comments

Comments
 (0)