Skip to content

Commit 0eecdef

Browse files
author
vnayda
committed
Merge remote-tracking branch 'origin/develop' into MAGETWO-52717
# Conflicts: # app/code/Magento/Catalog/etc/di.xml
2 parents 5e54a0b + d8eac00 commit 0eecdef

File tree

93 files changed

+1974
-292
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1974
-292
lines changed

app/code/Magento/Backend/etc/config.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
<template>
1212
<minify_html>0</minify_html>
1313
</template>
14+
<static>
15+
<sign>1</sign>
16+
</static>
1417
</dev>
1518
<system>
1619
<media_storage_configuration>

app/code/Magento/Catalog/Controller/Adminhtml/Product/MassStatus.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ public function execute()
8484
$productIds = $collection->getAllIds();
8585
$storeId = (int) $this->getRequest()->getParam('store', 0);
8686
$status = (int) $this->getRequest()->getParam('status');
87+
$filters = (array)$this->getRequest()->getParam('filters', []);
88+
89+
if (isset($filters['store_id'])) {
90+
$storeId = (int)$filters['store_id'];
91+
}
8792

8893
try {
8994
$this->_validateMassStatus($productIds, $status);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements
6565
*/
6666
const TREE_ROOT_ID = 1;
6767

68-
const CACHE_TAG = 'catalog_category';
68+
const CACHE_TAG = 'cat_c';
6969

7070
/**#@+
7171
* Constants

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements
5858
/**
5959
* Product cache tag
6060
*/
61-
const CACHE_TAG = 'catalog_product';
61+
const CACHE_TAG = 'cat_p';
6262

6363
/**
6464
* Category product relation cache tag
6565
*/
66-
const CACHE_PRODUCT_CATEGORY_TAG = 'catalog_category_product';
66+
const CACHE_PRODUCT_CATEGORY_TAG = 'cat_c_p';
6767

6868
/**
6969
* Product Store Id

app/code/Magento/Catalog/Model/Product/Option/Type/File.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Catalog\Model\Product\Option\Type;
77

8+
use Magento\Framework\App\Filesystem\DirectoryList;
89
use Magento\Framework\Filesystem;
910
use Magento\Framework\Exception\LocalizedException;
1011
use Magento\Catalog\Model\Product\Exception as ProductException;
@@ -69,17 +70,23 @@ class File extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
6970
*/
7071
protected $validatorFile;
7172

73+
/**
74+
* @var Filesystem
75+
*/
76+
private $filesystem;
77+
7278
/**
7379
* @param \Magento\Checkout\Model\Session $checkoutSession
7480
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
7581
* @param \Magento\Quote\Model\Quote\Item\OptionFactory $itemOptionFactory
76-
* @param \Magento\Catalog\Model\Product\Option\UrlBuilder $urlBuilder
77-
* @param \Magento\Framework\Escaper $escaper
7882
* @param \Magento\MediaStorage\Helper\File\Storage\Database $coreFileStorageDatabase
7983
* @param File\ValidatorInfo $validatorInfo
8084
* @param File\ValidatorFile $validatorFile
85+
* @param \Magento\Catalog\Model\Product\Option\UrlBuilder $urlBuilder
86+
* @param \Magento\Framework\Escaper $escaper
8187
* @param array $data
82-
* @throws \Magento\Framework\Exception\FileSystemException
88+
* @param Filesystem $filesystem
89+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
8390
*/
8491
public function __construct(
8592
\Magento\Checkout\Model\Session $checkoutSession,
@@ -90,12 +97,15 @@ public function __construct(
9097
\Magento\Catalog\Model\Product\Option\Type\File\ValidatorFile $validatorFile,
9198
\Magento\Catalog\Model\Product\Option\UrlBuilder $urlBuilder,
9299
\Magento\Framework\Escaper $escaper,
93-
array $data = []
100+
array $data = [],
101+
Filesystem $filesystem = null
94102
) {
95103
$this->_itemOptionFactory = $itemOptionFactory;
96104
$this->_urlBuilder = $urlBuilder;
97105
$this->_escaper = $escaper;
98106
$this->_coreFileStorageDatabase = $coreFileStorageDatabase;
107+
$this->filesystem = $filesystem ?: \Magento\Framework\App\ObjectManager::getInstance()->get(Filesystem::class);
108+
$this->_rootDirectory = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA);
99109
$this->validatorInfo = $validatorInfo;
100110
$this->validatorFile = $validatorFile;
101111
parent::__construct($checkoutSession, $scopeConfig, $data);

app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ protected function tearDown()
114114

115115
public function testGetIdentities()
116116
{
117-
$productTag = 'catalog_product_1';
118-
$categoryTag = 'catalog_category_product_1';
117+
$productTag = 'cat_p_1';
118+
$categoryTag = 'cat_c_p_1';
119119

120120
$this->productMock->expects($this->once())
121121
->method('getIdentities')

app/code/Magento/Catalog/Test/Unit/Block/Product/ViewTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected function setUp()
3232
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
3333
$this->productTypeConfig = $this->getMock(\Magento\Catalog\Model\ProductTypes\ConfigInterface::class);
3434
$this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false);
35-
$this->view = $helper->getObject(
35+
$this->view = $helper->getObject(
3636
\Magento\Catalog\Block\Product\View::class,
3737
['productTypeConfig' => $this->productTypeConfig, 'registry' => $this->registryMock]
3838
);
@@ -65,7 +65,7 @@ public function testShouldRenderQuantity()
6565

6666
public function testGetIdentities()
6767
{
68-
$productTags = ['catalog_product_1'];
68+
$productTags = ['cat_p_1'];
6969
$product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false);
7070
$category = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false);
7171

@@ -84,6 +84,6 @@ public function testGetIdentities()
8484
]
8585
)
8686
);
87-
$this->assertEquals(['catalog_product_1', 'catalog_category_1'], $this->view->getIdentities());
87+
$this->assertEquals(['cat_p_1', 'cat_c_1'], $this->view->getIdentities());
8888
}
8989
}

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Initialization/HelperTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,19 @@ public function testInitialize()
278278
->method('getOptionsReadOnly')
279279
->willReturn(false);
280280

281+
$firstExpectedCustomOption = clone $this->customOptionMock;
282+
$firstExpectedCustomOption->setData($optionsData['option2']);
283+
$secondExpectedCustomOption = clone $this->customOptionMock;
284+
$secondExpectedCustomOption->setData($optionsData['option3']);
281285
$this->customOptionFactoryMock->expects($this->any())
282286
->method('create')
283287
->willReturnMap([
284288
[
285289
['data' => $optionsData['option2']],
286-
(clone $this->customOptionMock)->setData($optionsData['option2'])
290+
$firstExpectedCustomOption
287291
], [
288292
['data' => $optionsData['option3']],
289-
(clone $this->customOptionMock)->setData($optionsData['option3'])
293+
$secondExpectedCustomOption
290294
]
291295
]);
292296

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/MassStatusTest.php

Lines changed: 102 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,74 @@
66
*/
77
namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product;
88

9+
use Magento\Ui\Component\MassAction\Filter;
10+
use Magento\Backend\Model\View\Result\Redirect;
11+
use Magento\Catalog\Model\Indexer\Product\Price\Processor;
12+
use Magento\Catalog\Controller\Adminhtml\Product\Builder;
13+
use Magento\Framework\Data\Collection\AbstractDb;
14+
use Magento\Catalog\Model\Product\Action;
15+
16+
/**
17+
* Class MassStatusTest
18+
*
19+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
20+
*/
921
class MassStatusTest extends \Magento\Catalog\Test\Unit\Controller\Adminhtml\ProductTest
1022
{
1123
/**
12-
* @var \PHPUnit_Framework_MockObject_MockObject
24+
* @var Processor|\PHPUnit_Framework_MockObject_MockObject
1325
*/
14-
protected $priceProcessor;
26+
private $priceProcessorMock;
1527

16-
/** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Backend\Model\View\Result\Redirect */
17-
protected $resultRedirect;
28+
/**
29+
* @var Redirect|\PHPUnit_Framework_MockObject_MockObject
30+
*/
31+
private $resultRedirectMock;
32+
33+
/**
34+
* @var Filter|\PHPUnit_Framework_MockObject_MockObject
35+
*/
36+
private $filterMock;
37+
38+
/**
39+
* @var Builder|\PHPUnit_Framework_MockObject_MockObject
40+
*/
41+
private $productBuilderMock;
42+
43+
/**
44+
* @var AbstractDb|\PHPUnit_Framework_MockObject_MockObject
45+
*/
46+
private $abstractDbMock;
47+
48+
/**
49+
* @var Action|\PHPUnit_Framework_MockObject_MockObject
50+
*/
51+
private $actionMock;
1852

1953
protected function setUp()
2054
{
21-
$this->priceProcessor = $this->getMockBuilder(\Magento\Catalog\Model\Indexer\Product\Price\Processor::class)
55+
$this->priceProcessorMock = $this->getMockBuilder(Processor::class)
2256
->disableOriginalConstructor()->getMock();
57+
$this->productBuilderMock = $this->getMockBuilder(Builder::class)
58+
->setMethods(['build'])
59+
->disableOriginalConstructor()
60+
->getMock();
2361

24-
$productBuilder = $this->getMockBuilder(
25-
\Magento\Catalog\Controller\Adminhtml\Product\Builder::class
26-
)->setMethods(['build'])->disableOriginalConstructor()->getMock();
27-
28-
$product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->disableOriginalConstructor()
29-
->setMethods(['getTypeId', 'getStoreId', '__sleep', '__wakeup'])->getMock();
30-
$product->expects($this->any())->method('getTypeId')->will($this->returnValue('simple'));
31-
$product->expects($this->any())->method('getStoreId')->will($this->returnValue('1'));
32-
$productBuilder->expects($this->any())->method('build')->will($this->returnValue($product));
62+
$productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
63+
->disableOriginalConstructor()
64+
->setMethods(['getTypeId', 'getStoreId', '__sleep', '__wakeup'])
65+
->getMock();
66+
$productMock->expects($this->any())
67+
->method('getTypeId')
68+
->willReturn('simple');
69+
$productMock->expects($this->any())
70+
->method('getStoreId')
71+
->willReturn('1');
72+
$this->productBuilderMock->expects($this->any())
73+
->method('build')
74+
->willReturn($productMock);
3375

34-
$this->resultRedirect = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class)
76+
$this->resultRedirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class)
3577
->disableOriginalConstructor()
3678
->getMock();
3779
$resultFactory = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class)
@@ -41,47 +83,71 @@ protected function setUp()
4183
$resultFactory->expects($this->atLeastOnce())
4284
->method('create')
4385
->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)
44-
->willReturn($this->resultRedirect);
86+
->willReturn($this->resultRedirectMock);
4587

46-
$abstractDbMock = $this->getMockBuilder(\Magento\Framework\Data\Collection\AbstractDb::class)
88+
$this->abstractDbMock = $this->getMockBuilder(AbstractDb::class)
4789
->disableOriginalConstructor()
4890
->setMethods(['getAllIds', 'getResource'])
4991
->getMock();
50-
$abstractDbMock->expects($this->any())
51-
->method('getAllIds')
52-
->willReturn([]);
53-
54-
$filterMock = $this->getMockBuilder(\Magento\Ui\Component\MassAction\Filter::class)
92+
$this->filterMock = $this->getMockBuilder(\Magento\Ui\Component\MassAction\Filter::class)
5593
->disableOriginalConstructor()
5694
->setMethods(['getCollection'])
5795
->getMock();
58-
$filterMock->expects($this->any())
59-
->method('getCollection')
60-
->willReturn($abstractDbMock);
61-
62-
$collectionFactoryMock = $this->getMockBuilder(
63-
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class
64-
)
96+
$this->actionMock = $this->getMockBuilder(Action::class)
97+
->disableOriginalConstructor()
98+
->getMock();
99+
100+
$collectionFactoryMock =
101+
$this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class)
65102
->disableOriginalConstructor()
66103
->setMethods(['create'])
67104
->getMock();
68105
$collectionFactoryMock->expects($this->any())
69106
->method('create')
70-
->willReturn($abstractDbMock);
107+
->willReturn($this->abstractDbMock);
108+
109+
$additionalParams = [
110+
'resultFactory' => $resultFactory
111+
];
112+
/** @var \Magento\Backend\App\Action\Context $context */
113+
$context = $this->initContext($additionalParams, [[Action::class, $this->actionMock]]);
71114

72-
$additionalParams = ['resultFactory' => $resultFactory];
73115
$this->action = new \Magento\Catalog\Controller\Adminhtml\Product\MassStatus(
74-
$this->initContext($additionalParams),
75-
$productBuilder,
76-
$this->priceProcessor,
77-
$filterMock,
116+
$context,
117+
$this->productBuilderMock,
118+
$this->priceProcessorMock,
119+
$this->filterMock,
78120
$collectionFactoryMock
79121
);
80122
}
81123

82124
public function testMassStatusAction()
83125
{
84-
$this->priceProcessor->expects($this->once())->method('reindexList');
126+
$storeId = 1;
127+
$status = \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED;
128+
$filters = [
129+
'store_id' => 2,
130+
];
131+
132+
$this->filterMock->expects($this->once())
133+
->method('getCollection')
134+
->willReturn($this->abstractDbMock);
135+
$this->abstractDbMock->expects($this->once())
136+
->method('getAllIds')
137+
->willReturn([3]);
138+
$this->request->expects($this->exactly(3))
139+
->method('getParam')
140+
->willReturnMap([
141+
['store', 0, $storeId],
142+
['status', null, $status],
143+
['filters', [], $filters]
144+
]);
145+
$this->actionMock->expects($this->once())
146+
->method('updateAttributes')
147+
->with([3], ['status' => $status], 2);
148+
$this->priceProcessorMock->expects($this->once())
149+
->method('reindexList');
150+
85151
$this->action->execute();
86152
}
87153
}

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/ProductTest.php

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

8+
use Magento\Catalog\Api\Data\ProductInterface;
9+
810
/**
911
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1012
*/
@@ -25,17 +27,33 @@ abstract class ProductTest extends \PHPUnit_Framework_TestCase
2527
/** @var \Magento\Framework\App\Request\Http|\PHPUnit_Framework_MockObject_MockObject */
2628
protected $request;
2729

30+
/**
31+
* @var \Magento\Framework\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
32+
*/
33+
private $objectManagerMock;
34+
2835
/**
2936
* Init context object
3037
*
3138
* @param array $additionalParams
39+
* @param array $objectManagerMap Object Manager mappings
3240
* @return \PHPUnit_Framework_MockObject_MockObject
3341
*/
34-
protected function initContext(array $additionalParams = [])
42+
protected function initContext(array $additionalParams = [], array $objectManagerMap = [])
3543
{
3644
$productActionMock = $this->getMock(\Magento\Catalog\Model\Product\Action::class, [], [], '', false);
37-
$objectManagerMock = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class);
38-
$objectManagerMock->expects($this->any())->method('get')->will($this->returnValue($productActionMock));
45+
46+
$this->objectManagerMock = $this->getMockForAbstractClass(\Magento\Framework\ObjectManagerInterface::class);
47+
48+
if ($objectManagerMap) {
49+
$this->objectManagerMock->expects($this->any())
50+
->method('get')
51+
->willReturnMap($objectManagerMap);
52+
}
53+
54+
$this->objectManagerMock->expects($this->any())
55+
->method('get')
56+
->willReturn($productActionMock);
3957

4058
$block = $this->getMockBuilder(\Magento\Framework\View\Element\AbstractBlock::class)
4159
->disableOriginalConstructor()->getMockForAbstractClass();
@@ -93,7 +111,7 @@ protected function initContext(array $additionalParams = [])
93111
$this->context->expects($this->any())->method('getEventManager')->will($this->returnValue($eventManager));
94112
$this->context->expects($this->any())->method('getRequest')->will($this->returnValue($requestInterfaceMock));
95113
$this->context->expects($this->any())->method('getResponse')->will($this->returnValue($responseInterfaceMock));
96-
$this->context->expects($this->any())->method('getObjectManager')->will($this->returnValue($objectManagerMock));
114+
$this->context->expects($this->any())->method('getObjectManager')->willReturn($this->objectManagerMock);
97115

98116
$this->context->expects($this->any())->method('getMessageManager')
99117
->will($this->returnValue($managerInterfaceMock));

0 commit comments

Comments
 (0)