11<?php
22
3- namespace Tests ;
3+ namespace Laravel \ Scout \ Tests ;
44
5- use Mockery ;
5+ use Mockery as m ;
66use Laravel \Scout \Builder ;
7- use Tests \ Fixtures \ EmptyTestModel ;
7+ use PHPUnit \ Framework \ TestCase ;
88use Laravel \Scout \Engines \AlgoliaEngine ;
9- use Tests \Fixtures \AlgoliaEngineTestModel ;
109use Illuminate \Database \Eloquent \Collection ;
11- use Tests \Fixtures \AlgoliaEngineTestCustomKeyModel ;
10+ use Laravel \Scout \Tests \Fixtures \EmptyTestModel ;
11+ use Laravel \Scout \Tests \Fixtures \AlgoliaEngineTestModel ;
12+ use Laravel \Scout \Tests \Fixtures \AlgoliaEngineTestCustomKeyModel ;
1213
13- class AlgoliaEngineTest extends AbstractTestCase
14+ class AlgoliaEngineTest extends TestCase
1415{
16+ public function tearDown ()
17+ {
18+ m::close ();
19+ }
20+
1521 public function test_update_adds_objects_to_index ()
1622 {
17- $ client = Mockery ::mock ('AlgoliaSearch\Client ' );
18- $ client ->shouldReceive ('initIndex ' )->with ('table ' )->andReturn ($ index = Mockery ::mock ('StdClass ' ));
23+ $ client = m ::mock ('AlgoliaSearch\Client ' );
24+ $ client ->shouldReceive ('initIndex ' )->with ('table ' )->andReturn ($ index = m ::mock ('StdClass ' ));
1925 $ index ->shouldReceive ('addObjects ' )->with ([[
2026 'id ' => 1 ,
2127 'objectID ' => 1 ,
@@ -27,8 +33,8 @@ public function test_update_adds_objects_to_index()
2733
2834 public function test_delete_removes_objects_to_index ()
2935 {
30- $ client = Mockery ::mock ('AlgoliaSearch\Client ' );
31- $ client ->shouldReceive ('initIndex ' )->with ('table ' )->andReturn ($ index = Mockery ::mock ('StdClass ' ));
36+ $ client = m ::mock ('AlgoliaSearch\Client ' );
37+ $ client ->shouldReceive ('initIndex ' )->with ('table ' )->andReturn ($ index = m ::mock ('StdClass ' ));
3238 $ index ->shouldReceive ('deleteObjects ' )->with ([1 ]);
3339
3440 $ engine = new AlgoliaEngine ($ client );
@@ -37,8 +43,8 @@ public function test_delete_removes_objects_to_index()
3743
3844 public function test_search_sends_correct_parameters_to_algolia ()
3945 {
40- $ client = Mockery ::mock ('AlgoliaSearch\Client ' );
41- $ client ->shouldReceive ('initIndex ' )->with ('table ' )->andReturn ($ index = Mockery ::mock ('StdClass ' ));
46+ $ client = m ::mock ('AlgoliaSearch\Client ' );
47+ $ client ->shouldReceive ('initIndex ' )->with ('table ' )->andReturn ($ index = m ::mock ('StdClass ' ));
4248 $ index ->shouldReceive ('search ' )->with ('zonda ' , [
4349 'numericFilters ' => ['foo=1 ' ],
4450 ]);
@@ -51,15 +57,15 @@ public function test_search_sends_correct_parameters_to_algolia()
5157
5258 public function test_map_correctly_maps_results_to_models ()
5359 {
54- $ client = Mockery ::mock ('AlgoliaSearch\Client ' );
60+ $ client = m ::mock ('AlgoliaSearch\Client ' );
5561 $ engine = new AlgoliaEngine ($ client );
5662
57- $ model = Mockery ::mock ('StdClass ' );
63+ $ model = m ::mock ('StdClass ' );
5864 $ model ->shouldReceive ('newQuery ' )->andReturn ($ model );
5965 $ model ->shouldReceive ('getKeyName ' )->andReturn ('id ' );
6066 $ model ->shouldReceive ('getScoutModelsByIds ' )->andReturn (Collection::make ([new AlgoliaEngineTestModel ]));
6167
62- $ builder = Mockery ::mock (Builder::class);
68+ $ builder = m ::mock (Builder::class);
6369
6470 $ results = $ engine ->map ($ builder , ['nbHits ' => 1 , 'hits ' => [
6571 ['objectID ' => 1 , 'id ' => 1 ],
@@ -70,8 +76,8 @@ public function test_map_correctly_maps_results_to_models()
7076
7177 public function test_a_model_is_indexed_with_a_custom_algolia_key ()
7278 {
73- $ client = Mockery ::mock ('AlgoliaSearch\Client ' );
74- $ client ->shouldReceive ('initIndex ' )->with ('table ' )->andReturn ($ index = Mockery ::mock ('StdClass ' ));
79+ $ client = m ::mock ('AlgoliaSearch\Client ' );
80+ $ client ->shouldReceive ('initIndex ' )->with ('table ' )->andReturn ($ index = m ::mock ('StdClass ' ));
7581 $ index ->shouldReceive ('addObjects ' )->with ([[
7682 'id ' => 1 ,
7783 'objectID ' => 'my-algolia-key.1 ' ,
@@ -83,8 +89,8 @@ public function test_a_model_is_indexed_with_a_custom_algolia_key()
8389
8490 public function test_a_model_is_removed_with_a_custom_algolia_key ()
8591 {
86- $ client = Mockery ::mock ('AlgoliaSearch\Client ' );
87- $ client ->shouldReceive ('initIndex ' )->with ('table ' )->andReturn ($ index = Mockery ::mock ('StdClass ' ));
92+ $ client = m ::mock ('AlgoliaSearch\Client ' );
93+ $ client ->shouldReceive ('initIndex ' )->with ('table ' )->andReturn ($ index = m ::mock ('StdClass ' ));
8894 $ index ->shouldReceive ('deleteObjects ' )->with (['my-algolia-key.1 ' ]);
8995
9096 $ engine = new AlgoliaEngine ($ client );
@@ -93,8 +99,8 @@ public function test_a_model_is_removed_with_a_custom_algolia_key()
9399
94100 public function test_flush_a_model ()
95101 {
96- $ client = Mockery ::mock ('AlgoliaSearch\Client ' );
97- $ client ->shouldReceive ('initIndex ' )->with ('table ' )->andReturn ($ index = Mockery ::mock ('StdClass ' ));
102+ $ client = m ::mock ('AlgoliaSearch\Client ' );
103+ $ client ->shouldReceive ('initIndex ' )->with ('table ' )->andReturn ($ index = m ::mock ('StdClass ' ));
98104 $ index ->shouldReceive ('clearIndex ' );
99105
100106 $ engine = new AlgoliaEngine ($ client );
@@ -103,8 +109,8 @@ public function test_flush_a_model()
103109
104110 public function test_update_empty_searchable_array_does_not_add_objects_to_index ()
105111 {
106- $ client = Mockery ::mock ('AlgoliaSearch\Client ' );
107- $ client ->shouldReceive ('initIndex ' )->with ('table ' )->andReturn ($ index = Mockery ::mock ('StdClass ' ));
112+ $ client = m ::mock ('AlgoliaSearch\Client ' );
113+ $ client ->shouldReceive ('initIndex ' )->with ('table ' )->andReturn ($ index = m ::mock ('StdClass ' ));
108114 $ index ->shouldNotReceive ('addObjects ' );
109115
110116 $ engine = new AlgoliaEngine ($ client );
0 commit comments