Skip to content

Commit 5a2c46c

Browse files
author
Oleksandr Dubovyk
committed
MAGETWO-60823: Cannot unset (set empty) category image on store view level if image defined on all store views
- Fixed - Modified test
1 parent 8c227d5 commit 5a2c46c

File tree

3 files changed

+36
-51
lines changed

3 files changed

+36
-51
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public function imagePreprocessing($data)
280280
continue;
281281
}
282282

283-
$data[$attributeCode] = false;
283+
$data[$attributeCode] = '';
284284
}
285285

286286
return $data;

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php

Lines changed: 27 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Category;
77

8-
use Magento\Catalog\Controller\Adminhtml\Category\Save as Model;
9-
108
/**
119
* Class SaveTest
1210
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -463,18 +461,35 @@ public function dataProviderExecute()
463461
*/
464462
public function imagePreprocessingDataProvider()
465463
{
464+
$dataWithImage = [
465+
'image' => 'path.jpg',
466+
'name' => 'category',
467+
'description' => '',
468+
'parent' => 0
469+
];
470+
$expectedSameAsDataWithImage = $dataWithImage;
471+
472+
$dataWithoutImage = [
473+
'name' => 'category',
474+
'description' => '',
475+
'parent' => 0
476+
];
477+
$expectedIfDataWithoutImage = $dataWithoutImage;
478+
$expectedIfDataWithoutImage['image'] = '';
479+
466480
return [
467-
[['attribute1' => null, 'attribute2' => 123]],
468-
[['attribute2' => 123]]
481+
'categoryPostData contains image' => [$dataWithImage, $expectedSameAsDataWithImage],
482+
'categoryPostData doesn\'t contain image' => [$dataWithoutImage, $expectedIfDataWithoutImage],
469483
];
470484
}
471485

472486
/**
473487
* @dataProvider imagePreprocessingDataProvider
474488
*
475489
* @param array $data
490+
* @param array $expected
476491
*/
477-
public function testImagePreprocessingWithoutValue($data)
492+
public function testImagePreprocessing($data, $expected)
478493
{
479494
$eavConfig = $this->createPartialMock(\Magento\Eav\Model\Config::class, ['getEntityType']);
480495

@@ -484,68 +499,30 @@ public function testImagePreprocessingWithoutValue($data)
484499

485500
$collection = new \Magento\Framework\DataObject(['attribute_collection' => [
486501
new \Magento\Framework\DataObject([
487-
'attribute_code' => 'attribute1',
502+
'attribute_code' => 'image',
488503
'backend' => $imageBackendModel
489504
]),
490505
new \Magento\Framework\DataObject([
491-
'attribute_code' => 'attribute2',
506+
'attribute_code' => 'name',
492507
'backend' => new \Magento\Framework\DataObject()
493-
])
494-
]]);
495-
496-
$eavConfig->expects($this->once())
497-
->method('getEntityType')
498-
->with(\Magento\Catalog\Api\Data\CategoryAttributeInterface::ENTITY_TYPE_CODE)
499-
->will($this->returnValue($collection));
500-
501-
$model = $this->objectManager->getObject(\Magento\Catalog\Controller\Adminhtml\Category\Save::class, [
502-
'eavConfig' => $eavConfig
503-
]);
504-
505-
$result = $model->imagePreprocessing($data);
506-
507-
$this->assertEquals([
508-
'attribute1' => false,
509-
'attribute2' => 123
510-
], $result);
511-
}
512-
513-
public function testImagePreprocessingWithValue()
514-
{
515-
$eavConfig = $this->createPartialMock(\Magento\Eav\Model\Config::class, ['getEntityType']);
516-
517-
$imageBackendModel = $this->objectManager->getObject(
518-
\Magento\Catalog\Model\Category\Attribute\Backend\Image::class
519-
);
520-
521-
$collection = new \Magento\Framework\DataObject(['attribute_collection' => [
522-
new \Magento\Framework\DataObject([
523-
'attribute_code' => 'attribute1',
524-
'backend' => $imageBackendModel
525508
]),
526509
new \Magento\Framework\DataObject([
527-
'attribute_code' => 'attribute2',
510+
'attribute_code' => 'level',
528511
'backend' => new \Magento\Framework\DataObject()
529-
])
512+
]),
530513
]]);
531514

532515
$eavConfig->expects($this->once())
533516
->method('getEntityType')
534517
->with(\Magento\Catalog\Api\Data\CategoryAttributeInterface::ENTITY_TYPE_CODE)
535518
->will($this->returnValue($collection));
536519

537-
$model = $this->objectManager->getObject(Model::class, [
520+
$model = $this->objectManager->getObject(\Magento\Catalog\Controller\Adminhtml\Category\Save::class, [
538521
'eavConfig' => $eavConfig
539522
]);
540523

541-
$result = $model->imagePreprocessing([
542-
'attribute1' => 'somevalue',
543-
'attribute2' => null
544-
]);
524+
$result = $model->imagePreprocessing($data);
545525

546-
$this->assertEquals([
547-
'attribute1' => 'somevalue',
548-
'attribute2' => null
549-
], $result);
526+
$this->assertEquals($expected, $result);
550527
}
551528
}

app/design/adminhtml/Magento/backend/web/css/source/components/_file-uploader.less

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@
7474
box-shadow: 0 0 0 1px @file-uploader-preview-focus__color;
7575
}
7676
}
77+
78+
&:disabled {
79+
+ .file-uploader-button {
80+
cursor: default;
81+
opacity: .5;
82+
pointer-events: none;
83+
}
84+
}
7785
}
7886
}
7987

0 commit comments

Comments
 (0)