From 93364fe386d1acd87c20d9d1d32e0a4602f923d8 Mon Sep 17 00:00:00 2001 From: Lorenzo Date: Fri, 10 Jun 2016 12:39:44 +0200 Subject: [PATCH 001/202] block newsletter title The title string is hardcoded! --- .../Magento/Newsletter/view/frontend/templates/subscribe.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Newsletter/view/frontend/templates/subscribe.phtml b/app/code/Magento/Newsletter/view/frontend/templates/subscribe.phtml index a8b63a3057268..2f30df4f82aab 100644 --- a/app/code/Magento/Newsletter/view/frontend/templates/subscribe.phtml +++ b/app/code/Magento/Newsletter/view/frontend/templates/subscribe.phtml @@ -8,7 +8,7 @@ ?>
-
Newsletter
+
From 0a3cd4600e20800321c6e2bdd9c33c0dd6aa2f72 Mon Sep 17 00:00:00 2001 From: pdanzinger Date: Thu, 8 Sep 2016 22:54:56 +0200 Subject: [PATCH 019/202] Remove obsolete comment in catalog_category_view.xml In catalog_category_view.xml there is an XML comment that tells developers they can change the pager increments using methods like "addPagerLimit". These settings can be found in the backend now and the method "addPagerLimit" is only to be found in a list of deprecated methods I think it is safe to assume this comment doesn't serve a purpose anymore. --- .../frontend/layout/catalog_category_view.xml | 47 ------------------- 1 file changed, 47 deletions(-) diff --git a/app/code/Magento/Catalog/view/frontend/layout/catalog_category_view.xml b/app/code/Magento/Catalog/view/frontend/layout/catalog_category_view.xml index 4c8ae8eaae952..298cdcc29e953 100644 --- a/app/code/Magento/Catalog/view/frontend/layout/catalog_category_view.xml +++ b/app/code/Magento/Catalog/view/frontend/layout/catalog_category_view.xml @@ -28,53 +28,6 @@ - - product_list_toolbar From e788a2421f5cfe2df9d5028b08141d92f70819b8 Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Wed, 28 Sep 2016 11:15:04 +0300 Subject: [PATCH 020/202] MAGETWO-58730: [Github] Incorrect province code sent on Checkout to UPS #6564 --- .../view/frontend/web/js/model/address-converter.js | 7 +++++++ .../view/frontend/web/js/model/new-customer-address.js | 2 +- .../view/frontend/web/js/model/shipping-rates-validator.js | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js b/app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js index 2d6fa460ef66d..3ec34cd96574b 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/address-converter.js @@ -44,6 +44,13 @@ define( addressData.region.region_code = region['code']; addressData.region.region = region['name']; } + } else if ( + !addressData.region_id + && countryData()[addressData.country_id] + && countryData()[addressData.country_id]['regions'] + ) { + addressData.region.region_code = ''; + addressData.region.region = ''; } delete addressData.region_id; diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/new-customer-address.js b/app/code/Magento/Checkout/view/frontend/web/js/model/new-customer-address.js index bee4480b0dfb1..fe05dcebfc99a 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/new-customer-address.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/new-customer-address.js @@ -22,7 +22,7 @@ define([], function () { return { email: addressData.email, countryId: addressData['country_id'] || addressData.countryId || window.checkoutConfig.defaultCountryId, - regionId: regionId, + regionId: regionId || addressData.regionId, regionCode: (addressData.region) ? addressData.region.region_code : null, region: (addressData.region) ? addressData.region.region : null, customerId: addressData.customer_id, diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rates-validator.js b/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rates-validator.js index 420d50b83478a..c49960ecfb91d 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rates-validator.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rates-validator.js @@ -176,7 +176,7 @@ define( address; if (this.validateAddressData(addressFlat)) { - addressFlat = $.extend(true, {}, quote.shippingAddress(), addressFlat); + addressFlat = uiRegistry.get('checkoutProvider').shippingAddress; address = addressConverter.formAddressDataToQuoteAddress(addressFlat); selectShippingAddress(address); } From 4d33a75b6d87e84db7b667e525666378920b9f72 Mon Sep 17 00:00:00 2001 From: vnayda Date: Wed, 28 Sep 2016 11:45:29 +0300 Subject: [PATCH 021/202] MAGETWO-58482: [FT] Magento\ConfigurableProduct\Test\TestCase\CreateConfigurableProductEntityTest failed --- .../AssertConfigurableProductPage.php | 20 +++++++++++++------ .../Repository/ConfigurableProduct/Price.xml | 3 +++ .../CreateConfigurableProductEntityTest.xml | 1 + 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductPage.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductPage.php index 62d6c72efe8c6..ad9807b76d6e5 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductPage.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductPage.php @@ -125,15 +125,23 @@ protected function verifyAttributesMatrix($variationsMatrix, $generatedMatrix) protected function getLowestConfigurablePrice() { $price = null; - $configurableOptions = $this->product->getConfigurableAttributesData(); - - foreach ($configurableOptions['matrix'] as $option) { - $price = $price === null ? $option['price'] : $price; - if ($price > $option['price']) { - $price = $option['price']; + $priceDataConfig = $this->product->getDataFieldConfig('price'); + if (isset($priceDataConfig['source'])) { + $priceData = $priceDataConfig['source']->getPriceData(); + if (isset($priceData['price_from'])) { + $price = $priceData['price_from']; } } + if (null === $price) { + $configurableOptions = $this->product->getConfigurableAttributesData(); + foreach ($configurableOptions['matrix'] as $option) { + $price = $price === null ? $option['price'] : $price; + if ($price > $option['price']) { + $price = $option['price']; + } + } + } return $price; } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/Price.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/Price.xml index 2e9d708dd42d8..1b6282b9432c3 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/Price.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Repository/ConfigurableProduct/Price.xml @@ -17,5 +17,8 @@ 11 + + 9 + diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.xml index 58435b066261e..187283da4602f 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.xml @@ -58,6 +58,7 @@ configurable_two_new_options_with_special_price Configurable Product %isolation% configurable_sku_%isolation% + from-9 100 9 Configurable short description From 06034a1e4a3a1c2a76e3263138d8ef5018c00292 Mon Sep 17 00:00:00 2001 From: Leonid Poluyanov Date: Wed, 28 Sep 2016 16:10:30 +0300 Subject: [PATCH 022/202] MAGETWO-57989: Unable to create custom image attribute in category --- .../Controller/Adminhtml/Category/Save.php | 14 +- .../Category/Attribute/Backend/Image.php | 19 +- .../Catalog/Model/Category/DataProvider.php | 4 +- .../Adminhtml/Category/Image/UploadTest.php | 25 ++- .../Adminhtml/Category/SaveTest.php | 39 ++-- .../Category/Attribute/Backend/ImageTest.php | 115 ++++++------ .../Catalog/Test/Unit/Model/CategoryTest.php | 172 +++++++++++------- .../base/web/js/form/element/file-uploader.js | 9 +- 8 files changed, 223 insertions(+), 174 deletions(-) diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php index 492bf1c021cf0..b8fe7df8189de 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php @@ -6,7 +6,7 @@ namespace Magento\Catalog\Controller\Adminhtml\Category; use Magento\Store\Model\StoreManagerInterface; -use \Magento\Catalog\Api\Data\CategoryAttributeInterface; +use Magento\Catalog\Api\Data\CategoryAttributeInterface; /** * Class Save @@ -70,14 +70,15 @@ public function __construct( \Magento\Framework\Controller\Result\JsonFactory $resultJsonFactory, \Magento\Framework\View\LayoutFactory $layoutFactory, StoreManagerInterface $storeManager, - \Magento\Eav\Model\Config $eavConfig + \Magento\Eav\Model\Config $eavConfig = null ) { parent::__construct($context); $this->resultRawFactory = $resultRawFactory; $this->resultJsonFactory = $resultJsonFactory; $this->layoutFactory = $layoutFactory; $this->storeManager = $storeManager; - $this->eavConfig = $eavConfig; + $this->eavConfig = $eavConfig + ?: \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Eav\Model\Config::class); } /** @@ -233,9 +234,10 @@ public function execute() } /** - * @param array $data Category data - * @return mixed - * @throws \Magento\Framework\Exception\LocalizedException + * Sets image attribute data to false if image was removed + * + * @param array $data + * @return array */ public function imagePreprocessing(array $data) { diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Image.php b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Image.php index efd3a4afb4a60..4d5a811211bf7 100644 --- a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Image.php +++ b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/Image.php @@ -48,34 +48,29 @@ class Image extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend */ private $imageUploader; - /** - * @var \Magento\Framework\ObjectManagerInterface - */ - private $objectManager; - /** * @param \Psr\Log\LoggerInterface $logger * @param \Magento\Framework\Filesystem $filesystem * @param \Magento\MediaStorage\Model\File\UploaderFactory $fileUploaderFactory - * @param \Magento\Framework\ObjectManagerInterface $objectManager */ public function __construct( \Psr\Log\LoggerInterface $logger, \Magento\Framework\Filesystem $filesystem, - \Magento\MediaStorage\Model\File\UploaderFactory $fileUploaderFactory, - \Magento\Framework\ObjectManagerInterface $objectManager + \Magento\MediaStorage\Model\File\UploaderFactory $fileUploaderFactory ) { $this->_filesystem = $filesystem; $this->_fileUploaderFactory = $fileUploaderFactory; $this->_logger = $logger; - $this->objectManager = $objectManager; } /** + * Gets image name from $value array. + * Will return empty string in a case when $value is not an array + * * @param array $value Attribute value * @return string */ - protected function getUploadedImageName($value) + private function getUploadedImageName($value) { if (is_array($value) && isset($value[0]['name'])) { return $value[0]['name']; @@ -86,6 +81,7 @@ protected function getUploadedImageName($value) /** * Avoiding saving potential upload data to DB + * Will set empty image attribute value if image was not uploaded * * @param \Magento\Framework\DataObject $object * @return $this @@ -113,7 +109,8 @@ public function beforeSave($object) private function getImageUploader() { if ($this->imageUploader === null) { - $this->imageUploader = $this->objectManager->get(\Magento\Catalog\CategoryImageUpload::class); + $this->imageUploader = \Magento\Framework\App\ObjectManager::getInstance() + ->get(\Magento\Catalog\CategoryImageUpload::class); } return $this->imageUploader; diff --git a/app/code/Magento/Catalog/Model/Category/DataProvider.php b/app/code/Magento/Catalog/Model/Category/DataProvider.php index 8ea60d54ec556..aefd31e21ad62 100644 --- a/app/code/Magento/Catalog/Model/Category/DataProvider.php +++ b/app/code/Magento/Catalog/Model/Category/DataProvider.php @@ -370,11 +370,13 @@ protected function filterFields($categoryData) } /** + * Converts category image data to acceptable for rendering format + * * @param \Magento\Catalog\Model\Category $category * @param array $categoryData * @return array */ - protected function convertValues($category, $categoryData) + private function convertValues($category, $categoryData) { foreach ($category->getAttributes() as $attributeCode => $attribute) { if (!isset($categoryData[$attributeCode])) { diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Image/UploadTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Image/UploadTest.php index 40c40a17b8e52..e49da3972e0a0 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Image/UploadTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/Image/UploadTest.php @@ -5,27 +5,26 @@ */ namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Category\Image; -use \Magento\Catalog\Controller\Adminhtml\Category\Image\Upload as Model; -use \Magento\Framework\App\Request\Http as Request; -use \Magento\Catalog\Model\ImageUploader; -use \Magento\Framework\Controller\ResultFactory; -use \Magento\Framework\DataObject; -use \Magento\Backend\App\Action\Context; +use Magento\Catalog\Controller\Adminhtml\Category\Image\Upload as Model; +use Magento\Framework\App\Request\Http as Request; +use Magento\Catalog\Model\ImageUploader; +use Magento\Framework\Controller\ResultFactory; +use Magento\Framework\DataObject; +use Magento\Backend\App\Action\Context; /** * Class UploadTest - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class UploadTest extends \PHPUnit_Framework_TestCase { - protected $objectManager; + private $objectManager; protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); } - public function uploadedImageNameProvider() + public function executeDataProvider() { return [ ['image1', 'image1'], @@ -35,12 +34,12 @@ public function uploadedImageNameProvider() } /** - * @param $name - * @param $savedName + * @param string $name + * @param string $savedName * - * @dataProvider uploadedImageNameProvider + * @dataProvider executeDataProvider */ - public function testExecuteShouldSaveUploadedImageWithSpecifiedNameToTmpFolder($name, $savedName) + public function testExecute($name, $savedName) { $request = $this->objectManager->getObject(Request::class); diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php index 9ef502b9640ca..58557e25d970b 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php @@ -16,67 +16,67 @@ class SaveTest extends \PHPUnit_Framework_TestCase /** * @var \Magento\Backend\Model\View\Result\RedirectFactory|\PHPUnit_Framework_MockObject_MockObject */ - protected $resultRedirectFactoryMock; + private $resultRedirectFactoryMock; /** * @var \Magento\Framework\Controller\Result\RawFactory|\PHPUnit_Framework_MockObject_MockObject */ - protected $resultRawFactoryMock; + private $resultRawFactoryMock; /** * @var \Magento\Framework\Controller\Result\JsonFactory|\PHPUnit_Framework_MockObject_MockObject */ - protected $resultJsonFactoryMock; + private $resultJsonFactoryMock; /** * @var \Magento\Framework\View\LayoutFactory|\PHPUnit_Framework_MockObject_MockObject */ - protected $layoutFactoryMock; + private $layoutFactoryMock; /** * @var \Magento\Backend\App\Action\Context|\PHPUnit_Framework_MockObject_MockObject */ - protected $contextMock; + private $contextMock; /** * @var \Magento\Framework\View\Page\Title|\PHPUnit_Framework_MockObject_MockObject */ - protected $titleMock; + private $titleMock; /** * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $requestMock; + private $requestMock; /** * @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $objectManagerMock; + private $objectManagerMock; /** * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $eventManagerMock; + private $eventManagerMock; /** * @var \Magento\Framework\App\ResponseInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $responseMock; + private $responseMock; /** * @var \Magento\Framework\Message\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $messageManagerMock; + private $messageManagerMock; /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager */ - protected $objectManager; + private $objectManager; /** * @var \Magento\Catalog\Controller\Adminhtml\Category\Save */ - protected $save; + private $save; /** * Set up @@ -581,7 +581,10 @@ public function dataProviderExecute() ]; } - public function attributeValueDataProvider() + /** + * @return array + */ + public function imagePreprocessingDataProvider() { return [ [['attribute1' => null, 'attribute2' => 123]], @@ -590,11 +593,11 @@ public function attributeValueDataProvider() } /** - * @dataProvider attributeValueDataProvider + * @dataProvider imagePreprocessingDataProvider * - * @param $data + * @param array $data */ - public function testImagePreprocessingShouldSetAttributesWithImageBackendToFalse($data) + public function testImagePreprocessingWithoutValue($data) { $eavConfig = $this->getMock(\Magento\Eav\Model\Config::class, ['getEntityType'], [], '', false); @@ -630,7 +633,7 @@ public function testImagePreprocessingShouldSetAttributesWithImageBackendToFalse ], $result); } - public function testImagePreprocessingShouldNotSetValueToFalseWhenValueSet() + public function testImagePreprocessingWithValue() { $eavConfig = $this->getMock(\Magento\Eav\Model\Config::class, ['getEntityType'], [], '', false); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/ImageTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/ImageTest.php index 2bd41e6bca343..aa78fea896687 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/ImageTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/Attribute/Backend/ImageTest.php @@ -5,29 +5,27 @@ */ namespace Magento\Catalog\Test\Unit\Model\Category\Attribute\Backend; -use \Magento\Catalog\Model\Category\Attribute\Backend\Image as Model; - class ImageTest extends \PHPUnit_Framework_TestCase { /** * @var \Magento\Eav\Model\Entity\Attribute\AbstractAttribute */ - protected $attribute; + private $attribute; /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager */ - protected $objectManager; + private $objectManager; /** * @var \Magento\Catalog\Model\ImageUploader */ - protected $imageUploader; + private $imageUploader; /** * @var \Psr\Log\LoggerInterface */ - protected $logger; + private $logger; protected function setUp() { @@ -66,7 +64,10 @@ protected function setUp() ); } - public function deletionValueProvider() + /** + * @return array + */ + public function deletedValueDataProvider() { return [ [false], @@ -75,13 +76,13 @@ public function deletionValueProvider() } /** - * @dataProvider deletionValueProvider + * @dataProvider deletedValueDataProvider * - * @param $value + * @param array $value */ - public function testBeforeSaveShouldSetAttributeValueToBlankWhenImageValueRequiresDeletion($value) + public function testBeforeSaveValueDeletion($value) { - $model = $this->objectManager->getObject(Model::class); + $model = $this->objectManager->getObject(\Magento\Catalog\Model\Category\Attribute\Backend\Image::class); $model->setAttribute($this->attribute); $object = new \Magento\Framework\DataObject([ @@ -93,7 +94,10 @@ public function testBeforeSaveShouldSetAttributeValueToBlankWhenImageValueRequir $this->assertEquals('', $object->getTestAttribute()); } - public function invalidValueProvider() + /** + * @return array + */ + public function invalidValueDataProvider() { $closure = function () { return false; @@ -109,13 +113,13 @@ public function invalidValueProvider() } /** - * @dataProvider invalidValueProvider + * @dataProvider invalidValueDataProvider * - * @param $value + * @param array $value */ - public function testBeforeSaveShouldSetAttributeValueToBlankWhenImageValueInvalid($value) + public function testBeforeSaveValueInvalid($value) { - $model = $this->objectManager->getObject(Model::class); + $model = $this->objectManager->getObject(\Magento\Catalog\Model\Category\Attribute\Backend\Image::class); $model->setAttribute($this->attribute); $object = new \Magento\Framework\DataObject([ @@ -127,9 +131,9 @@ public function testBeforeSaveShouldSetAttributeValueToBlankWhenImageValueInvali $this->assertEquals('', $object->getTestAttribute()); } - public function testBeforeSaveShouldSetAttributeValueToUploadedImageName() + public function testBeforeSaveAttributeFileName() { - $model = $this->objectManager->getObject(Model::class); + $model = $this->objectManager->getObject(\Magento\Catalog\Model\Category\Attribute\Backend\Image::class); $model->setAttribute($this->attribute); $object = new \Magento\Framework\DataObject([ @@ -143,27 +147,27 @@ public function testBeforeSaveShouldSetAttributeValueToUploadedImageName() $this->assertEquals('test123.jpg', $object->getTestAttribute()); } - public function testBeforeSaveShouldSetAttributeUploadInformationToTemporaryAttribute() + public function testBeforeSaveTemporaryAttribute() { - $model = $this->objectManager->getObject(Model::class); + $model = $this->objectManager->getObject(\Magento\Catalog\Model\Category\Attribute\Backend\Image::class); $model->setAttribute($this->attribute); $object = new \Magento\Framework\DataObject([ 'test_attribute' => [ - ['name' => 'test123.jpg', 'tmp_name' => 'abc123', 'url' => 'http://www.test.com/test123.jpg'] + ['name' => 'test123.jpg', 'tmp_name' => 'abc123', 'url' => 'http://www.example.com/test123.jpg'] ] ]); $model->beforeSave($object); $this->assertEquals([ - ['name' => 'test123.jpg', 'tmp_name' => 'abc123', 'url' => 'http://www.test.com/test123.jpg'] + ['name' => 'test123.jpg', 'tmp_name' => 'abc123', 'url' => 'http://www.example.com/test123.jpg'] ], $object->getData('_additional_data_test_attribute')); } - public function testBeforeSaveShouldNotModifyAttributeValueWhenStringValue() + public function testBeforeSaveAttributeStringValue() { - $model = $this->objectManager->getObject(Model::class); + $model = $this->objectManager->getObject(\Magento\Catalog\Model\Category\Attribute\Backend\Image::class); $model->setAttribute($this->attribute); $object = new \Magento\Framework\DataObject([ @@ -173,23 +177,13 @@ public function testBeforeSaveShouldNotModifyAttributeValueWhenStringValue() $model->beforeSave($object); $this->assertEquals('test123.jpg', $object->getTestAttribute()); - } - - public function testBeforeSaveShouldNotSetAdditionalDataWhenStringValue() - { - $model = $this->objectManager->getObject(Model::class); - $model->setAttribute($this->attribute); - - $object = new \Magento\Framework\DataObject([ - 'test_attribute' => 'test123.jpg' - ]); - - $model->beforeSave($object); - $this->assertNull($object->getData('_additional_data_test_attribute')); } - protected function setUpModelForAfterSave() + /** + * @return \Magento\Catalog\Model\Category\Attribute\Backend\Image + */ + private function setUpModelForAfterSave() { $objectManagerMock = $this->getMock( \Magento\Framework\App\ObjectManager::class, @@ -211,15 +205,16 @@ protected function setUpModelForAfterSave() return $this->objectManager->get($class, $params); })); - $model = $this->objectManager->getObject(Model::class, [ + $model = $this->objectManager->getObject(\Magento\Catalog\Model\Category\Attribute\Backend\Image::class, [ 'objectManager' => $objectManagerMock, 'logger' => $this->logger ]); + $this->objectManager->setBackwardCompatibleProperty($model, 'imageUploader', $this->imageUploader); return $model->setAttribute($this->attribute); } - public function attributeValidValueProvider() + public function attributeValueDataProvider() { return [ [[['name' => 'test1234.jpg']]], @@ -230,11 +225,11 @@ public function attributeValidValueProvider() } /** - * @dataProvider attributeValidValueProvider + * @dataProvider attributeValueDataProvider * - * @param $value + * @param array $value */ - public function testAfterSaveShouldUploadImageWhenAdditionalDataSet($value) + public function testAfterSaveWithAdditionalData($value) { $model = $this->setUpModelForAfterSave(); @@ -242,36 +237,38 @@ public function testAfterSaveShouldUploadImageWhenAdditionalDataSet($value) ->method('moveFileFromTmp') ->with($this->equalTo('test1234.jpg')); - $object = new \Magento\Framework\DataObject([ - 'test_attribute' => $value, - '_additional_data_test_attribute' => [ - ['name' => 'test1234.jpg'] + $object = new \Magento\Framework\DataObject( + [ + 'test_attribute' => $value, + '_additional_data_test_attribute' => [['name' => 'test1234.jpg']] ] - ]); + ); $model->afterSave($object); } /** - * @dataProvider attributeValidValueProvider + * @dataProvider attributeValueDataProvider * - * @param $value + * @param array $value */ - public function testAfterSaveShouldNotUploadImageWhenAdditionalDataNotSet($value) + public function testAfterSaveWithoutAdditionalData($value) { $model = $this->setUpModelForAfterSave(); $this->imageUploader->expects($this->never()) ->method('moveFileFromTmp'); - $object = new \Magento\Framework\DataObject([ - 'test_attribute' => $value - ]); + $object = new \Magento\Framework\DataObject( + [ + 'test_attribute' => $value + ] + ); $model->afterSave($object); } - public function testAfterSaveShouldCreateCriticalLogEntryOnUploadExceptions() + public function testAfterSaveWithExceptions() { $model = $this->setUpModelForAfterSave(); @@ -285,11 +282,11 @@ public function testAfterSaveShouldCreateCriticalLogEntryOnUploadExceptions() ->method('critical') ->with($this->equalTo($exception)); - $object = new \Magento\Framework\DataObject([ - '_additional_data_test_attribute' => [ - ['name' => 'test1234.jpg'] + $object = new \Magento\Framework\DataObject( + [ + '_additional_data_test_attribute' => [['name' => 'test1234.jpg']] ] - ]); + ); $model->afterSave($object); } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php index 66403d3964890..ce4cc93b0181b 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/CategoryTest.php @@ -9,7 +9,7 @@ namespace Magento\Catalog\Test\Unit\Model; use Magento\Catalog\Model\Indexer; -use Magento\Catalog\Model\Category as Model; +use Magento\Catalog\Model\Category; /** * @SuppressWarnings(PHPMD.TooManyFields) @@ -17,83 +17,125 @@ */ class CategoryTest extends \PHPUnit_Framework_TestCase { - /** @var \Magento\Catalog\Model\Category */ - protected $category; + /** + * @var \Magento\Catalog\Model\Category + */ + private $category; - /** @var \Magento\Framework\Model\Context|\PHPUnit_Framework_MockObject_MockObject */ - protected $context; + /** + * @var \Magento\Framework\Model\Context|\PHPUnit_Framework_MockObject_MockObject + */ + private $context; - /** @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $eventManager; + /** + * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $eventManager; - /** @var \Magento\Framework\App\CacheInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $cacheManager; + /** + * @var \Magento\Framework\App\CacheInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $cacheManager; - /** @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject */ - protected $registry; + /** + * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject + */ + private $registry; - /** @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $storeManager; + /** + * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $storeManager; - /** @var \Magento\Catalog\Model\ResourceModel\Category\Tree|\PHPUnit_Framework_MockObject_MockObject */ - protected $categoryTreeResource; + /** + * @var \Magento\Catalog\Model\ResourceModel\Category\Tree|\PHPUnit_Framework_MockObject_MockObject + */ + private $categoryTreeResource; - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $categoryTreeFactory; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $categoryTreeFactory; - /** @var \Magento\Catalog\Api\CategoryRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $categoryRepository; + /** + * @var \Magento\Catalog\Api\CategoryRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $categoryRepository; - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $storeCollectionFactory; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $storeCollectionFactory; - /** @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $url; + /** + * @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $url; - /** @var \PHPUnit_Framework_MockObject_MockObject */ - protected $productCollectionFactory; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $productCollectionFactory; - /** @var \Magento\Catalog\Model\Config|\PHPUnit_Framework_MockObject_MockObject */ - protected $catalogConfig; + /** + * @var \Magento\Catalog\Model\Config|\PHPUnit_Framework_MockObject_MockObject + */ + private $catalogConfig; - /** @var \Magento\Framework\Filter\FilterManager|\PHPUnit_Framework_MockObject_MockObject */ - protected $filterManager; + /** + * @var \Magento\Framework\Filter\FilterManager|\PHPUnit_Framework_MockObject_MockObject + */ + private $filterManager; - /** @var \Magento\Catalog\Model\Indexer\Category\Flat\State|\PHPUnit_Framework_MockObject_MockObject */ - protected $flatState; + /** + * @var \Magento\Catalog\Model\Indexer\Category\Flat\State|\PHPUnit_Framework_MockObject_MockObject + */ + private $flatState; - /** @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $flatIndexer; + /** + * @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $flatIndexer; - /** @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $productIndexer; + /** + * @var \Magento\Framework\Indexer\IndexerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $productIndexer; - /** @var \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator|\PHPUnit_Framework_MockObject_MockObject */ - protected $categoryUrlPathGenerator; + /** + * @var \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator|\PHPUnit_Framework_MockObject_MockObject + */ + private $categoryUrlPathGenerator; - /** @var \Magento\UrlRewrite\Model\UrlFinderInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $urlFinder; + /** + * @var \Magento\UrlRewrite\Model\UrlFinderInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $urlFinder; - /** @var \Magento\Framework\Model\ResourceModel\AbstractResource|\PHPUnit_Framework_MockObject_MockObject */ - protected $resource; + /** + * @var \Magento\Framework\Model\ResourceModel\AbstractResource|\PHPUnit_Framework_MockObject_MockObject + */ + private $resource; - /** @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject */ - protected $indexerRegistry; + /** + * @var \Magento\Framework\Indexer\IndexerRegistry|\PHPUnit_Framework_MockObject_MockObject + */ + private $indexerRegistry; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Catalog\Api\CategoryAttributeRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $metadataServiceMock; + private $metadataServiceMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $attributeValueFactory; + private $attributeValueFactory; /** * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager */ - protected $objectManager; + private $objectManager; protected function setUp() { @@ -496,21 +538,24 @@ public function testGetCustomAttributes() ); } - public function imageAttributeNameAndUrlProvider() + /** + * @return array + */ + public function getImageWithAttributeCodeDataProvider() { return [ - ['testimage', 'http://www.test123.com/catalog/category/testimage'], + ['testimage', 'http://www.example.com/catalog/category/testimage'], [false, false] ]; } /** - * @param $value - * @param $url + * @param string|bool $value + * @param string|bool $url * - * @dataProvider imageAttributeNameAndUrlProvider + * @dataProvider getImageWithAttributeCodeDataProvider */ - public function testGetImageUrlShouldGenerateMediaUrlForSpecifiedAttributeValue($value, $url) + public function testGetImageWithAttributeCode($value, $url) { $storeManager = $this->getMock(\Magento\Store\Model\StoreManager::class, ['getStore'], [], '', false); $store = $this->getMock(\Magento\Store\Model\Store::class, ['getBaseUrl'], [], '', false); @@ -522,11 +567,15 @@ public function testGetImageUrlShouldGenerateMediaUrlForSpecifiedAttributeValue( $store->expects($this->any()) ->method('getBaseUrl') ->with(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) - ->will($this->returnValue('http://www.test123.com/')); + ->will($this->returnValue('http://www.example.com/')); - $model = $this->objectManager->getObject(Model::class, [ - 'storeManager' => $storeManager - ]); + /** @var \Magento\Catalog\Model\Category $model */ + $model = $this->objectManager->getObject( + \Magento\Catalog\Model\Category::class, + [ + 'storeManager' => $storeManager + ] + ); $model->setData('attribute1', $value); @@ -535,7 +584,7 @@ public function testGetImageUrlShouldGenerateMediaUrlForSpecifiedAttributeValue( $this->assertEquals($url, $result); } - public function testGetImageUrlShouldGenerateMediaUrlForImageAttributeValue() + public function testGetImageWithoutAttributeCode() { $storeManager = $this->getMock(\Magento\Store\Model\StoreManager::class, ['getStore'], [], '', false); $store = $this->getMock(\Magento\Store\Model\Store::class, ['getBaseUrl'], [], '', false); @@ -547,9 +596,10 @@ public function testGetImageUrlShouldGenerateMediaUrlForImageAttributeValue() $store->expects($this->any()) ->method('getBaseUrl') ->with(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) - ->will($this->returnValue('http://www.test123.com/')); + ->will($this->returnValue('http://www.example.com/')); - $model = $this->objectManager->getObject(Model::class, [ + /** @var \Magento\Catalog\Model\Category $model */ + $model = $this->objectManager->getObject(\Magento\Catalog\Model\Category::class, [ 'storeManager' => $storeManager ]); @@ -557,6 +607,6 @@ public function testGetImageUrlShouldGenerateMediaUrlForImageAttributeValue() $result = $model->getImageUrl(); - $this->assertEquals('http://www.test123.com/catalog/category/myimage', $result); + $this->assertEquals('http://www.example.com/catalog/category/myimage', $result); } } diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/file-uploader.js b/app/code/Magento/Ui/view/base/web/js/form/element/file-uploader.js index 5d06886fe91bd..917dc62f9f49b 100644 --- a/app/code/Magento/Ui/view/base/web/js/form/element/file-uploader.js +++ b/app/code/Magento/Ui/view/base/web/js/form/element/file-uploader.js @@ -299,16 +299,15 @@ define([ */ onBeforeFileUpload: function (e, data) { var file = data.files[0], - allowed = this.isFileAllowed(file); + allowed = this.isFileAllowed(file), + target = $(e.target); if (allowed.passed) { - var $target = $(e.target); - - $target.on('fileuploadsend', function(event, postData) { + target.on('fileuploadsend', function (event, postData) { postData.data.set('param_name', this.paramName); }.bind(data)); - $target.fileupload('process', data).done(function () { + target.fileupload('process', data).done(function () { data.submit(); }); } else { From 5228cf78543e27de4aebe79d003efc2e0af35922 Mon Sep 17 00:00:00 2001 From: PingusPepan Date: Thu, 29 Sep 2016 10:49:12 +0200 Subject: [PATCH 023/202] Fixed unclosed span tag Span tag was unclosed and instead of closing another one was opened --- app/code/Magento/Review/view/frontend/templates/form.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Review/view/frontend/templates/form.phtml b/app/code/Magento/Review/view/frontend/templates/form.phtml index 7c89fd8740c56..bcac1dbca0598 100644 --- a/app/code/Magento/Review/view/frontend/templates/form.phtml +++ b/app/code/Magento/Review/view/frontend/templates/form.phtml @@ -20,7 +20,7 @@ getRatings() && $block->getRatings()->getSize()): ?>
- escapeHtml(__('Your Rating')) ?>
+ escapeHtml(__('Your Rating')) ?>
getRatings() as $_rating): ?> From 104563f57c232b9f52861bbf0b9b8a4915273b35 Mon Sep 17 00:00:00 2001 From: Lorenzo Date: Thu, 29 Sep 2016 12:55:40 +0200 Subject: [PATCH 024/202] Fix nav not working in mobile In mobile thumbs don't disappear and dots are not present. In Luma theme the var name is "nav" instead of "navigation" and it works as expected. --- app/design/frontend/Magento/blank/etc/view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/design/frontend/Magento/blank/etc/view.xml b/app/design/frontend/Magento/blank/etc/view.xml index 3a92ad0a67410..6c53a8613f09c 100644 --- a/app/design/frontend/Magento/blank/etc/view.xml +++ b/app/design/frontend/Magento/blank/etc/view.xml @@ -227,7 +227,7 @@ - dots + dots From 726928a4236135ffe5ce91035d8dd46a10f6f3af Mon Sep 17 00:00:00 2001 From: Ruslan Kostiv Date: Thu, 29 Sep 2016 21:33:06 +0300 Subject: [PATCH 025/202] MAGETWO-55849: Customer can be deleted without Merchant permissions verification --- app/code/Magento/User/Block/User/Edit.php | 6 +- .../User/Controller/Adminhtml/User/Delete.php | 10 + .../Controller/Adminhtml/User/DeleteTest.php | 225 ++++++++++++++++++ .../templates/user/roles_grid_js.phtml | 9 + .../app/Magento/User/Test/Repository/User.xml | 4 + .../TestCase/DeleteAdminUserEntityTest.php | 5 +- .../TestCase/DeleteAdminUserEntityTest.xml | 2 + 7 files changed, 257 insertions(+), 4 deletions(-) create mode 100644 app/code/Magento/User/Test/Unit/Controller/Adminhtml/User/DeleteTest.php diff --git a/app/code/Magento/User/Block/User/Edit.php b/app/code/Magento/User/Block/User/Edit.php index f6c5b484861de..94b1b2f2e6cf9 100644 --- a/app/code/Magento/User/Block/User/Edit.php +++ b/app/code/Magento/User/Block/User/Edit.php @@ -50,7 +50,7 @@ protected function _construct() $this->buttonList->update('save', 'label', __('Save User')); $this->buttonList->remove('delete'); - $objId = $this->getRequest()->getParam($this->_objectId); + $objId = (int)$this->getRequest()->getParam($this->_objectId); if (!empty($objId)) { $this->addButton( @@ -59,10 +59,10 @@ protected function _construct() 'label' => __('Delete User'), 'class' => 'delete', 'onclick' => sprintf( - 'deleteConfirm("%s", "%s", %s)', + 'deleteUserAccount("%s", "%s", %s)', __('Are you sure you want to do this?'), $this->getUrl('adminhtml/*/delete'), - json_encode(['data' => ['user_id' => $objId]]) + $objId ), ] ); diff --git a/app/code/Magento/User/Controller/Adminhtml/User/Delete.php b/app/code/Magento/User/Controller/Adminhtml/User/Delete.php index d892c8533a297..3ff336eeecff8 100644 --- a/app/code/Magento/User/Controller/Adminhtml/User/Delete.php +++ b/app/code/Magento/User/Controller/Adminhtml/User/Delete.php @@ -6,6 +6,9 @@ */ namespace Magento\User\Controller\Adminhtml\User; +use Magento\User\Block\User\Edit\Tab\Main as UserEdit; +use Magento\Framework\Exception\AuthenticationException; + class Delete extends \Magento\User\Controller\Adminhtml\User { /** @@ -13,8 +16,10 @@ class Delete extends \Magento\User\Controller\Adminhtml\User */ public function execute() { + /** @var \Magento\User\Model\User */ $currentUser = $this->_objectManager->get(\Magento\Backend\Model\Auth\Session::class)->getUser(); $userId = (int)$this->getRequest()->getPost('user_id'); + if ($userId) { if ($currentUser->getId() == $userId) { $this->messageManager->addError(__('You cannot delete your own account.')); @@ -22,6 +27,11 @@ public function execute() return; } try { + $currentUserPassword = (string)$this->getRequest()->getPost(UserEdit::CURRENT_USER_PASSWORD_FIELD); + if (empty($currentUserPassword)) { + throw new AuthenticationException(__('You have entered an invalid password for current user.')); + } + $currentUser->performIdentityCheck($currentUserPassword); /** @var \Magento\User\Model\User $model */ $model = $this->_userFactory->create(); $model->setId($userId); diff --git a/app/code/Magento/User/Test/Unit/Controller/Adminhtml/User/DeleteTest.php b/app/code/Magento/User/Test/Unit/Controller/Adminhtml/User/DeleteTest.php new file mode 100644 index 0000000000000..5e2d0d6bcfdbf --- /dev/null +++ b/app/code/Magento/User/Test/Unit/Controller/Adminhtml/User/DeleteTest.php @@ -0,0 +1,225 @@ +objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManager\ObjectManager::class) + ->disableOriginalConstructor() + ->setMethods(['get', 'create']) + ->getMock(); + + $this->responseMock = $this->getMockBuilder(\Magento\Framework\App\ResponseInterface::class) + ->disableOriginalConstructor() + ->setMethods(['setRedirect']) + ->getMockForAbstractClass(); + + $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class) + ->disableOriginalConstructor() + ->setMethods(['getPost']) + ->getMockForAbstractClass(); + + $this->authSessionMock = $this->getMockBuilder(Session::class) + ->disableOriginalConstructor() + ->setMethods(['getUser']) + ->getMock(); + + $this->userMock = $this->getMockBuilder(\Magento\User\Model\User::class) + ->disableOriginalConstructor() + ->setMethods(['getId', 'performIdentityCheck', 'delete']) + ->getMock(); + + $this->userFactoryMock = $this->getMockBuilder(\Magento\User\Model\UserFactory::class) + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + + $this->messageManagerMock = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) + ->disableOriginalConstructor() + ->getMock(); + + $objectManager = new ObjectManagerHelper($this); + $context = $objectManager->getObject( + \Magento\Backend\App\Action\Context::class, + [ + 'request' => $this->requestMock, + 'response' => $this->responseMock, + 'objectManager' => $this->objectManagerMock, + 'messageManager' => $this->messageManagerMock, + ] + ); + + $this->controller = $objectManager->getObject( + \Magento\User\Controller\Adminhtml\User\Delete::class, + [ + 'context' => $context, + 'userFactory' => $this->userFactoryMock, + ] + ); + } + + /** + * Test method \Magento\User\Controller\Adminhtml\User\Delete::execute + * + * @param string $currentUserPassword + * @param int $userId + * @param int $currentUserId + * @param string $resultMethod + * + * @dataProvider executeDataProvider + * @return void + * + */ + public function testExecute($currentUserPassword, $userId, $currentUserId, $resultMethod) + { + $currentUserMock = $this->userMock; + $this->authSessionMock->expects($this->any())->method('getUser')->will($this->returnValue($currentUserMock)); + + $currentUserMock->expects($this->any())->method('getId')->willReturn($currentUserId); + + $this->objectManagerMock + ->expects($this->any()) + ->method('get') + ->with(Session::class) + ->willReturn($this->authSessionMock); + + $this->requestMock->expects($this->any()) + ->method('getPost') + ->willReturnMap([ + ['user_id', $userId], + [UserEdit::CURRENT_USER_PASSWORD_FIELD, $currentUserPassword], + ]); + + $userMock = clone $currentUserMock; + + $this->userFactoryMock->expects($this->any())->method('create')->will($this->returnValue($userMock)); + $this->responseMock->expects($this->any())->method('setRedirect')->willReturnSelf(); + $this->userMock->expects($this->any())->method('delete')->willReturnSelf(); + $this->messageManagerMock->expects($this->once())->method($resultMethod); + + $this->controller->execute(); + } + + /** + * @return void + */ + public function testEmptyPasswordThrowsException() + { + try { + $currentUserId = 1; + $userId = 2; + + $currentUserMock = $this->userMock; + $this->authSessionMock->expects($this->any()) + ->method('getUser') + ->will($this->returnValue($currentUserMock)); + + $currentUserMock->expects($this->any())->method('getId')->willReturn($currentUserId); + + $this->objectManagerMock + ->expects($this->any()) + ->method('get') + ->with(Session::class) + ->willReturn($this->authSessionMock); + + $this->requestMock->expects($this->any()) + ->method('getPost') + ->willReturnMap([ + ['user_id', $userId], + [UserEdit::CURRENT_USER_PASSWORD_FIELD, ''], + ]); + + $this->controller->execute(); + } catch (AuthenticationException $e) { + $this->assertEquals($e->getMessage(), 'You have entered an invalid password for current user.'); + } + } + + /** + * Data Provider for execute method + * + * @return array + */ + public function executeDataProvider() + { + return [ + [ + 'currentUserPassword' => '123123q', + 'userId' => 1, + 'currentUserId' => 2, + 'resultMethod' => 'addSuccess', + ], + [ + 'currentUserPassword' => '123123q', + 'userId' => 0, + 'currentUserId' => 2, + 'resultMethod' => 'addError', + ], + [ + 'currentUserPassword' => '123123q', + 'userId' => 1, + 'currentUserId' => 1, + 'resultMethod' => 'addError', + ], + ]; + } +} diff --git a/app/code/Magento/User/view/adminhtml/templates/user/roles_grid_js.phtml b/app/code/Magento/User/view/adminhtml/templates/user/roles_grid_js.phtml index bac0dd0b3f869..9795c7fd1672f 100644 --- a/app/code/Magento/User/view/adminhtml/templates/user/roles_grid_js.phtml +++ b/app/code/Magento/User/view/adminhtml/templates/user/roles_grid_js.phtml @@ -70,4 +70,13 @@ require([ }); + function deleteUserAccount(message, url, objId) { + if (jQuery.validator.validateElement(jQuery('[name="current_password"]'))) { + postData = {'data' : { + 'user_id': objId, + 'current_password': jQuery('[name="current_password"]').val() + }} + deleteConfirm(message, url, postData); + } + } diff --git a/dev/tests/functional/tests/app/Magento/User/Test/Repository/User.xml b/dev/tests/functional/tests/app/Magento/User/Test/Repository/User.xml index 25b812bf77665..dbb7a4aeb53bb 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/Repository/User.xml +++ b/dev/tests/functional/tests/app/Magento/User/Test/Repository/User.xml @@ -41,5 +41,9 @@ %current_password% Active + + + 123123q + diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.php b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.php index 57de56c7f56f7..67ede3855e7a7 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.php @@ -101,11 +101,13 @@ public function __inject( * * @param User $user * @param string $isDefaultUser + * @param User $systemAdmin * @return void */ public function testDeleteAdminUserEntity( User $user, - $isDefaultUser + $isDefaultUser, + User $systemAdmin = null ) { $filter = [ 'username' => $user->getUsername(), @@ -118,6 +120,7 @@ public function testDeleteAdminUserEntity( } $this->userIndex->open(); $this->userIndex->getUserGrid()->searchAndOpen($filter); + $this->userEdit->getUserForm()->fill($systemAdmin); $this->userEdit->getPageActions()->delete(); $this->userEdit->getModalBlock()->acceptAlert(); } diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.xml b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.xml index 782c3243eaa6b..fd10c53dfd533 100644 --- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/DeleteAdminUserEntityTest.xml @@ -9,11 +9,13 @@ 0 + system_admin 1 + system_admin From 41b7e36575283d64831b16e2e0e908dceb191f52 Mon Sep 17 00:00:00 2001 From: Ruslan Kostiv Date: Fri, 30 Sep 2016 13:08:42 +0300 Subject: [PATCH 026/202] MAGETWO-55395: Custom address attribute not appearing on Checkout summary --- .../template/shipping-address/address-renderer/default.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/code/Magento/Checkout/view/frontend/web/template/shipping-address/address-renderer/default.html b/app/code/Magento/Checkout/view/frontend/web/template/shipping-address/address-renderer/default.html index eeecbf3466366..a2b83ead6b354 100644 --- a/app/code/Magento/Checkout/view/frontend/web/template/shipping-address/address-renderer/default.html +++ b/app/code/Magento/Checkout/view/frontend/web/template/shipping-address/address-renderer/default.html @@ -13,6 +13,11 @@
+ + + + +