Skip to content

Commit

Permalink
Merge branch 'develop' into Fearless-Kiwis-MAGETWO-50123-Unable-to-as…
Browse files Browse the repository at this point in the history
…sign-blank-value-to-attribute
  • Loading branch information
cpartica committed Aug 22, 2016
2 parents 1de0edc + 8904497 commit 76d3f43
Show file tree
Hide file tree
Showing 18 changed files with 464 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function execute()
$attributesData[$attributeCode] = $value;
} elseif ($attribute->getFrontendInput() == 'multiselect') {
// Check if 'Change' checkbox has been checked by admin for this attribute
$isChanged = (bool)$this->getRequest()->getPost($attributeCode . '_checkbox');
$isChanged = (bool)$this->getRequest()->getPost('toggle_' . $attributeCode);
if (!$isChanged) {
unset($attributesData[$attributeCode]);
continue;
Expand Down
5 changes: 4 additions & 1 deletion app/code/Magento/Catalog/Model/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,10 @@ public function getMediaGalleryImages()
if (!$this->hasData('media_gallery_images') && is_array($this->getMediaGallery('images'))) {
$images = $this->_collectionFactory->create();
foreach ($this->getMediaGallery('images') as $image) {
if ((isset($image['disabled']) && $image['disabled']) || empty($image['value_id'])) {
if ((isset($image['disabled']) && $image['disabled'])
|| empty($image['value_id'])
|| $images->getItemById($image['value_id']) != null
) {
continue;
}
$image['url'] = $this->getMediaConfig()->getMediaUrl($image['file']);
Expand Down
84 changes: 84 additions & 0 deletions app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,16 @@ class ProductTest extends \PHPUnit_Framework_TestCase
*/
private $extensionAttributesFactory;

/**
* @var \Magento\Framework\Filesystem
*/
private $filesystemMock;

/**
* @var \Magento\Framework\Data\CollectionFactory
*/
private $collectionFactoryMock;

/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
Expand Down Expand Up @@ -374,6 +384,13 @@ protected function setUp()
$this->extensionAttributesFactory = $this->getMockBuilder(ExtensionAttributesFactory::class)
->disableOriginalConstructor()
->getMock();
$this->filesystemMock = $this->getMockBuilder(\Magento\Framework\Filesystem::class)
->disableOriginalConstructor()
->getMock();
$this->collectionFactoryMock = $this->getMockBuilder(\Magento\Framework\Data\CollectionFactory::class)
->disableOriginalConstructor()
->setMethods(['create'])
->getMock();
$this->mediaConfig = $this->getMock(\Magento\Catalog\Model\Product\Media\Config::class, [], [], '', false);
$this->objectManagerHelper = new ObjectManagerHelper($this);

Expand Down Expand Up @@ -402,6 +419,8 @@ protected function setUp()
'mediaGalleryEntryConverterPool' => $this->mediaGalleryEntryConverterPoolMock,
'linkRepository' => $this->productLinkRepositoryMock,
'catalogProductMediaConfig' => $this->mediaConfig,
'_filesystem' => $this->filesystemMock,
'_collectionFactory' => $this->collectionFactoryMock,
'data' => ['id' => 1]
]
);
Expand Down Expand Up @@ -1230,6 +1249,71 @@ public function testSetMediaGalleryEntries()
$this->assertEquals($expectedResult, $this->model->getMediaGallery());
}

public function testGetMediaGalleryImagesMerging()
{
$mediaEntries = [
'images' => [
[
'value_id' => 1,
'file' => 'imageFile.jpg',
'media_type' => 'image',
],
[
'value_id' => 1,
'file' => 'imageFile.jpg',
],
[
'value_id' => 2,
'file' => 'smallImageFile.jpg',
'media_type' => 'image',
],
]
];
$expectedImageDataObject = new \Magento\Framework\DataObject([
'value_id' => 1,
'file' => 'imageFile.jpg',
'media_type' => 'image',
'url' => 'http://magento.dev/pub/imageFile.jpg',
'id' => 1,
'path' => '/var/www/html/pub/imageFile.jpg',
]);
$expectedSmallImageDataObject = new \Magento\Framework\DataObject([
'value_id' => 2,
'file' => 'smallImageFile.jpg',
'media_type' => 'image',
'url' => 'http://magento.dev/pub/smallImageFile.jpg',
'id' => 2,
'path' => '/var/www/html/pub/smallImageFile.jpg',
]);

$directoryMock = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\ReadInterface::class)
->disableOriginalConstructor()
->getMock();
$this->filesystemMock->expects($this->once())->method('getDirectoryRead')->willReturn($directoryMock);
$this->model->setData('media_gallery', $mediaEntries);
$imagesCollectionMock = $this->getMockBuilder(\Magento\Framework\Data\Collection::class)
->disableOriginalConstructor()
->getMock();
$this->collectionFactoryMock->expects($this->once())->method('create')->willReturn($imagesCollectionMock);
$imagesCollectionMock->expects($this->at(2))->method('getItemById')->with(1)->willReturn($expectedImageDataObject);
$this->mediaConfig->expects($this->at(0))
->method('getMediaUrl')
->willReturn('http://magento.dev/pub/imageFile.jpg');
$directoryMock->expects($this->at(0))
->method('getAbsolutePath')
->willReturn('/var/www/html/pub/imageFile.jpg');
$this->mediaConfig->expects($this->at(2))
->method('getMediaUrl')
->willReturn('http://magento.dev/pub/smallImageFile.jpg');
$directoryMock->expects($this->at(1))
->method('getAbsolutePath')
->willReturn('/var/www/html/pub/smallImageFile.jpg');
$imagesCollectionMock->expects($this->at(1))->method('addItem')->with($expectedImageDataObject);
$imagesCollectionMock->expects($this->at(4))->method('addItem')->with($expectedSmallImageDataObject);

$this->model->getMediaGalleryImages();
}

public function testGetCustomAttributes()
{
$priceCode = 'price';
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Newsletter/Model/Subscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ public function subscribe($email)
$this->setStatusChanged(true);

try {
/* Save model before sending out email */
$this->save();
if ($isConfirmNeed === true
&& $isOwnSubscribes === false
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/Search/view/frontend/web/form-mini.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ define([
}.bind(this));

this.element.on('blur', $.proxy(function () {
if (!this.searchLabel.hasClass('active')) {
return;
}

setTimeout($.proxy(function () {
if (this.autoComplete.is(':hidden')) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Config\Test\Block\System\Config;

use Magento\Mtf\Block\Form;
use Magento\Mtf\Client\Locator;

/**
* Admin Security form in admin configurations.
*
* Locate Admin account sharing settings, see if its visible
*/
class AdminForm extends Form
{
private $adminAccountSharingField = '#admin_security_admin_account_sharing';

public function adminAccountSharingAvailability()
{
return $this->_rootElement->find($this->adminAccountSharingField, Locator::SELECTOR_CSS)->isVisible();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Config\Test\Constraint;

use Magento\Mtf\Constraint\AbstractConstraint;
use Magento\Config\Test\Page\Adminhtml\AdminAccountSharing;

/**
* Assert Admin account sharing is available in Stores>Configuration>advanced>admin grid.
*/
class AssertAdminAccountSharing extends AbstractConstraint
{
/**
* Assert Admin account sharing is available in Stores>Configuration>advanced>admin grid.
* @param AdminAccountSharing $adminAccountSharing
*/
public function processAssert(AdminAccountSharing $adminAccountSharing)
{
\PHPUnit_Framework_Assert::assertTrue(
$adminAccountSharing->getAdminForm()->adminAccountSharingAvailability(),
'Admin Account Sharing Option is not available'
);
}

/**
* Returns a string representation of the object.
*
* @return string
*/
public function toString()
{
return 'Admin Account Sharing option is available and present in Stores>Configuration>Advanced>Admin Grid.';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/pages.xsd">
<page name="AdminAccountSharing" area="Adminhtml" mca="admin/system_config/edit/section/admin/" module="Magento_Config">
<block name="adminForm" class="Magento\Config\Test\Block\System\Config\AdminForm" locator="[id='page:main-container']" strategy="css selector" />
</page>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Config\Test\TestCase;

use Magento\Mtf\TestCase\Injectable;
use Magento\Config\Test\Page\Adminhtml\AdminAccountSharing;

/**
* Steps:
* 1. Log in to Admin.
* 2. Go to Stores>Configuration>Advanced>admin>Security.
* 3. * 7. Verify admin Acoount Sharing option availability.
*
* @group Config_(PS)
* @ZephyrId MAGETWO-47822
*/
class VerifyAdminAccountSharingEntityTest extends Injectable
{
/* tags */
const MVP = 'yes';
const DOMAIN = 'PS';
const TEST_TYPE = 'extended_acceptance_test';
/* end tags */

/**
* Admin account settings page.
*
* @var adminAccountSharing
*/
private $adminAccountSharing;

/**
* @param AdminAccountSharing $adminAccountSharing
*/
public function __inject(
AdminAccountSharing $adminAccountSharing
) {
$this->adminAccountSharing = $adminAccountSharing;
}

/**
* Create Verify Admin Account Sharing test.
*
* @return void
*/
public function test()
{
$this->adminAccountSharing->open();
sleep(10);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
<testCase name="Magento\Config\Test\TestCase\VerifyAdminAccountSharingEntityTest" summary="Verify admin account sharing option availability" ticketId="MAGETWO-47822">
<variation name="VerifyAdminAccountSharingEntityTestVariation1" summary="Verify Admin Account Sharing is available by default">
<constraint name="Magento\Config\Test\Constraint\AssertAdminAccountSharing" />
</variation>
</testCase>
</config>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Email\Test\Block\Adminhtml\Template\Edit;

use Magento\Mtf\Block\Form;
use Magento\Mtf\Client\Locator;

/**
* Click Load button in Email template form.
* this class needs to be created because we need a customized click on the 'Load' button, its not a standard click
*/
class TemplateForm extends Form
{
private $loadButton = '#load';

/**
* @return void
*/
public function clickLoadTemplate()
{
$element = $this->_rootElement->find($this->loadButton, Locator::SELECTOR_CSS); // locate the Load button
$element->click(); // click the load button
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<mapping strict="1">
<fields>
<template_select>
<selector>#template_select</selector>
<input>select</input>
</template_select>
<template_code/>
</fields>
</mapping>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Email\Test\Constraint;

use Magento\Email\Test\Page\Adminhtml\EmailTemplateIndex;
use Magento\Mtf\Constraint\AbstractConstraint;

/**
* Assertion to check Success Save Message for Email Template.
*/
class AssertEmailTemplateSuccessSaveMessage extends AbstractConstraint
{
const SUCCESS_MESSAGE = 'You saved the email template.';

/**
* @param EmailTemplateIndex $emailTemplateIndex
*/
public function processAssert(EmailTemplateIndex $emailTemplateIndex)
{
$actualMessage = $emailTemplateIndex->getMessagesBlock()->getSuccessMessage();
\PHPUnit_Framework_Assert::assertEquals(
self::SUCCESS_MESSAGE,
$actualMessage,
'Wrong success message is displayed.'
. "\nExpected: " . self::SUCCESS_MESSAGE
. "\nActual: " . $actualMessage
);
}

/**
* Text success save message is displayed
*
* @return string
*/
public function toString()
{
return 'Assert that success message is displayed.';
}
}
Loading

0 comments on commit 76d3f43

Please sign in to comment.