diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php index 764040e9cfeb8..e4ad195921423 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Action/Attribute/Save.php @@ -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; diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php index b1fbe6aed9387..603e566f14fa1 100644 --- a/app/code/Magento/Catalog/Model/Product.php +++ b/app/code/Magento/Catalog/Model/Product.php @@ -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']); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php index 10bd9ddfd572a..d4950d9df6de7 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php @@ -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) */ @@ -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); @@ -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] ] ); @@ -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'; diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php index 10722de41c1d2..2deb4800bd023 100755 --- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php @@ -9,6 +9,7 @@ use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav; use Magento\Eav\Model\Config; use Magento\Framework\App\RequestInterface; +use Magento\Framework\EntityManager\EventManager; use Magento\Store\Model\StoreManagerInterface; use Magento\Store\Api\Data\StoreInterface; use Magento\Ui\DataProvider\EavValidationRules; @@ -27,11 +28,15 @@ use Magento\Catalog\Api\ProductAttributeRepositoryInterface; use Magento\Framework\Api\SearchResultsInterface; use Magento\Catalog\Api\Data\ProductAttributeInterface; +use Magento\Framework\Api\AttributeInterface; use Magento\Eav\Api\Data\AttributeGroupInterface; use Magento\Catalog\Model\ResourceModel\Eav\Attribute; use Magento\Framework\Currency; use Magento\Framework\Locale\Currency as CurrencyLocale; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Framework\Stdlib\ArrayManager; +use Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory as EavAttributeFactory; +use Magento\Framework\Event\ManagerInterface; /** * Class EavTest @@ -157,6 +162,26 @@ class EavTest extends AbstractModifierTest */ protected $currencyLocaleMock; + /** + * @var ProductAttributeInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $productAttributeMock; + + /** + * @var ArrayManager|\PHPUnit_Framework_MockObject_MockObject + */ + protected $arrayManagerMock; + + /** + * @var EavAttributeFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $eavAttributeFactoryMock; + + /** + * @var ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $eventManagerMock; + /** * @var ObjectManager */ @@ -167,6 +192,9 @@ class EavTest extends AbstractModifierTest */ protected $eav; + /** + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ protected function setUp() { parent::setUp(); @@ -228,10 +256,24 @@ protected function setUp() $this->searchResultsMock = $this->getMockBuilder(SearchResultsInterface::class) ->getMockForAbstractClass(); $this->eavAttributeMock = $this->getMockBuilder(Attribute::class) - ->setMethods(['getAttributeGroupCode', 'getApplyTo', 'getFrontendInput', 'getAttributeCode']) + ->setMethods(['load', 'getAttributeGroupCode', 'getApplyTo', 'getFrontendInput', 'getAttributeCode']) + ->disableOriginalConstructor() + ->getMock(); + $this->productAttributeMock = $this->getMockBuilder(ProductAttributeInterface::class) + ->getMock(); + $this->arrayManagerMock = $this->getMockBuilder(ArrayManager::class) + ->getMock(); + $this->eavAttributeFactoryMock = $this->getMockBuilder(EavAttributeFactory::class) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->eventManagerMock = $this->getMockBuilder(ManagerInterface::class) ->disableOriginalConstructor() ->getMock(); + $this->eavAttributeFactoryMock->expects($this->any()) + ->method('create') + ->willReturn($this->eavAttributeMock); $this->groupCollectionFactoryMock->expects($this->any()) ->method('create') ->willReturn($this->groupCollectionMock); @@ -277,6 +319,9 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods(['getCurrency']) ->getMock(); + $this->eavAttributeMock->expects($this->any()) + ->method('load') + ->willReturnSelf(); $this->eav =$this->getModel(); $this->objectManager->setBackwardCompatibleProperty( @@ -304,6 +349,9 @@ protected function createModel() 'attributeGroupRepository' => $this->attributeGroupRepositoryMock, 'sortOrderBuilder' => $this->sortOrderBuilderMock, 'attributeRepository' => $this->attributeRepositoryMock, + 'arrayManager' => $this->arrayManagerMock, + 'eavAttributeFactory' => $this->eavAttributeFactoryMock, + '_eventManager' => $this->eventManagerMock ]); } @@ -399,4 +447,162 @@ public function testModifyData() $this->assertEquals($sourceData, $this->eav->modifyData([])); } + + /** + * @param int $productId + * @param bool $productRequired + * @param string $attrValue + * @param array $expected + * @covers \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav::isProductExists + * @covers \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav::setupAttributeMeta + * @dataProvider setupAttributeMetaDataProvider + */ + public function testSetupAttributeMetaDefaultAttribute($productId, $productRequired, $attrValue, $expected) + { + $configPath = 'arguments/data/config'; + $groupCode = 'product-details'; + $sortOrder = '0'; + + $this->productMock->expects($this->any()) + ->method('getId') + ->willReturn($productId); + + $this->productAttributeMock->expects($this->any()) + ->method('getIsRequired') + ->willReturn($productRequired); + + $this->productAttributeMock->expects($this->any()) + ->method('getDefaultValue') + ->willReturn('required_value'); + + $this->productAttributeMock->expects($this->any()) + ->method('getAttributeCode') + ->willReturn('code'); + + $this->productAttributeMock->expects($this->any()) + ->method('getValue') + ->willReturn('value'); + + $attributeMock = $this->getMockBuilder(AttributeInterface::class) + ->disableOriginalConstructor() + ->getMock(); + + $attributeMock->expects($this->any()) + ->method('getValue') + ->willReturn($attrValue); + + $this->productMock->expects($this->any()) + ->method('getCustomAttribute') + ->willReturn($attributeMock); + + $this->arrayManagerMock->expects($this->any()) + ->method('set') + ->with( + $configPath, + [], + $expected + ) + ->willReturn($expected); + + $this->arrayManagerMock->expects($this->any()) + ->method('merge') + ->willReturn($expected); + + $this->arrayManagerMock->expects($this->any()) + ->method('get') + ->willReturn([]); + + $this->arrayManagerMock->expects($this->any()) + ->method('exists'); + + $this->assertEquals( + $expected, + $this->eav->setupAttributeMeta($this->productAttributeMock, $groupCode, $sortOrder) + ); + } + + /** + * @return array + */ + public function setupAttributeMetaDataProvider() + { + return [ + 'default_null_prod_not_new_and_required' => [ + 'productId' => 1, + 'productRequired' => true, + 'attrValue' => 'val', + 'expected' => [ + 'dataType' => null, + 'formElement' => null, + 'visible' => null, + 'required' => true, + 'notice' => null, + 'default' => null, + 'label' => null, + 'code' => 'code', + 'source' => 'product-details', + 'scopeLabel' => '', + 'globalScope' => false, + 'sortOrder' => 0 + ], + ], + 'default_null_prod_not_new_and_not_required' => [ + 'productId' => 1, + 'productRequired' => false, + 'attrValue' => 'val', + 'expected' => [ + 'dataType' => null, + 'formElement' => null, + 'visible' => null, + 'required' => false, + 'notice' => null, + 'default' => null, + 'label' => null, + 'code' => 'code', + 'source' => 'product-details', + 'scopeLabel' => '', + 'globalScope' => false, + 'sortOrder' => 0 + ], + ], + 'default_null_prod_new_and_not_required' => [ + 'productId' => null, + 'productRequired' => false, + 'attrValue' => null, + 'expected' => [ + 'dataType' => null, + 'formElement' => null, + 'visible' => null, + 'required' => false, + 'notice' => null, + 'default' => 'required_value', + 'label' => null, + 'code' => 'code', + 'source' => 'product-details', + 'scopeLabel' => '', + 'globalScope' => false, + 'sortOrder' => 0 + ], + ], + 'default_null_prod_new_and_required' => [ + 'productId' => null, + 'productRequired' => false, + 'attrValue' => null, + 'expected' => [ + 'dataType' => null, + 'formElement' => null, + 'visible' => null, + 'required' => false, + 'notice' => null, + 'default' => 'required_value', + 'label' => null, + 'code' => 'code', + 'source' => 'product-details', + 'scopeLabel' => '', + 'globalScope' => false, + 'sortOrder' => 0 + ], + ] + ]; + } } diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php index edab28873b5b7..1419c17e11b29 100755 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php @@ -522,6 +522,16 @@ private function getPreviousSetAttributes() return $this->prevSetAttributes; } + /** + * Check is product already new or we trying to create one + * + * @return bool + */ + private function isProductExists() + { + return (bool) $this->locator->getProduct()->getId(); + } + /** * Initial meta setup * @@ -531,6 +541,7 @@ private function getPreviousSetAttributes() * @return array * @throws \Magento\Framework\Exception\LocalizedException * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) * @api */ public function setupAttributeMeta(ProductAttributeInterface $attribute, $groupCode, $sortOrder) @@ -543,7 +554,7 @@ public function setupAttributeMeta(ProductAttributeInterface $attribute, $groupC 'visible' => $attribute->getIsVisible(), 'required' => $attribute->getIsRequired(), 'notice' => $attribute->getNote(), - 'default' => $attribute->getDefaultValue(), + 'default' => (!$this->isProductExists()) ? $attribute->getDefaultValue() : null, 'label' => $attribute->getDefaultFrontendLabel(), 'code' => $attribute->getAttributeCode(), 'source' => $groupCode, diff --git a/app/code/Magento/Newsletter/Model/Subscriber.php b/app/code/Magento/Newsletter/Model/Subscriber.php index 36f3c0711038f..6e614545b23d0 100644 --- a/app/code/Magento/Newsletter/Model/Subscriber.php +++ b/app/code/Magento/Newsletter/Model/Subscriber.php @@ -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 diff --git a/app/code/Magento/Search/view/frontend/web/form-mini.js b/app/code/Magento/Search/view/frontend/web/form-mini.js index 7c9bc4255fb21..9bb254a724768 100644 --- a/app/code/Magento/Search/view/frontend/web/form-mini.js +++ b/app/code/Magento/Search/view/frontend/web/form-mini.js @@ -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')) { diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/select.js b/app/code/Magento/Ui/view/base/web/js/form/element/select.js index ebcbd96789588..1887639c8d031 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/select.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/select.js @@ -44,9 +44,9 @@ define([ if (_.isUndefined(caption)) { caption = node.label; } - } else { - return node; } + + return node; }); return { @@ -194,7 +194,7 @@ define([ }, /** - * Matches specfied value with existing options + * Matches specified value with existing options * or, if value is not specified, returns value of the first option. * * @returns {*} @@ -286,6 +286,11 @@ define([ return preview; }, + /** + * + * @param {Number} value + * @returns {Object} Chainable + */ getOption: function (value) { return this.indexedOptions[value]; }, @@ -301,6 +306,19 @@ define([ this.value(value); return this; + }, + + /** + * Initializes observable properties of instance + * + * @returns {Object} Chainable. + */ + setInitialValue: function () { + if (_.isUndefined(this.value()) && !this.default) { + this.clear(); + } + + return this._super(); } }); }); diff --git a/dev/tests/functional/tests/app/Magento/Config/Test/Block/System/Config/AdminForm.php b/dev/tests/functional/tests/app/Magento/Config/Test/Block/System/Config/AdminForm.php new file mode 100644 index 0000000000000..38bb261cb790e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Config/Test/Block/System/Config/AdminForm.php @@ -0,0 +1,24 @@ +_rootElement->find($this->adminAccountSharingField, Locator::SELECTOR_CSS)->isVisible(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Config/Test/Constraint/AssertAdminAccountSharing.php b/dev/tests/functional/tests/app/Magento/Config/Test/Constraint/AssertAdminAccountSharing.php new file mode 100644 index 0000000000000..ae01915bef395 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Config/Test/Constraint/AssertAdminAccountSharing.php @@ -0,0 +1,38 @@ +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.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Config/Test/Page/Adminhtml/AdminAccountSharing.xml b/dev/tests/functional/tests/app/Magento/Config/Test/Page/Adminhtml/AdminAccountSharing.xml new file mode 100644 index 0000000000000..0369a7746d528 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Config/Test/Page/Adminhtml/AdminAccountSharing.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Config/Test/TestCase/VerifyAdminAccountSharingEntityTest.php b/dev/tests/functional/tests/app/Magento/Config/Test/TestCase/VerifyAdminAccountSharingEntityTest.php new file mode 100644 index 0000000000000..30928810490d7 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Config/Test/TestCase/VerifyAdminAccountSharingEntityTest.php @@ -0,0 +1,55 @@ +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); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Config/Test/TestCase/VerifyAdminAccountSharingEntityTest.xml b/dev/tests/functional/tests/app/Magento/Config/Test/TestCase/VerifyAdminAccountSharingEntityTest.xml new file mode 100644 index 0000000000000..46b043e6fb5a6 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Config/Test/TestCase/VerifyAdminAccountSharingEntityTest.xml @@ -0,0 +1,14 @@ + + + + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Email/Test/Block/Adminhtml/Template/Edit/TemplateForm.php b/dev/tests/functional/tests/app/Magento/Email/Test/Block/Adminhtml/Template/Edit/TemplateForm.php new file mode 100644 index 0000000000000..8cd455b6bed8d --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Email/Test/Block/Adminhtml/Template/Edit/TemplateForm.php @@ -0,0 +1,27 @@ +_rootElement->find($this->loadButton, Locator::SELECTOR_CSS); // locate the Load button + $element->click(); // click the load button + } +} diff --git a/dev/tests/functional/tests/app/Magento/Email/Test/Block/Adminhtml/Template/Edit/TemplateForm.xml b/dev/tests/functional/tests/app/Magento/Email/Test/Block/Adminhtml/Template/Edit/TemplateForm.xml new file mode 100644 index 0000000000000..b8bd0ee922a06 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Email/Test/Block/Adminhtml/Template/Edit/TemplateForm.xml @@ -0,0 +1,16 @@ + + + + + + #template_select + select + + + + \ No newline at end of file diff --git a/dev/tests/functional/tests/app/Magento/Email/Test/Constraint/AssertEmailTemplateSuccessSaveMessage.php b/dev/tests/functional/tests/app/Magento/Email/Test/Constraint/AssertEmailTemplateSuccessSaveMessage.php new file mode 100644 index 0000000000000..4fbba15df27e7 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Email/Test/Constraint/AssertEmailTemplateSuccessSaveMessage.php @@ -0,0 +1,42 @@ +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.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Email/Test/Fixture/EmailTemplate.xml b/dev/tests/functional/tests/app/Magento/Email/Test/Fixture/EmailTemplate.xml new file mode 100644 index 0000000000000..92870a5ebab3b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Email/Test/Fixture/EmailTemplate.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Email/Test/Page/Adminhtml/EmailTemplateIndex.xml b/dev/tests/functional/tests/app/Magento/Email/Test/Page/Adminhtml/EmailTemplateIndex.xml new file mode 100644 index 0000000000000..dbb64d68dcd9e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Email/Test/Page/Adminhtml/EmailTemplateIndex.xml @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Email/Test/Page/Adminhtml/EmailTemplateNew.xml b/dev/tests/functional/tests/app/Magento/Email/Test/Page/Adminhtml/EmailTemplateNew.xml new file mode 100644 index 0000000000000..9c0b1a626e139 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Email/Test/Page/Adminhtml/EmailTemplateNew.xml @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/dev/tests/functional/tests/app/Magento/Email/Test/TestCase/CreateEmailTemplateEntityTest.php b/dev/tests/functional/tests/app/Magento/Email/Test/TestCase/CreateEmailTemplateEntityTest.php new file mode 100644 index 0000000000000..dc86b6479757e --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Email/Test/TestCase/CreateEmailTemplateEntityTest.php @@ -0,0 +1,77 @@ +emailTemplateIndex = $emailTemplateIndex; + $this->emailTemplateNew = $emailTemplateNew; + } + + /** + * @param EmailTemplate $emailTemplate + */ + + public function test(EmailTemplate $emailTemplate) + { + $this->emailTemplateIndex->open(); + $this->emailTemplateIndex->getPageActionsBlock()->addNew(); + $this->emailTemplateNew->getTemplateForm()->fill($emailTemplate); + $this->emailTemplateNew->getTemplateForm()->clickLoadTemplate(); + $this->emailTemplateNew->getFormPageActions()->save(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Email/Test/TestCase/CreateEmailTemplateEntityTest.xml b/dev/tests/functional/tests/app/Magento/Email/Test/TestCase/CreateEmailTemplateEntityTest.xml new file mode 100644 index 0000000000000..57b95ad424300 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Email/Test/TestCase/CreateEmailTemplateEntityTest.xml @@ -0,0 +1,16 @@ + + + + + + Change Email + Test code_%isolation% + + + + \ No newline at end of file diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/EavTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/EavTest.php index ffcf5096b103f..eeba8d78cead1 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/EavTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/EavTest.php @@ -70,6 +70,19 @@ public function testModifyMeta() $this->prepareDataForComparison($actualMeta, $expectedMeta); $this->assertEquals($expectedMeta, $actualMeta); } + + public function testModifyMetaNewProduct() + { + $this->objectManager->get(\Magento\Eav\Model\Entity\AttributeCache::class)->clear(); + /** @var \Magento\Catalog\Model\Product $product */ + $product = $this->objectManager->create(\Magento\Catalog\Model\Product::class); + $product->setAttributeSetId(4); + $this->locatorMock->expects($this->any())->method('getProduct')->willReturn($product); + $expectedMeta = include __DIR__ . '/_files/eav_expected_meta_output_w_default.php'; + $actualMeta = $this->eavModifier->modifyMeta([]); + $this->prepareDataForComparison($actualMeta, $expectedMeta); + $this->assertEquals($expectedMeta, $actualMeta); + } /** * @magentoDataFixture Magento/Catalog/_files/product_simple_with_admin_store.php diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/_files/eav_expected_meta_output.php b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/_files/eav_expected_meta_output.php index 1f22ec3b1c6eb..29b092177b522 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/_files/eav_expected_meta_output.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/_files/eav_expected_meta_output.php @@ -35,7 +35,6 @@ "visible" => "1", "required" => "0", "label" => "Enable Product", - "default" => "1", "source" => "product-details", "scopeLabel" => "[WEBSITE]", "globalScope" => false, diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/_files/eav_expected_meta_output_w_default.php b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/_files/eav_expected_meta_output_w_default.php new file mode 100644 index 0000000000000..999a96d29811f --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/_files/eav_expected_meta_output_w_default.php @@ -0,0 +1,105 @@ + [ + "arguments" => [ + "data" => [ + "config" => [ + "dataScope" => "data.product", + ], + ], + ], + "children" => [ + "container_status" => [ + "children" => [ + "status" => [ + "arguments" => [ + "data" => [ + "config" => [ + "dataType" => "select", + "formElement" => "select", + "options" => [ + [ + "value" => 1, + "label" => "Enabled" + ], + [ + "value" => 2, + "label" => "Disabled" + ] + ], + "visible" => "1", + "required" => "0", + "label" => "Enable Product", + "default" => "1", + "source" => "product-details", + "scopeLabel" => "[WEBSITE]", + "globalScope" => false, + "code" => "status", + "sortOrder" => "__placeholder__", + "componentType" => "field" + ], + ], + ], + ], + ], + ], + "container_name" => [ + "children" => [ + "name" => [ + "arguments" => [ + "data" => [ + "config" => [ + "dataType" => "text", + "formElement" => "input", + "visible" => "1", + "required" => "1", + "label" => "Product Name", + "source" => "product-details", + "scopeLabel" => "[STORE VIEW]", + "globalScope" => false, + "code" => "name", + "sortOrder" => "__placeholder__", + "componentType" => "field", + "validation" => [ + "required-entry" => true + ], + ], + ], + ], + ], + ], + ], + "container_sku" => [ + "children" => [ + "sku" => [ + "arguments" => [ + "data" => [ + "config" => [ + "dataType" => "text", + "formElement" => "input", + "visible" => "1", + "required" => "1", + "label" => "SKU", + "source" => "product-details", + "scopeLabel" => "[GLOBAL]", + "globalScope" => true, + "code" => "sku", + "sortOrder" => "__placeholder__", + "componentType" => "field", + "validation" => [ + "required-entry" => true + ], + ], + ], + ], + ], + ], + ], + ], + ], +];