@@ -84,10 +84,33 @@ public function test_search()
84
84
{
85
85
list ($ engine , $ db ) = $ this ->getEngine ();
86
86
87
- $ table = $ this ->setDbExpectations ($ db );
87
+ $ skip = 0 ;
88
+ $ limit = 5 ;
89
+ $ table = $ this ->setDbExpectations ($ db , $ skip , $ limit );
88
90
89
- $ table ->shouldReceive ('skip ' )->with (0 )->andReturnSelf ()
90
- ->shouldReceive ('limit ' )->with (5 )->andReturnSelf ()
91
+ $ table ->shouldReceive ('skip ' )->with ($ skip )->andReturnSelf ()
92
+ ->shouldReceive ('limit ' )->with ($ limit )->andReturnSelf ()
93
+ ->shouldReceive ('where ' )->with ('bar ' , 1 );
94
+
95
+ $ db ->shouldReceive ('select ' )->with (null , ['foo ' , 1 ]);
96
+
97
+ $ builder = new Builder (new TestModel (), 'foo ' );
98
+ $ builder ->where ('bar ' , 1 )->take (5 );
99
+
100
+ $ engine ->search ($ builder );
101
+ }
102
+
103
+ public function test_search_configuration ()
104
+ {
105
+ $ searchConfig = 'simple ' ;
106
+ list ($ engine , $ db ) = $ this ->getEngine (['search_configuration ' => $ searchConfig ]);
107
+
108
+ $ skip = 0 ;
109
+ $ limit = 5 ;
110
+ $ table = $ this ->setDbExpectations ($ db , $ skip , $ limit , "' " .$ searchConfig ."' " );
111
+
112
+ $ table ->shouldReceive ('skip ' )->with ($ skip )->andReturnSelf ()
113
+ ->shouldReceive ('limit ' )->with ($ limit )->andReturnSelf ()
91
114
->shouldReceive ('where ' )->with ('bar ' , 1 );
92
115
93
116
$ db ->shouldReceive ('select ' )->with (null , ['foo ' , 1 ]);
@@ -152,15 +175,15 @@ protected function getEngine($config = [])
152
175
return [new PostgresEngine ($ resolver , $ config ), $ db ];
153
176
}
154
177
155
- protected function setDbExpectations ($ db , $ skip = 0 , $ limit = 5 )
178
+ protected function setDbExpectations ($ db , $ skip = 0 , $ limit = 5 , $ searchConfiguration = '' )
156
179
{
157
180
$ db ->shouldReceive ('table ' )
158
181
->andReturn ($ table = Mockery::mock ('stdClass ' ));
159
182
$ db ->shouldReceive ('raw ' )
160
- ->with (' plainto_tsquery( ?) query ' )
161
- ->andReturn (' plainto_tsquery( ?) query ' );
183
+ ->with (" plainto_tsquery( $ searchConfiguration ?) query " )
184
+ ->andReturn (" plainto_tsquery( $ searchConfiguration ?) query " );
162
185
163
- $ table ->shouldReceive ('crossJoin ' )->with (' plainto_tsquery( ?) query ' )->andReturnSelf ()
186
+ $ table ->shouldReceive ('crossJoin ' )->with (" plainto_tsquery( $ searchConfiguration ?) query " )->andReturnSelf ()
164
187
->shouldReceive ('select ' )->with ('id ' )->andReturnSelf ()
165
188
->shouldReceive ('selectRaw ' )->with ('ts_rank(searchable,query) AS rank ' )->andReturnSelf ()
166
189
->shouldReceive ('selectRaw ' )->with ('COUNT(*) OVER () AS total_count ' )->andReturnSelf ()
0 commit comments