Skip to content

Commit c054450

Browse files
committed
MAGETWO-54460: Admin user with access to only one website is unable to edit a product
- added test
1 parent dd65894 commit c054450

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

app/code/Magento/Rule/Test/Unit/Model/ResourceModel/Rule/Collection/AbstractCollectionTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ class AbstractCollectionTest extends \PHPUnit_Framework_TestCase
4545
*/
4646
protected $_db;
4747

48+
/**
49+
* @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
50+
*/
51+
private $connectionMock;
52+
53+
/**
54+
* @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject
55+
*/
56+
private $selectMock;
57+
4858
protected function setUp()
4959
{
5060
$this->_entityFactoryMock = $this->getMock(\Magento\Framework\Data\Collection\EntityFactoryInterface::class);
@@ -152,6 +162,30 @@ public function testAddWebsiteFilter()
152162
);
153163
}
154164

165+
public function testAddWebsiteFilterArray()
166+
{
167+
$this->selectMock = $this->getMockBuilder(\Magento\Framework\DB\Select::class)
168+
->disableOriginalConstructor()
169+
->getMock();
170+
171+
$this->connectionMock = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)
172+
->disableOriginalConstructor()
173+
->getMockForAbstractClass();
174+
$this->connectionMock->expects($this->atLeastOnce())
175+
->method('quoteInto')
176+
->with($this->equalTo('website. IN (?)'), $this->equalTo(['2', '3']))
177+
->willReturn(true);
178+
179+
$this->abstractCollection->expects($this->atLeastOnce())->method('getSelect')->willReturn($this->selectMock);
180+
$this->abstractCollection->expects($this->atLeastOnce())->method('getConnection')
181+
->willReturn($this->connectionMock);
182+
183+
$this->assertInstanceOf(
184+
\Magento\Rule\Model\ResourceModel\Rule\Collection\AbstractCollection::class,
185+
$this->abstractCollection->addWebsiteFilter(['2', '3'])
186+
);
187+
}
188+
155189
public function testAddFieldToFilter()
156190
{
157191
$this->_prepareAddFilterStubs();

0 commit comments

Comments
 (0)