44 $this->storeManager = $this->createMock(\
Magento\Store\Model\StoreManagerInterface::class);
45 $this->select = $this->createPartialMock(\
Magento\Framework\DB\Select::class, [
'from',
'where']);
46 $this->connectionMock = $this->createPartialMock(
47 \
Magento\Framework\DB\Adapter\Pdo\Mysql::class,
48 [
'select',
'prepareSqlCondition',
'quoteIdentifier']
50 $this->resource = $this->getMockForAbstractClass(
57 [
'getConnection',
'__wakeup',
'getMainTable',
'getTable']
60 $this->select->expects($this->any())
62 ->will($this->returnSelf());
63 $this->connectionMock->expects($this->any())
65 ->will($this->returnValue($this->select));
66 $this->connectionMock->expects($this->any())
67 ->method(
'quoteIdentifier')
68 ->will($this->returnArgument(0));
69 $this->resource->expects($this->any())
70 ->method(
'getConnection')
71 ->will($this->returnValue($this->connectionMock));
72 $this->resource->expects($this->any())
73 ->method(
'getMainTable')
74 ->will($this->returnValue(
'test_main_table'));
75 $this->resource->expects($this->any())
77 ->with(
'test_main_table')
78 ->will($this->returnValue(
'test_main_table'));
83 'storeManager' => $this->storeManager,
84 'resource' => $this->resource,
98 $this->connectionMock->expects($this->once())
99 ->method(
'prepareSqlCondition')
100 ->with(
'store_id', [
'in' => $condition]);
102 $this->collection->addStoreFilter(
$storeId, $withAdmin);
111 [[112, 113],
false, [112, 113]],
112 [[112, 113],
true, [112, 113, 0]],
125 $store = $this->createMock(\
Magento\Store\Model\Store::class);
126 $store->expects($this->once())->method(
'getId')->will($this->returnValue(
$storeId));
127 $this->storeManager->expects($this->once())->method(
'getStore')->will($this->returnValue(
$store));
129 $this->connectionMock->expects($this->once())
130 ->method(
'prepareSqlCondition')
131 ->with(
'store_id', [
'in' => $condition]);
133 $this->collection->addStoreFilter(
$storeId, $withAdmin);
143 [112,
true, [112, 0]],
dataProviderForTestAddStoreIfStoreIsArray()
testAddStoreFilterIfStoreIsArray($storeId, $withAdmin, $condition)
dataProviderForTestAddStoreFilterIfStoreIsInt()
testAddStoreFilterIfStoreIsInt($storeId, $withAdmin, $condition)