18 private $selectBuilder;
23 private $resourceConnectionMock;
28 private $connectionMock;
40 $this->resourceConnectionMock = $this->getMockBuilder(ResourceConnection::class)
41 ->disableOriginalConstructor()
44 $this->connectionMock = $this->getMockBuilder(AdapterInterface::class)
45 ->disableOriginalConstructor()
48 $this->selectMock = $this->getMockBuilder(Select::class)
49 ->disableOriginalConstructor()
52 $this->selectBuilder =
new SelectBuilder($this->resourceConnectionMock);
57 $connectionName =
'MySql';
58 $from = [
'customer c'];
62 [
'link-type' =>
'left',
'table' =>
'customer',
'condition' =>
'in'],
63 [
'link-type' =>
'inner',
'table' =>
'price',
'condition' =>
'eq'],
64 [
'link-type' =>
'right',
'table' =>
'attribute',
'condition' =>
'neq'],
66 $groups = [
'id',
'name'];
67 $this->selectBuilder->setConnectionName($connectionName);
68 $this->selectBuilder->setFrom($from);
69 $this->selectBuilder->setColumns(
$columns);
70 $this->selectBuilder->setFilters([$filter]);
71 $this->selectBuilder->setJoins($joins);
72 $this->selectBuilder->setGroup($groups);
73 $this->resourceConnectionMock->expects($this->once())
74 ->method(
'getConnection')
75 ->with($connectionName)
76 ->willReturn($this->connectionMock);
77 $this->connectionMock->expects($this->once())
79 ->willReturn($this->selectMock);
80 $this->selectMock->expects($this->once())
83 $this->selectMock->expects($this->once())
86 $this->selectMock->expects($this->once())
89 $this->selectMock->expects($this->once())
91 ->with($joins[0][
'table'], $joins[0][
'condition'], []);
92 $this->selectMock->expects($this->once())
94 ->with($joins[1][
'table'], $joins[1][
'condition'], []);
95 $this->selectMock->expects($this->once())
97 ->with($joins[2][
'table'], $joins[2][
'condition'], []);
98 $this->selectBuilder->create();