17 private $defaultPriceMock;
26 $this->defaultPriceMock = $this->getMockBuilder(DefaultPrice::class)->disableOriginalConstructor()->getMock();
33 $maxRelatedProductCount = 200;
35 $connectionMock = $this->getMockBuilder(\
Magento\Framework\DB\Adapter\AdapterInterface::class)->getMock();
36 $this->defaultPriceMock->expects($this->once())->method(
'getConnection')->willReturn($connectionMock);
37 $this->defaultPriceMock->expects($this->once())->method(
'getTable')->with(
$tableName)->willReturn(
$tableName);
39 $relationSelectMock = $this->getMockBuilder(\
Magento\Framework\DB\Select::class)
40 ->disableOriginalConstructor()
42 $relationSelectMock->expects($this->once())
46 [
'count' =>
'count(relation.child_id)']
49 $relationSelectMock->expects($this->once())->method(
'group')->with(
'parent_id')->willReturnSelf();
50 $connectionMock->expects($this->at(0))->method(
'select')->willReturn($relationSelectMock);
52 $maxSelectMock = $this->getMockBuilder(\
Magento\Framework\DB\Select::class)
53 ->disableOriginalConstructor()
55 $maxSelectMock->expects($this->once())
58 [
'max_value' => $relationSelectMock],
59 [
'count' =>
'MAX(count)']
62 $connectionMock->expects($this->at(1))->method(
'select')->willReturn($maxSelectMock);
64 $connectionMock->expects($this->at(2))
66 ->with($maxSelectMock)
67 ->willReturn($maxRelatedProductCount);
69 $this->assertEquals($maxRelatedProductCount, $this->model->getMaxRelationsCount());
testGetMaxRelationsCount()