Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Commit 76d3f43

Browse files
committed
Merge branch 'develop' into Fearless-Kiwis-MAGETWO-50123-Unable-to-assign-blank-value-to-attribute
2 parents 1de0edc + 8904497 commit 76d3f43

File tree

18 files changed

+464
-2
lines changed

18 files changed

+464
-2
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function execute()
132132
$attributesData[$attributeCode] = $value;
133133
} elseif ($attribute->getFrontendInput() == 'multiselect') {
134134
// Check if 'Change' checkbox has been checked by admin for this attribute
135-
$isChanged = (bool)$this->getRequest()->getPost($attributeCode . '_checkbox');
135+
$isChanged = (bool)$this->getRequest()->getPost('toggle_' . $attributeCode);
136136
if (!$isChanged) {
137137
unset($attributesData[$attributeCode]);
138138
continue;

app/code/Magento/Catalog/Model/Product.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,10 @@ public function getMediaGalleryImages()
14681468
if (!$this->hasData('media_gallery_images') && is_array($this->getMediaGallery('images'))) {
14691469
$images = $this->_collectionFactory->create();
14701470
foreach ($this->getMediaGallery('images') as $image) {
1471-
if ((isset($image['disabled']) && $image['disabled']) || empty($image['value_id'])) {
1471+
if ((isset($image['disabled']) && $image['disabled'])
1472+
|| empty($image['value_id'])
1473+
|| $images->getItemById($image['value_id']) != null
1474+
) {
14721475
continue;
14731476
}
14741477
$image['url'] = $this->getMediaConfig()->getMediaUrl($image['file']);

app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,16 @@ class ProductTest extends \PHPUnit_Framework_TestCase
185185
*/
186186
private $extensionAttributesFactory;
187187

188+
/**
189+
* @var \Magento\Framework\Filesystem
190+
*/
191+
private $filesystemMock;
192+
193+
/**
194+
* @var \Magento\Framework\Data\CollectionFactory
195+
*/
196+
private $collectionFactoryMock;
197+
188198
/**
189199
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
190200
*/
@@ -374,6 +384,13 @@ protected function setUp()
374384
$this->extensionAttributesFactory = $this->getMockBuilder(ExtensionAttributesFactory::class)
375385
->disableOriginalConstructor()
376386
->getMock();
387+
$this->filesystemMock = $this->getMockBuilder(\Magento\Framework\Filesystem::class)
388+
->disableOriginalConstructor()
389+
->getMock();
390+
$this->collectionFactoryMock = $this->getMockBuilder(\Magento\Framework\Data\CollectionFactory::class)
391+
->disableOriginalConstructor()
392+
->setMethods(['create'])
393+
->getMock();
377394
$this->mediaConfig = $this->getMock(\Magento\Catalog\Model\Product\Media\Config::class, [], [], '', false);
378395
$this->objectManagerHelper = new ObjectManagerHelper($this);
379396

@@ -402,6 +419,8 @@ protected function setUp()
402419
'mediaGalleryEntryConverterPool' => $this->mediaGalleryEntryConverterPoolMock,
403420
'linkRepository' => $this->productLinkRepositoryMock,
404421
'catalogProductMediaConfig' => $this->mediaConfig,
422+
'_filesystem' => $this->filesystemMock,
423+
'_collectionFactory' => $this->collectionFactoryMock,
405424
'data' => ['id' => 1]
406425
]
407426
);
@@ -1230,6 +1249,71 @@ public function testSetMediaGalleryEntries()
12301249
$this->assertEquals($expectedResult, $this->model->getMediaGallery());
12311250
}
12321251

1252+
public function testGetMediaGalleryImagesMerging()
1253+
{
1254+
$mediaEntries = [
1255+
'images' => [
1256+
[
1257+
'value_id' => 1,
1258+
'file' => 'imageFile.jpg',
1259+
'media_type' => 'image',
1260+
],
1261+
[
1262+
'value_id' => 1,
1263+
'file' => 'imageFile.jpg',
1264+
],
1265+
[
1266+
'value_id' => 2,
1267+
'file' => 'smallImageFile.jpg',
1268+
'media_type' => 'image',
1269+
],
1270+
]
1271+
];
1272+
$expectedImageDataObject = new \Magento\Framework\DataObject([
1273+
'value_id' => 1,
1274+
'file' => 'imageFile.jpg',
1275+
'media_type' => 'image',
1276+
'url' => 'http://magento.dev/pub/imageFile.jpg',
1277+
'id' => 1,
1278+
'path' => '/var/www/html/pub/imageFile.jpg',
1279+
]);
1280+
$expectedSmallImageDataObject = new \Magento\Framework\DataObject([
1281+
'value_id' => 2,
1282+
'file' => 'smallImageFile.jpg',
1283+
'media_type' => 'image',
1284+
'url' => 'http://magento.dev/pub/smallImageFile.jpg',
1285+
'id' => 2,
1286+
'path' => '/var/www/html/pub/smallImageFile.jpg',
1287+
]);
1288+
1289+
$directoryMock = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\ReadInterface::class)
1290+
->disableOriginalConstructor()
1291+
->getMock();
1292+
$this->filesystemMock->expects($this->once())->method('getDirectoryRead')->willReturn($directoryMock);
1293+
$this->model->setData('media_gallery', $mediaEntries);
1294+
$imagesCollectionMock = $this->getMockBuilder(\Magento\Framework\Data\Collection::class)
1295+
->disableOriginalConstructor()
1296+
->getMock();
1297+
$this->collectionFactoryMock->expects($this->once())->method('create')->willReturn($imagesCollectionMock);
1298+
$imagesCollectionMock->expects($this->at(2))->method('getItemById')->with(1)->willReturn($expectedImageDataObject);
1299+
$this->mediaConfig->expects($this->at(0))
1300+
->method('getMediaUrl')
1301+
->willReturn('http://magento.dev/pub/imageFile.jpg');
1302+
$directoryMock->expects($this->at(0))
1303+
->method('getAbsolutePath')
1304+
->willReturn('/var/www/html/pub/imageFile.jpg');
1305+
$this->mediaConfig->expects($this->at(2))
1306+
->method('getMediaUrl')
1307+
->willReturn('http://magento.dev/pub/smallImageFile.jpg');
1308+
$directoryMock->expects($this->at(1))
1309+
->method('getAbsolutePath')
1310+
->willReturn('/var/www/html/pub/smallImageFile.jpg');
1311+
$imagesCollectionMock->expects($this->at(1))->method('addItem')->with($expectedImageDataObject);
1312+
$imagesCollectionMock->expects($this->at(4))->method('addItem')->with($expectedSmallImageDataObject);
1313+
1314+
$this->model->getMediaGalleryImages();
1315+
}
1316+
12331317
public function testGetCustomAttributes()
12341318
{
12351319
$priceCode = 'price';

app/code/Magento/Newsletter/Model/Subscriber.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ public function subscribe($email)
442442
$this->setStatusChanged(true);
443443

444444
try {
445+
/* Save model before sending out email */
445446
$this->save();
446447
if ($isConfirmNeed === true
447448
&& $isOwnSubscribes === false

app/code/Magento/Search/view/frontend/web/form-mini.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ define([
7979
}.bind(this));
8080

8181
this.element.on('blur', $.proxy(function () {
82+
if (!this.searchLabel.hasClass('active')) {
83+
return;
84+
}
8285

8386
setTimeout($.proxy(function () {
8487
if (this.autoComplete.is(':hidden')) {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Config\Test\Block\System\Config;
7+
8+
use Magento\Mtf\Block\Form;
9+
use Magento\Mtf\Client\Locator;
10+
11+
/**
12+
* Admin Security form in admin configurations.
13+
*
14+
* Locate Admin account sharing settings, see if its visible
15+
*/
16+
class AdminForm extends Form
17+
{
18+
private $adminAccountSharingField = '#admin_security_admin_account_sharing';
19+
20+
public function adminAccountSharingAvailability()
21+
{
22+
return $this->_rootElement->find($this->adminAccountSharingField, Locator::SELECTOR_CSS)->isVisible();
23+
}
24+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Config\Test\Constraint;
8+
9+
use Magento\Mtf\Constraint\AbstractConstraint;
10+
use Magento\Config\Test\Page\Adminhtml\AdminAccountSharing;
11+
12+
/**
13+
* Assert Admin account sharing is available in Stores>Configuration>advanced>admin grid.
14+
*/
15+
class AssertAdminAccountSharing extends AbstractConstraint
16+
{
17+
/**
18+
* Assert Admin account sharing is available in Stores>Configuration>advanced>admin grid.
19+
* @param AdminAccountSharing $adminAccountSharing
20+
*/
21+
public function processAssert(AdminAccountSharing $adminAccountSharing)
22+
{
23+
\PHPUnit_Framework_Assert::assertTrue(
24+
$adminAccountSharing->getAdminForm()->adminAccountSharingAvailability(),
25+
'Admin Account Sharing Option is not available'
26+
);
27+
}
28+
29+
/**
30+
* Returns a string representation of the object.
31+
*
32+
* @return string
33+
*/
34+
public function toString()
35+
{
36+
return 'Admin Account Sharing option is available and present in Stores>Configuration>Advanced>Admin Grid.';
37+
}
38+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd">
3+
<page name="AdminAccountSharing" area="Adminhtml" mca="admin/system_config/edit/section/admin/" module="Magento_Config">
4+
<block name="adminForm" class="Magento\Config\Test\Block\System\Config\AdminForm" locator="[id='page:main-container']" strategy="css selector" />
5+
</page>
6+
</config>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Config\Test\TestCase;
8+
9+
use Magento\Mtf\TestCase\Injectable;
10+
use Magento\Config\Test\Page\Adminhtml\AdminAccountSharing;
11+
12+
/**
13+
* Steps:
14+
* 1. Log in to Admin.
15+
* 2. Go to Stores>Configuration>Advanced>admin>Security.
16+
* 3. * 7. Verify admin Acoount Sharing option availability.
17+
*
18+
* @group Config_(PS)
19+
* @ZephyrId MAGETWO-47822
20+
*/
21+
class VerifyAdminAccountSharingEntityTest extends Injectable
22+
{
23+
/* tags */
24+
const MVP = 'yes';
25+
const DOMAIN = 'PS';
26+
const TEST_TYPE = 'extended_acceptance_test';
27+
/* end tags */
28+
29+
/**
30+
* Admin account settings page.
31+
*
32+
* @var adminAccountSharing
33+
*/
34+
private $adminAccountSharing;
35+
36+
/**
37+
* @param AdminAccountSharing $adminAccountSharing
38+
*/
39+
public function __inject(
40+
AdminAccountSharing $adminAccountSharing
41+
) {
42+
$this->adminAccountSharing = $adminAccountSharing;
43+
}
44+
45+
/**
46+
* Create Verify Admin Account Sharing test.
47+
*
48+
* @return void
49+
*/
50+
public function test()
51+
{
52+
$this->adminAccountSharing->open();
53+
sleep(10);
54+
}
55+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
9+
<testCase name="Magento\Config\Test\TestCase\VerifyAdminAccountSharingEntityTest" summary="Verify admin account sharing option availability" ticketId="MAGETWO-47822">
10+
<variation name="VerifyAdminAccountSharingEntityTestVariation1" summary="Verify Admin Account Sharing is available by default">
11+
<constraint name="Magento\Config\Test\Constraint\AssertAdminAccountSharing" />
12+
</variation>
13+
</testCase>
14+
</config>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Email\Test\Block\Adminhtml\Template\Edit;
7+
8+
use Magento\Mtf\Block\Form;
9+
use Magento\Mtf\Client\Locator;
10+
11+
/**
12+
* Click Load button in Email template form.
13+
* this class needs to be created because we need a customized click on the 'Load' button, its not a standard click
14+
*/
15+
class TemplateForm extends Form
16+
{
17+
private $loadButton = '#load';
18+
19+
/**
20+
* @return void
21+
*/
22+
public function clickLoadTemplate()
23+
{
24+
$element = $this->_rootElement->find($this->loadButton, Locator::SELECTOR_CSS); // locate the Load button
25+
$element->click(); // click the load button
26+
}
27+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<mapping strict="1">
9+
<fields>
10+
<template_select>
11+
<selector>#template_select</selector>
12+
<input>select</input>
13+
</template_select>
14+
<template_code/>
15+
</fields>
16+
</mapping>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Email\Test\Constraint;
7+
8+
use Magento\Email\Test\Page\Adminhtml\EmailTemplateIndex;
9+
use Magento\Mtf\Constraint\AbstractConstraint;
10+
11+
/**
12+
* Assertion to check Success Save Message for Email Template.
13+
*/
14+
class AssertEmailTemplateSuccessSaveMessage extends AbstractConstraint
15+
{
16+
const SUCCESS_MESSAGE = 'You saved the email template.';
17+
18+
/**
19+
* @param EmailTemplateIndex $emailTemplateIndex
20+
*/
21+
public function processAssert(EmailTemplateIndex $emailTemplateIndex)
22+
{
23+
$actualMessage = $emailTemplateIndex->getMessagesBlock()->getSuccessMessage();
24+
\PHPUnit_Framework_Assert::assertEquals(
25+
self::SUCCESS_MESSAGE,
26+
$actualMessage,
27+
'Wrong success message is displayed.'
28+
. "\nExpected: " . self::SUCCESS_MESSAGE
29+
. "\nActual: " . $actualMessage
30+
);
31+
}
32+
33+
/**
34+
* Text success save message is displayed
35+
*
36+
* @return string
37+
*/
38+
public function toString()
39+
{
40+
return 'Assert that success message is displayed.';
41+
}
42+
}

0 commit comments

Comments
 (0)