Code Duplication    Length = 17-17 lines in 2 locations

Tests/Query/SearchTextFilterReducerTest.php 2 locations

@@ 72-88 (lines=17) @@
69
        $this->assertEquals('Field1 = "test" or Field2 = "test" or Field3 = "test"', $reducedFilter[3]->toUQL());
70
    }
71
72
    public function testReducesSearchTextFilterWithFilterConditionsAndUsesWildcardForLikeComparisonMethod()
73
    {
74
        $fields = [
75
            $this->buildField('Field1', new StringDataType(), 'field1'),
76
            $this->buildField('Field2', new StringDataType(), 'field2'),
77
            $this->buildField('Field3', new StringDataType(), 'field3'),
78
        ];
79
80
        $filterToReduce = $this->createFilter(Filter::CONDITION_TYPE_OR, [
81
            $this->createFilterCondition('column_search_text', FilterCondition::METHOD_STRING_LIKE, 'test', true),
82
        ]);
83
84
        $searchTextFilterReducer = new SearchTextFilterReducer($fields);
85
        $reducedFilter = $searchTextFilterReducer->reduceToFilterCondition($filterToReduce);
86
87
        $this->assertEquals('Field1 ~ "%test%" or Field2 ~ "%test%" or Field3 ~ "%test%"', $reducedFilter[0]->toUQL());
88
    }
89
90
    public function testReducesSearchTextFilterWithFilterConditionsButSkipsFieldsThatDoNotSupportGivenMethod()
91
    {
@@ 112-128 (lines=17) @@
109
        $this->assertEquals('StringField = "test" or AnotherStringField = "test"', $reducedFilter[0]->toUQL());
110
    }
111
112
    public function testReducesSearchTextFilterWithFilterConditionsButSkipsFieldsThatDoNotDefineDatabaseFilterQueryField()
113
    {
114
        $fields = [
115
            $this->buildField('FieldWithDbQueryField', new StringDataType(), 'field_with_db_field'),
116
            $this->buildField('FieldWithoutDbQueryField', new StringDataType(), null),
117
            $this->buildField('AnotherFieldWithDbQueryField', new StringDataType(), 'another_field_with_db_field'),
118
        ];
119
120
        $filterToReduce = $this->createFilter(Filter::CONDITION_TYPE_OR, [
121
            $this->createFilterCondition('column_search_text', FilterCondition::METHOD_STRING_EQ, 'test', true),
122
        ]);
123
124
        $searchTextFilterReducer = new SearchTextFilterReducer($fields);
125
        $reducedFilter = $searchTextFilterReducer->reduceToFilterCondition($filterToReduce);
126
127
        $this->assertEquals('FieldWithDbQueryField = "test" or AnotherFieldWithDbQueryField = "test"', $reducedFilter[0]->toUQL());
128
    }
129
130
    public function testReducesSearchTextFilterWithFilterConditionsButSkipsFieldsThatDefineDatabaseSelectAliasAsArray()
131
    {