Skip to content

Commit 1cf64d3

Browse files
Merge branch 'develop' of https://github.corp.magento.com/magento2/magento2ce into MAGETWO-49914
2 parents 15479e0 + 487f5f4 commit 1cf64d3

File tree

16 files changed

+396
-76
lines changed

16 files changed

+396
-76
lines changed

ISSUE_TEMPLATE.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Steps to reproduce
2+
--
3+
1. Install Magento from `develop` branch.
4+
2. [Example] Add Configurable Product to the cart.
5+
3. ...
6+
7+
Expected result
8+
--
9+
1. [Example] Configurable product added to the shopping cart.
10+
2. ...
11+
12+
Actual result
13+
--
14+
1. [Example] Error message appears: "Cannot save quote".
15+
2. [Screenshot, logs]
16+
3. ...

app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePanel.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ protected function getHiddenColumn($columnName, $sortOrder)
364364
];
365365
}
366366

367-
368367
/**
369368
* Get configuration for the modal set: modal and trigger button
370369
*
@@ -579,7 +578,6 @@ protected function getBundleSelections()
579578
'sortOrder' => 100,
580579
'validation' => [
581580
'validate-number' => true,
582-
'validate-digits' => true,
583581
],
584582
],
585583
],
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product;
7+
8+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
9+
use Magento\Catalog\Ui\DataProvider\Product\ProductCustomOptionsDataProvider;
10+
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
11+
use Magento\Framework\App\RequestInterface;
12+
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
13+
use Magento\Framework\DB\Select as DbSelect;
14+
15+
class ProductCustomOptionsDataProviderTest extends \PHPUnit_Framework_TestCase
16+
{
17+
/**
18+
* @var ObjectManagerHelper
19+
*/
20+
protected $objectManagerHelper;
21+
22+
/**
23+
* @var ProductCustomOptionsDataProvider
24+
*/
25+
protected $dataProvider;
26+
27+
/**
28+
* @var CollectionFactory|\PHPUnit_Framework_MockObject_MockObject
29+
*/
30+
protected $collectionFactoryMock;
31+
32+
/**
33+
* @var RequestInterface|\PHPUnit_Framework_MockObject_MockObject
34+
*/
35+
protected $requestMock;
36+
37+
/**
38+
* @var AbstractCollection|\PHPUnit_Framework_MockObject_MockObject
39+
*/
40+
protected $collectionMock;
41+
42+
/**
43+
* @var DbSelect|\PHPUnit_Framework_MockObject_MockObject
44+
*/
45+
protected $dbSelectMock;
46+
47+
protected function setUp()
48+
{
49+
$this->collectionFactoryMock = $this->getMockBuilder(CollectionFactory::class)
50+
->disableOriginalConstructor()
51+
->setMethods(['create'])
52+
->getMock();
53+
$this->requestMock = $this->getMockBuilder(RequestInterface::class)
54+
->getMockForAbstractClass();
55+
$this->collectionMock = $this->getMockBuilder(AbstractCollection::class)
56+
->disableOriginalConstructor()
57+
->setMethods(['load', 'getSelect', 'getTable', 'getIterator', 'isLoaded', 'toArray', 'getSize'])
58+
->getMockForAbstractClass();
59+
$this->dbSelectMock = $this->getMockBuilder(DbSelect::class)
60+
->disableOriginalConstructor()
61+
->getMock();
62+
63+
$this->collectionFactoryMock->expects($this->once())
64+
->method('create')
65+
->willReturn($this->collectionMock);
66+
67+
$this->objectManagerHelper = new ObjectManagerHelper($this);
68+
$this->dataProvider = $this->objectManagerHelper->getObject(
69+
ProductCustomOptionsDataProvider::class,
70+
[
71+
'collectionFactory' => $this->collectionFactoryMock,
72+
'request' => $this->requestMock
73+
]
74+
);
75+
}
76+
77+
/**
78+
* @param int $amount
79+
* @param array $collectionArray
80+
* @param array $result
81+
* @dataProvider getDataDataProvider
82+
*/
83+
public function testGetDataCollectionIsLoaded($amount, array $collectionArray, array $result)
84+
{
85+
$this->collectionMock->expects($this->never())
86+
->method('load');
87+
88+
$this->setCommonExpectations(true, $amount, $collectionArray);
89+
90+
$this->assertSame($result, $this->dataProvider->getData());
91+
}
92+
93+
/**
94+
* @param int $amount
95+
* @param array $collectionArray
96+
* @param array $result
97+
* @dataProvider getDataDataProvider
98+
*/
99+
public function testGetData($amount, array $collectionArray, array $result)
100+
{
101+
$tableName = 'catalog_product_option_table';
102+
103+
$this->collectionMock->expects($this->once())
104+
->method('isLoaded')
105+
->willReturn(false);
106+
$this->requestMock->expects($this->once())
107+
->method('getParam')
108+
->with('current_product_id', null)
109+
->willReturn(0);
110+
$this->collectionMock->expects($this->any())
111+
->method('getSelect')
112+
->willReturn($this->dbSelectMock);
113+
$this->dbSelectMock->expects($this->any())
114+
->method('distinct')
115+
->willReturnSelf();
116+
$this->collectionMock->expects($this->any())
117+
->method('getTable')
118+
->with('catalog_product_option')
119+
->willReturn($tableName);
120+
$this->dbSelectMock->expects($this->once())
121+
->method('join')
122+
->with(['opt' => $tableName], 'opt.product_id = e.entity_id', null)
123+
->willReturnSelf();
124+
$this->collectionMock->expects($this->once())
125+
->method('load')
126+
->willReturnSelf();
127+
$this->collectionMock->expects($this->any())
128+
->method('getIterator')
129+
->willReturn(new \ArrayIterator([]));
130+
131+
$this->setCommonExpectations(false, $amount, $collectionArray);
132+
133+
$this->assertSame($result, $this->dataProvider->getData());
134+
}
135+
136+
/**
137+
* @return array
138+
*/
139+
public function getDataDataProvider()
140+
{
141+
return [
142+
0 => [
143+
'amount' => 2,
144+
'collectionArray' => [
145+
'12' => ['id' => '12', 'value' => 'test1'],
146+
'25' => ['id' => '25', 'value' => 'test2']
147+
],
148+
'result' => [
149+
'totalRecords' => 2,
150+
'items' => [
151+
['id' => '12', 'value' => 'test1'],
152+
['id' => '25', 'value' => 'test2']
153+
]
154+
]
155+
]
156+
];
157+
}
158+
159+
/**
160+
* Set common expectations
161+
*
162+
* @param bool $isLoaded
163+
* @param int $amount
164+
* @param array $collectionArray
165+
* @return void
166+
*/
167+
protected function setCommonExpectations($isLoaded, $amount, array $collectionArray)
168+
{
169+
$this->collectionMock->expects($this->once())
170+
->method('isLoaded')
171+
->willReturn($isLoaded);
172+
$this->collectionMock->expects($this->once())
173+
->method('toArray')
174+
->willReturn($collectionArray);
175+
$this->collectionMock->expects($this->once())
176+
->method('getSize')
177+
->willReturn($amount);
178+
}
179+
}

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AbstractModifier.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
abstract class AbstractModifier implements ModifierInterface
1717
{
18+
const FORM_NAME = 'product_form';
1819
const DATA_SOURCE_DEFAULT = 'product';
1920
const DATA_SCOPE_PRODUCT = 'data.product';
2021

0 commit comments

Comments
 (0)