19 private $resourceConnectionMock;
24 private $conditionResolver;
29 private $selectBuilderMock;
34 private $connectionMock;
41 $this->resourceConnectionMock = $this->getMockBuilder(ResourceConnection::class)
42 ->disableOriginalConstructor()
45 $this->selectBuilderMock = $this->getMockBuilder(SelectBuilder::class)
46 ->disableOriginalConstructor()
49 $this->connectionMock = $this->getMockBuilder(AdapterInterface::class)
50 ->disableOriginalConstructor()
58 $condition = [
"type" =>
"variable",
"_value" =>
"1",
"attribute" =>
"id",
"operator" =>
"neq"];
59 $valueCondition = [
"type" =>
"value",
"_value" =>
"2",
"attribute" =>
"first_name",
"operator" =>
"eq"];
60 $identifierCondition = [
61 "type" =>
"identifier",
62 "_value" =>
"other_field",
63 "attribute" =>
"last_name",
65 $filter = [[
"glue" =>
"AND",
"condition" => [$valueCondition]]];
67 [
"glue" =>
"OR",
"condition" => [$condition],
'filter' => $filter],
68 [
"glue" =>
"OR",
"condition" => [$identifierCondition]],
71 $this->selectBuilderMock->expects($this->any())
73 ->with(array_merge([], [$condition[
'_value']]));
75 $this->selectBuilderMock->expects($this->once())
79 $this->selectBuilderMock->expects($this->any())
80 ->method(
'getColumns')
81 ->willReturn([
'price' =>
new Expression(
"(n.price = 400)")]);
83 $this->resourceConnectionMock->expects($this->once())
84 ->method(
'getConnection')
85 ->willReturn($this->connectionMock);
87 $this->connectionMock->expects($this->any())
89 ->willReturn(
"'John'");
90 $this->connectionMock->expects($this->exactly(4))
91 ->method(
'quoteIdentifier')
93 [
'n.id',
false,
'`n`.`id`'],
94 [
'n.first_name',
false,
'`n`.`first_name`'],
95 [
'n.last_name',
false,
'`n`.`last_name`'],
96 [
'other_field',
false,
'`other_field`'],
99 $result =
"(`n`.`id` != 1 OR ((`n`.`first_name` = 'John'))) OR (`n`.`last_name` = `other_field`)";
102 $this->conditionResolver->getFilter($this->selectBuilderMock, $filterConfig, $aliasName)