@@ 23-46 (lines=24) @@ | ||
20 | $this->assertEquals(Filter::CONDITION_TYPE_OR, $result->getConditionType()); |
|
21 | } |
|
22 | ||
23 | public function testTransformWithOneField() |
|
24 | { |
|
25 | $searchPhrase = 'search phrase'; |
|
26 | ||
27 | $dataType = $this->prophesize(DataTypeInterface::class); |
|
28 | $dataType->supports(Argument::any())->willReturn(true); |
|
29 | ||
30 | $field = $this->prophesize(Field::class); |
|
31 | $field->getDataType()->willReturn($dataType->reveal()); |
|
32 | $field->getDatabaseFilterQueryField()->willReturn('query_field'); |
|
33 | $field->getDatabaseSelectAlias()->willReturn('alias'); |
|
34 | $field->getUniqueName()->shouldBeCalled(); |
|
35 | ||
36 | $filterCondition = $this->prophesize(FilterCondition::class); |
|
37 | $filterCondition->getValue()->willReturn($searchPhrase); |
|
38 | $filterCondition->getMethod()->shouldBeCalled(); |
|
39 | $transformer = new SearchTextFilterConditionTransformer(); |
|
40 | $result = $transformer->transform($filterCondition->reveal(), [$field->reveal()]); |
|
41 | ||
42 | $this->assertInstanceOf(Filter::class, $result); |
|
43 | $this->assertCount(1, $result); |
|
44 | $this->assertInstanceOf(FilterCondition::class, $result[0]); |
|
45 | $this->assertEquals($searchPhrase, $result[0]->getValue()); |
|
46 | } |
|
47 | ||
48 | public function testTransformWithOneFieldUsingLikeMethod() |
|
49 | { |
|
@@ 48-71 (lines=24) @@ | ||
45 | $this->assertEquals($searchPhrase, $result[0]->getValue()); |
|
46 | } |
|
47 | ||
48 | public function testTransformWithOneFieldUsingLikeMethod() |
|
49 | { |
|
50 | $searchPhrase = 'search phrase'; |
|
51 | ||
52 | $dataType = $this->prophesize(DataTypeInterface::class); |
|
53 | $dataType->supports(Argument::any())->willReturn(true); |
|
54 | ||
55 | $field = $this->prophesize(Field::class); |
|
56 | $field->getDataType()->willReturn($dataType->reveal()); |
|
57 | $field->getDatabaseFilterQueryField()->willReturn('query_field'); |
|
58 | $field->getDatabaseSelectAlias()->willReturn('alias'); |
|
59 | $field->getUniqueName()->shouldBeCalled(); |
|
60 | ||
61 | $filterCondition = $this->prophesize(FilterCondition::class); |
|
62 | $filterCondition->getValue()->willReturn($searchPhrase); |
|
63 | $filterCondition->getMethod()->willReturn(FilterCondition::METHOD_STRING_LIKE); |
|
64 | $transformer = new SearchTextFilterConditionTransformer(); |
|
65 | $result = $transformer->transform($filterCondition->reveal(), [$field->reveal()]); |
|
66 | ||
67 | $this->assertInstanceOf(Filter::class, $result); |
|
68 | $this->assertCount(1, $result); |
|
69 | $this->assertInstanceOf(FilterCondition::class, $result[0]); |
|
70 | $this->assertEquals("%$searchPhrase%", $result[0]->getValue()); |
|
71 | } |
|
72 | ||
73 | public function testTransformDoNotTransformUnsupportedMethod() |
|
74 | { |