@@ -78,6 +78,32 @@ public function testTransform()
78
78
$ this ->assertSame ('property = ? ' , $ sqlFilter ->getExpression ());
79
79
$ this ->assertCount (1 , $ sqlFilter ->getParams ());
80
80
$ this ->assertSame ('Sample string ' , $ sqlFilter ->getParams ()[0 ]);
81
+
82
+ // Test with a complex filter and only one property (currently not supported so considered as string for now)
83
+ // Sample complex filters with only one property would be
84
+ // "<10->2" : Lower than 10 or greater than 2
85
+ // "'Handball'-'Football'" : Equals to 'Hand ball' or 'Foot ball'
86
+ // "'*ball*'+'*tennis*'" : Like 'ball' and like 'tennis'
87
+ $ sqlFilter = $ this ->filterConverter ->transform ('property ' , '<10->2 ' );
88
+ $ this ->assertSame ('property = ? ' , $ sqlFilter ->getExpression ());
89
+ $ this ->assertCount (1 , $ sqlFilter ->getParams ());
90
+ $ this ->assertSame ('<10->2 ' , $ sqlFilter ->getParams ()[0 ]);
91
+
92
+ // Test with a complex filter with multiple properties (currently not supported and will fail)
93
+ try {
94
+ $ this ->filterConverter ->transform (0 , 'price:<90-validity:>=3 ' );
95
+ $ this ->fail ('Must have thrown a ConverterException ! ' );
96
+ } catch (ConverterException $ cex ) {
97
+ $ this ->assertSame ('Complex filters are currently not implemented ! ' , $ cex ->getMessage ());
98
+ }
99
+
100
+ // Test with a key which has a bad type
101
+ try {
102
+ $ this ->filterConverter ->transform (0.26 , '>10 ' );
103
+ $ this ->fail ('Must have thrown a ConverterException ! ' );
104
+ } catch (ConverterException $ cex ) {
105
+ $ this ->assertSame ('Invalid filter key type ! ' , $ cex ->getMessage ());
106
+ }
81
107
}
82
108
83
109
/**
0 commit comments