Skip to content

Commit d1a7554

Browse files
committed
Merge branch 'develop_mainline' into develop
2 parents 820011f + e2ef0d5 commit d1a7554

File tree

21 files changed

+954
-192
lines changed

21 files changed

+954
-192
lines changed

app/code/Magento/Catalog/Model/Product/Option/Type/File.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,6 @@ protected function prepareSize($value)
497497
$sizes = '';
498498
if (!empty($value['width']) && !empty($value['height']) && $value['width'] > 0 && $value['height'] > 0) {
499499
$sizes = $value['width'] . ' x ' . $value['height'] . ' ' . __('px.');
500-
return [$value, $sizes];
501500
}
502501
return $sizes;
503502
}

app/code/Magento/Catalog/Model/Resource/Eav/Attribute.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,4 +784,13 @@ public function setScope($scope)
784784
return $this;
785785
}
786786
}
787+
788+
/**
789+
* {@inheritdoc}
790+
*/
791+
public function afterDelete()
792+
{
793+
$this->_eavConfig->clear();
794+
return parent::afterDelete();
795+
}
787796
}
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Catalog\Test\Unit\Model\Entity;
8+
9+
use Magento\Catalog\Model\Entity\Attribute;
10+
11+
/**
12+
* @SuppressWarnings(PHPMD.TooManyFields)
13+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
14+
*/
15+
class AttributeTest extends \PHPUnit_Framework_TestCase
16+
{
17+
/**
18+
* @var \Magento\Catalog\Model\Entity\Attribute
19+
*/
20+
protected $attribute;
21+
22+
/**
23+
* @var \Magento\Framework\Model\Context|\PHPUnit_Framework_MockObject_MockObject
24+
*/
25+
protected $contextMock;
26+
27+
/**
28+
* @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject
29+
*/
30+
protected $registryMock;
31+
32+
/**
33+
* @var \Magento\Framework\Api\MetadataServiceInterface|\PHPUnit_Framework_MockObject_MockObject
34+
*/
35+
protected $metadataServiceMock;
36+
37+
/**
38+
* @var \Magento\Framework\Api\AttributeValueFactory|\PHPUnit_Framework_MockObject_MockObject
39+
*/
40+
protected $attributeValueFactoryMock;
41+
42+
/**
43+
* @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject
44+
*/
45+
protected $configMock;
46+
47+
/**
48+
* @var \Magento\Eav\Model\Entity\TypeFactory|\PHPUnit_Framework_MockObject_MockObject
49+
*/
50+
protected $typeFactoryMock;
51+
52+
/**
53+
* @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
54+
*/
55+
protected $storeManagerMock;
56+
57+
/**
58+
* @var \Magento\Eav\Model\Resource\Helper|\PHPUnit_Framework_MockObject_MockObject
59+
*/
60+
protected $helperMock;
61+
62+
/**
63+
* @var \Magento\Framework\Validator\UniversalFactory|\PHPUnit_Framework_MockObject_MockObject
64+
*/
65+
protected $universalFactoryMock;
66+
67+
/**
68+
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject
69+
*/
70+
protected $timezoneMock;
71+
72+
/**
73+
* @var \Magento\Catalog\Model\Product\ReservedAttributeList|\PHPUnit_Framework_MockObject_MockObject
74+
*/
75+
protected $reservedAttributeListMock;
76+
77+
/**
78+
* @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject
79+
*/
80+
protected $resolverMock;
81+
82+
/**
83+
* @var \Magento\Catalog\Model\Attribute\LockValidatorInterface|\PHPUnit_Framework_MockObject_MockObject
84+
*/
85+
protected $lockValidatorMock;
86+
87+
/**
88+
* @var \Magento\Framework\Model\Resource\AbstractResource|\PHPUnit_Framework_MockObject_MockObject
89+
*/
90+
private $resourceMock;
91+
92+
/**
93+
* @var \Magento\Framework\App\CacheInterface|\PHPUnit_Framework_MockObject_MockObject
94+
*/
95+
private $cacheManager;
96+
97+
/**
98+
* @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
99+
*/
100+
private $eventDispatcher;
101+
102+
/**
103+
* @var \Magento\Eav\Api\Data\AttributeOptionInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject
104+
*/
105+
private $attributeOptionFactoryMock;
106+
107+
/**
108+
* @var \Magento\Framework\Reflection\DataObjectProcessor|\PHPUnit_Framework_MockObject_MockObject
109+
*/
110+
private $dataObjectProcessorMock;
111+
112+
/**
113+
* @var \Magento\Framework\Api\DataObjectHelper|\PHPUnit_Framework_MockObject_MockObject
114+
*/
115+
private $dataObjectHelperMock;
116+
117+
protected function setUp()
118+
{
119+
$this->contextMock = $this->getMockBuilder('Magento\Framework\Model\Context')
120+
->setMethods(['getCacheManager', 'getEventDispatcher'])
121+
->disableOriginalConstructor()
122+
->getMock();
123+
$this->registryMock = $this->getMockBuilder('Magento\Framework\Registry')
124+
->getMock();
125+
$this->metadataServiceMock = $this->getMockBuilder('Magento\Framework\Api\MetadataServiceInterface')
126+
->getMock();
127+
$this->attributeValueFactoryMock = $this->getMockBuilder('Magento\Framework\Api\AttributeValueFactory')
128+
->disableOriginalConstructor()
129+
->getMock();
130+
$this->configMock = $this->getMockBuilder('Magento\Eav\Model\Config')
131+
->disableOriginalConstructor()
132+
->getMock();
133+
$this->typeFactoryMock = $this->getMockBuilder('Magento\Eav\Model\Entity\TypeFactory')
134+
->disableOriginalConstructor()
135+
->getMock();
136+
$this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface')
137+
->getMock();
138+
$this->helperMock = $this->getMockBuilder('Magento\Eav\Model\Resource\Helper')
139+
->disableOriginalConstructor()
140+
->getMock();
141+
$this->universalFactoryMock = $this->getMockBuilder('Magento\Framework\Validator\UniversalFactory')
142+
->disableOriginalConstructor()
143+
->getMock();
144+
$this->attributeOptionFactoryMock =
145+
$this->getMockBuilder('Magento\Eav\Api\Data\AttributeOptionInterfaceFactory')
146+
->disableOriginalConstructor()
147+
->getMock();
148+
$this->dataObjectProcessorMock = $this->getMockBuilder('Magento\Framework\Reflection\DataObjectProcessor')
149+
->disableOriginalConstructor()
150+
->getMock();
151+
$this->dataObjectHelperMock = $this->getMockBuilder('Magento\Framework\Api\DataObjectHelper')
152+
->disableOriginalConstructor()
153+
->getMock();
154+
$this->timezoneMock = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface')
155+
->getMock();
156+
$this->reservedAttributeListMock = $this->getMockBuilder('Magento\Catalog\Model\Product\ReservedAttributeList')
157+
->disableOriginalConstructor()
158+
->getMock();
159+
$this->resolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface')
160+
->getMock();
161+
$this->lockValidatorMock = $this->getMockBuilder('Magento\Catalog\Model\Attribute\LockValidatorInterface')
162+
->getMock();
163+
164+
$this->resourceMock = $this->getMockBuilder('Magento\Framework\Model\Resource\AbstractResource')
165+
->setMethods(['_construct', '_getReadAdapter', '_getWriteAdapter', 'getIdFieldName', 'saveInSetIncluding'])
166+
->getMock();
167+
$this->cacheManager = $this->getMockBuilder('Magento\Framework\App\CacheInterface')
168+
->getMock();
169+
$this->eventDispatcher = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface')
170+
->getMock();
171+
172+
$this->contextMock
173+
->expects($this->any())
174+
->method('getCacheManager')
175+
->willReturn($this->cacheManager);
176+
$this->contextMock
177+
->expects($this->any())
178+
->method('getEventDispatcher')
179+
->willReturn($this->eventDispatcher);
180+
181+
$this->attribute = new Attribute(
182+
$this->contextMock,
183+
$this->registryMock,
184+
$this->metadataServiceMock,
185+
$this->attributeValueFactoryMock,
186+
$this->configMock,
187+
$this->typeFactoryMock,
188+
$this->storeManagerMock,
189+
$this->helperMock,
190+
$this->universalFactoryMock,
191+
$this->attributeOptionFactoryMock,
192+
$this->dataObjectProcessorMock,
193+
$this->dataObjectHelperMock,
194+
$this->timezoneMock,
195+
$this->reservedAttributeListMock,
196+
$this->resolverMock,
197+
$this->lockValidatorMock,
198+
$this->resourceMock
199+
);
200+
}
201+
202+
public function testAfterSaveEavCache()
203+
{
204+
$this->configMock
205+
->expects($this->once())
206+
->method('clear');
207+
208+
$this->attribute->afterSave();
209+
}
210+
}

app/code/Magento/Catalog/Test/Unit/Model/Resource/Eav/AttributeTest.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ class AttributeTest extends \PHPUnit_Framework_TestCase
3737
*/
3838
protected $resourceMock;
3939

40+
/**
41+
* @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject
42+
*/
43+
protected $eavConfigMock;
44+
4045
public function setUp()
4146
{
4247
$this->_processor = $this->getMock(
@@ -89,6 +94,11 @@ public function setUp()
8994
[], '', false
9095
);
9196

97+
$this->eavConfigMock = $this->getMockBuilder('Magento\Eav\Model\Config')
98+
->setMethods(['clear'])
99+
->disableOriginalConstructor()
100+
->getMock();
101+
92102
$this->resourceMock->expects($this->any())
93103
->method('_getWriteAdapter')
94104
->will($this->returnValue($dbAdapterMock));
@@ -101,7 +111,8 @@ public function setUp()
101111
'productFlatIndexerProcessor' => $this->_processor,
102112
'indexerEavProcessor' => $this->_eavProcessor,
103113
'resource' => $this->resourceMock,
104-
'data' => ['id' => 1]
114+
'data' => ['id' => 1],
115+
'eavConfig' => $this->eavConfigMock
105116
]
106117
);
107118
}
@@ -125,6 +136,14 @@ public function testIndexerAfterSaveScopeChangeAttribute()
125136
$this->_model->afterSave();
126137
}
127138

139+
public function testAfterSaveEavCache()
140+
{
141+
$this->eavConfigMock
142+
->expects($this->once())
143+
->method('clear');
144+
$this->_model->afterSave();
145+
}
146+
128147
public function testIndexerAfterDeleteAttribute()
129148
{
130149
$this->_processor->expects($this->once())->method('markIndexerAsInvalid');
@@ -133,6 +152,14 @@ public function testIndexerAfterDeleteAttribute()
133152
$this->_model->afterDeleteCommit();
134153
}
135154

155+
public function testAfterDeleteEavCache()
156+
{
157+
$this->eavConfigMock
158+
->expects($this->once())
159+
->method('clear');
160+
$this->_model->afterDelete();
161+
}
162+
136163
public function testGetScopeGlobal()
137164
{
138165
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);

app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ define([
3838
},
3939

4040
submitForm: function(form) {
41+
var self = this;
42+
if (form.has('input[type="file"]').length) {
43+
self.element.off('submit');
44+
form.submit();
45+
} else {
46+
self.ajaxSubmit(form);
47+
}
48+
},
49+
50+
ajaxSubmit: function(form) {
4151
var self = this;
4252
$.ajax({
4353
url: form.attr('action'),

app/code/Magento/Customer/Model/Customer.php

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,6 @@ class Customer extends \Magento\Framework\Model\AbstractExtensibleModel
159159
*/
160160
protected $_transportBuilder;
161161

162-
/**
163-
* @var AttributeFactory
164-
*/
165-
protected $_attributeFactory;
166-
167162
/**
168163
* @var GroupRepositoryInterface
169164
*/
@@ -237,7 +232,6 @@ public function __construct(
237232
\Magento\Customer\Model\Resource\Address\CollectionFactory $addressesFactory,
238233
\Magento\Framework\Mail\Template\TransportBuilder $transportBuilder,
239234
GroupRepositoryInterface $groupRepository,
240-
AttributeFactory $attributeFactory,
241235
\Magento\Framework\Encryption\EncryptorInterface $encryptor,
242236
\Magento\Framework\Stdlib\DateTime $dateTime,
243237
CustomerInterfaceFactory $customerDataFactory,
@@ -254,7 +248,6 @@ public function __construct(
254248
$this->_addressesFactory = $addressesFactory;
255249
$this->_transportBuilder = $transportBuilder;
256250
$this->_groupRepository = $groupRepository;
257-
$this->_attributeFactory = $attributeFactory;
258251
$this->_encryptor = $encryptor;
259252
$this->dateTime = $dateTime;
260253
$this->customerDataFactory = $customerDataFactory;
@@ -1015,18 +1008,15 @@ public function validate()
10151008
}
10161009

10171010
$entityType = $this->_config->getEntityType('customer');
1018-
$attribute = $this->_createCustomerAttribute();
1019-
$attribute->loadByCode($entityType, 'dob');
1011+
$attribute = $this->_config->getAttribute($entityType, 'dob');
10201012
if ($attribute->getIsRequired() && '' == trim($this->getDob())) {
10211013
$errors[] = __('The Date of Birth is required.');
10221014
}
1023-
$attribute = $this->_createCustomerAttribute();
1024-
$attribute->loadByCode($entityType, 'taxvat');
1015+
$attribute = $this->_config->getAttribute($entityType, 'taxvat');
10251016
if ($attribute->getIsRequired() && '' == trim($this->getTaxvat())) {
10261017
$errors[] = __('The TAX/VAT number is required.');
10271018
}
1028-
$attribute = $this->_createCustomerAttribute();
1029-
$attribute->loadByCode($entityType, 'gender');
1019+
$attribute = $this->_config->getAttribute($entityType, 'gender');
10301020
if ($attribute->getIsRequired() && '' == trim($this->getGender())) {
10311021
$errors[] = __('Gender is required.');
10321022
}
@@ -1321,14 +1311,6 @@ protected function _createAddressCollection()
13211311
return $this->_addressesFactory->create();
13221312
}
13231313

1324-
/**
1325-
* @return \Magento\Customer\Model\Attribute
1326-
*/
1327-
protected function _createCustomerAttribute()
1328-
{
1329-
return $this->_attributeFactory->create();
1330-
}
1331-
13321314
/**
13331315
* @return array
13341316
*/

0 commit comments

Comments
 (0)