Skip to content

Commit 3ee655a

Browse files
author
Yaroslav Onischenko
committed
MAGETWO-55908: Prepare PR
1 parent 56b7492 commit 3ee655a

File tree

12 files changed

+59
-79
lines changed

12 files changed

+59
-79
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77

88
use Magento\Catalog\Api\Data\ProductAttributeInterface;
99
use Magento\Catalog\Model\Locator\LocatorInterface;
10-
use Magento\Customer\Model\Customer\Source\GroupSourceWithAllGroupsInterface;
10+
use Magento\Customer\Model\Customer\Source\GroupSourceInterface;
1111
use Magento\Directory\Helper\Data;
1212
use Magento\Framework\App\ObjectManager;
1313
use Magento\Store\Model\StoreManagerInterface;
14-
use Magento\Customer\Api\Data\GroupInterface;
1514
use Magento\Customer\Api\GroupManagementInterface;
1615
use Magento\Customer\Api\GroupRepositoryInterface;
1716
use Magento\Framework\Api\SearchCriteriaBuilder;
@@ -84,7 +83,7 @@ class AdvancedPricing extends AbstractModifier
8483
protected $meta = [];
8584

8685
/**
87-
* @var GroupSourceWithAllGroupsInterface
86+
* @var GroupSourceInterface
8887
*/
8988
private $customerGroupSource;
9089

@@ -98,7 +97,7 @@ class AdvancedPricing extends AbstractModifier
9897
* @param Data $directoryHelper
9998
* @param ArrayManager $arrayManager
10099
* @param string $scopeName
101-
* @param GroupSourceWithAllGroupsInterface $customerGroupSource
100+
* @param GroupSourceInterface $customerGroupSource
102101
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
103102
*/
104103
public function __construct(
@@ -111,7 +110,7 @@ public function __construct(
111110
Data $directoryHelper,
112111
ArrayManager $arrayManager,
113112
$scopeName = '',
114-
GroupSourceWithAllGroupsInterface $customerGroupSource = null
113+
GroupSourceInterface $customerGroupSource = null
115114
) {
116115
$this->locator = $locator;
117116
$this->storeManager = $storeManager;
@@ -123,7 +122,7 @@ public function __construct(
123122
$this->arrayManager = $arrayManager;
124123
$this->scopeName = $scopeName;
125124
$this->customerGroupSource = $customerGroupSource
126-
?: ObjectManager::getInstance()->get(GroupSourceWithAllGroupsInterface::class);
125+
?: ObjectManager::getInstance()->get(GroupSourceInterface::class);
127126
}
128127

129128
/**

app/code/Magento/Customer/Model/Config/Source/Group.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Magento\Customer\Model\Config\Source;
77

88
use Magento\Customer\Api\GroupManagementInterface;
9-
use Magento\Customer\Model\Customer\Source\GroupSourceForLoggedInCustomersInterface;
9+
use Magento\Customer\Model\Customer\Attribute\Source\GroupSourceLoggedInOnlyInterface;
1010
use Magento\Framework\App\ObjectManager;
1111

1212
class Group implements \Magento\Framework\Option\ArrayInterface
@@ -29,33 +29,33 @@ class Group implements \Magento\Framework\Option\ArrayInterface
2929
protected $_converter;
3030

3131
/**
32-
* @var GroupSourceForLoggedInCustomersInterface
32+
* @var GroupSourceLoggedInOnlyInterface
3333
*/
34-
private $groupSourceForLoggedInCustomers;
34+
private $groupSourceLoggedInOnly;
3535

3636
/**
3737
* @param GroupManagementInterface $groupManagement
3838
* @param \Magento\Framework\Convert\DataObject $converter
39-
* @param GroupSourceForLoggedInCustomersInterface $groupSourceForLoggedInCustomers
39+
* @param GroupSourceLoggedInOnlyInterface $groupSourceForLoggedInCustomers
4040
*/
4141
public function __construct(
4242
GroupManagementInterface $groupManagement,
4343
\Magento\Framework\Convert\DataObject $converter,
44-
GroupSourceForLoggedInCustomersInterface $groupSourceForLoggedInCustomers = null
44+
GroupSourceLoggedInOnlyInterface $groupSourceForLoggedInCustomers = null
4545
) {
4646
$this->_groupManagement = $groupManagement;
4747
$this->_converter = $converter;
48-
$this->groupSourceForLoggedInCustomers = $groupSourceForLoggedInCustomers
49-
?: ObjectManager::getInstance()->get(GroupSourceForLoggedInCustomersInterface::class);
48+
$this->groupSourceLoggedInOnly = $groupSourceForLoggedInCustomers
49+
?: ObjectManager::getInstance()->get(GroupSourceLoggedInOnlyInterface::class);
5050
}
5151

5252
/**
53-
* @return array
53+
* @inheritdoc
5454
*/
5555
public function toOptionArray()
5656
{
5757
if (!$this->_options) {
58-
$this->_options = $this->groupSourceForLoggedInCustomers->toOptionArray();
58+
$this->_options = $this->groupSourceLoggedInOnly->toOptionArray();
5959
array_unshift($this->_options, ['value' => '', 'label' => __('-- Please Select --')]);
6060
}
6161

app/code/Magento/Customer/Model/Config/Source/Group/Multiselect.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
*/
66
namespace Magento\Customer\Model\Config\Source\Group;
77

8+
use Magento\Customer\Model\Customer\Attribute\Source\GroupSourceLoggedInOnlyInterface;
89
use Magento\Customer\Api\GroupManagementInterface;
10+
use Magento\Framework\App\ObjectManager;
911

1012
class Multiselect implements \Magento\Framework\Option\ArrayInterface
1113
{
@@ -17,25 +19,36 @@ class Multiselect implements \Magento\Framework\Option\ArrayInterface
1719
protected $_options;
1820

1921
/**
22+
* @deprecated
2023
* @var GroupManagementInterface
2124
*/
2225
protected $_groupManagement;
2326

2427
/**
28+
* @deprecated
2529
* @var \Magento\Framework\Convert\DataObject
2630
*/
2731
protected $_converter;
2832

33+
/**
34+
* @var GroupSourceLoggedInOnlyInterface
35+
*/
36+
private $groupSourceLoggedInOnly;
37+
2938
/**
3039
* @param GroupManagementInterface $groupManagement
3140
* @param \Magento\Framework\Convert\DataObject $converter
41+
* @param GroupSourceLoggedInOnlyInterface|null $groupSourceLoggedInOnly
3242
*/
3343
public function __construct(
3444
GroupManagementInterface $groupManagement,
35-
\Magento\Framework\Convert\DataObject $converter
45+
\Magento\Framework\Convert\DataObject $converter,
46+
GroupSourceLoggedInOnlyInterface $groupSourceLoggedInOnly = null
3647
) {
3748
$this->_groupManagement = $groupManagement;
3849
$this->_converter = $converter;
50+
$this->groupSourceLoggedInOnly = $groupSourceLoggedInOnly
51+
?: ObjectManager::getInstance()->get(GroupSourceLoggedInOnlyInterface::class);
3952
}
4053

4154
/**
@@ -46,8 +59,7 @@ public function __construct(
4659
public function toOptionArray()
4760
{
4861
if (!$this->_options) {
49-
$groups = $this->_groupManagement->getLoggedInGroups();
50-
$this->_options = $this->_converter->toOptionArray($groups, 'id', 'code');
62+
$this->_options = $this->groupSourceLoggedInOnly->toOptionArray();
5163
}
5264
return $this->_options;
5365
}

app/code/Magento/Customer/Model/Customer/Attribute/Source/Group.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
namespace Magento\Customer\Model\Customer\Attribute\Source;
77

88
use Magento\Customer\Api\GroupManagementInterface;
9-
use Magento\Customer\Model\Customer\Source\GroupSourceForLoggedInCustomersInterface;
109

1110
/**
1211
* Customer group attribute source
1312
*
1413
* @author Magento Core Team <core@magentocommerce.com>
1514
*/
16-
class Group extends \Magento\Eav\Model\Entity\Attribute\Source\Table implements GroupSourceForLoggedInCustomersInterface
15+
class Group extends \Magento\Eav\Model\Entity\Attribute\Source\Table implements GroupSourceLoggedInOnlyInterface
1716
{
1817
/**
1918
* @var GroupManagementInterface

app/code/Magento/Customer/Model/Customer/Source/GroupSourceForLoggedInCustomersInterface.php renamed to app/code/Magento/Customer/Model/Customer/Attribute/Source/GroupSourceLoggedInOnlyInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\Customer\Model\Customer\Source;
7+
namespace Magento\Customer\Model\Customer\Attribute\Source;
88

99
use Magento\Framework\Option\ArrayInterface as OptionArrayInterface;
1010

11-
interface GroupSourceForLoggedInCustomersInterface extends OptionArrayInterface
11+
interface GroupSourceLoggedInOnlyInterface extends OptionArrayInterface
1212
{
1313

1414
}

app/code/Magento/Customer/Model/Customer/Source/Group.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Magento\Customer\Api\GroupRepositoryInterface;
1212
use Magento\Framework\Api\SearchCriteriaBuilder;
1313

14-
class Group implements GroupSourceWithAllGroupsInterface
14+
class Group implements GroupSourceInterface
1515
{
1616
/**
1717
* @var ModuleManager
@@ -28,12 +28,6 @@ class Group implements GroupSourceWithAllGroupsInterface
2828
*/
2929
protected $searchCriteriaBuilder;
3030

31-
/**
32-
* Defines is 'ALL GROUPS' value should be added to options
33-
* @var bool
34-
*/
35-
protected $isShowAllGroupsValue = true;
36-
3731
/**
3832
* @param ModuleManager $moduleManager
3933
* @param GroupRepositoryInterface $groupRepository
@@ -60,13 +54,10 @@ public function toOptionArray()
6054
return [];
6155
}
6256
$customerGroups = [];
63-
64-
if ($this->isShowAllGroupsValue) {
65-
$customerGroups[] = [
66-
'label' => __('ALL GROUPS'),
67-
'value' => GroupInterface::CUST_GROUP_ALL,
68-
];
69-
}
57+
$customerGroups[] = [
58+
'label' => __('ALL GROUPS'),
59+
'value' => GroupInterface::CUST_GROUP_ALL,
60+
];
7061

7162
/** @var GroupSearchResultsInterface $groups */
7263
$groups = $this->groupRepository->getList($this->searchCriteriaBuilder->create());

app/code/Magento/Customer/Model/Customer/Source/GroupSourceInterface.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66
namespace Magento\Customer\Model\Customer\Source;
77

8-
98
use Magento\Framework\Option\ArrayInterface as OptionArrayInterface;
109

1110
interface GroupSourceInterface extends OptionArrayInterface

app/code/Magento/Customer/Model/Customer/Source/GroupSourceWithAllGroupsInterface.php

Lines changed: 0 additions & 12 deletions
This file was deleted.

app/code/Magento/Customer/Model/Customer/Source/GroupWithoutAllSources.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

app/code/Magento/Customer/Test/Unit/Model/Config/Source/Group/MultiselectTest.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
*/
77
namespace Magento\Customer\Test\Unit\Model\Config\Source\Group;
88

9+
use Magento\Customer\Model\Customer\Attribute\Source\GroupSourceLoggedInOnlyInterface;
10+
911
class MultiselectTest extends \PHPUnit_Framework_TestCase
1012
{
1113
/**
@@ -23,22 +25,29 @@ class MultiselectTest extends \PHPUnit_Framework_TestCase
2325
*/
2426
protected $converterMock;
2527

28+
/**
29+
* @var GroupSourceLoggedInOnlyInterface|\PHPUnit_Framework_MockObject_MockObject
30+
*/
31+
private $groupSourceLoggedInOnly;
32+
2633
protected function setUp()
2734
{
2835
$this->groupServiceMock = $this->getMock(\Magento\Customer\Api\GroupManagementInterface::class);
2936
$this->converterMock = $this->getMock(\Magento\Framework\Convert\DataObject::class, [], [], '', false);
30-
$this->model =
31-
new \Magento\Customer\Model\Config\Source\Group\Multiselect($this->groupServiceMock, $this->converterMock);
37+
$this->groupSourceLoggedInOnly = $this->getMockBuilder(GroupSourceLoggedInOnlyInterface::class)->getMock();
38+
$this->model = new \Magento\Customer\Model\Config\Source\Group\Multiselect(
39+
$this->groupServiceMock,
40+
$this->converterMock,
41+
$this->groupSourceLoggedInOnly
42+
);
3243
}
3344

3445
public function testToOptionArray()
3546
{
3647
$expectedValue = ['General', 'Retail'];
37-
$this->groupServiceMock->expects($this->once())
38-
->method('getLoggedInGroups')
39-
->will($this->returnValue($expectedValue));
40-
$this->converterMock->expects($this->once())->method('toOptionArray')
41-
->with($expectedValue, 'id', 'code')->will($this->returnValue($expectedValue));
48+
$this->groupServiceMock->expects($this->never())->method('getLoggedInGroups');
49+
$this->converterMock->expects($this->never())->method('toOptionArray');
50+
$this->groupSourceLoggedInOnly->expects($this->once())->method('toOptionArray')->willReturn($expectedValue);
4251
$this->assertEquals($expectedValue, $this->model->toOptionArray());
4352
}
4453
}

0 commit comments

Comments
 (0)