@@ -19,14 +19,25 @@ class SearchableTest extends TestCase
19
19
public function test_searchable_using_update_is_called_on_collection ()
20
20
{
21
21
$ collection = m::mock ();
22
- $ collection ->shouldReceive ('isEmpty ' )->once ( )->andReturn (false );
22
+ $ collection ->shouldReceive ('isEmpty ' )->times ( 2 )->andReturn (false );
23
23
$ collection ->shouldReceive ('first->makeSearchableUsing ' )->with ($ collection )->once ()->andReturn ($ collection );
24
24
$ collection ->shouldReceive ('first->searchableUsing->update ' )->with ($ collection )->once ();
25
25
26
26
$ model = new SearchableModel ;
27
27
$ model ->queueMakeSearchable ($ collection );
28
28
}
29
29
30
+ public function test_searchable_using_update_is_called_on_collection_sync ()
31
+ {
32
+ $ collection = m::mock ();
33
+ $ collection ->shouldReceive ('isEmpty ' )->once ()->andReturn (false );
34
+ $ collection ->shouldReceive ('first->makeSearchableUsing ' )->with ($ collection )->once ()->andReturn ($ collection );
35
+ $ collection ->shouldReceive ('first->searchableUsing->update ' )->with ($ collection )->once ();
36
+
37
+ $ model = new SearchableModel ;
38
+ $ model ->syncMakeSearchable ($ collection );
39
+ }
40
+
30
41
public function test_searchable_using_update_is_not_called_on_empty_collection ()
31
42
{
32
43
$ collection = m::mock ();
@@ -35,6 +46,13 @@ public function test_searchable_using_update_is_not_called_on_empty_collection()
35
46
36
47
$ model = new SearchableModel ;
37
48
$ model ->queueMakeSearchable ($ collection );
49
+
50
+ $ collection = m::mock ();
51
+ $ collection ->shouldReceive ('isEmpty ' )->andReturn (true );
52
+ $ collection ->shouldNotReceive ('first->searchableUsing->update ' );
53
+
54
+ $ model = new SearchableModel ;
55
+ $ model ->syncMakeSearchable ($ collection );
38
56
}
39
57
40
58
public function test_overridden_make_searchable_is_dispatched ()
@@ -58,13 +76,23 @@ public function test_overridden_make_searchable_is_dispatched()
58
76
public function test_searchable_using_delete_is_called_on_collection ()
59
77
{
60
78
$ collection = m::mock ();
61
- $ collection ->shouldReceive ('isEmpty ' )->once ( )->andReturn (false );
79
+ $ collection ->shouldReceive ('isEmpty ' )->times ( 2 )->andReturn (false );
62
80
$ collection ->shouldReceive ('first->searchableUsing->delete ' )->with ($ collection );
63
81
64
82
$ model = new SearchableModel ;
65
83
$ model ->queueRemoveFromSearch ($ collection );
66
84
}
67
85
86
+ public function test_searchable_using_delete_is_called_on_collection_sycn ()
87
+ {
88
+ $ collection = m::mock ();
89
+ $ collection ->shouldReceive ('isEmpty ' )->once ()->andReturn (false );
90
+ $ collection ->shouldReceive ('first->searchableUsing->delete ' )->with ($ collection );
91
+
92
+ $ model = new SearchableModel ;
93
+ $ model ->syncRemoveFromSearch ($ collection );
94
+ }
95
+
68
96
public function test_searchable_using_delete_is_not_called_on_empty_collection ()
69
97
{
70
98
$ collection = m::mock ();
@@ -73,6 +101,13 @@ public function test_searchable_using_delete_is_not_called_on_empty_collection()
73
101
74
102
$ model = new SearchableModel ;
75
103
$ model ->queueRemoveFromSearch ($ collection );
104
+
105
+ $ collection = m::mock ();
106
+ $ collection ->shouldReceive ('isEmpty ' )->once ()->andReturn (true );
107
+ $ collection ->shouldNotReceive ('first->searchableUsing->delete ' );
108
+
109
+ $ model = new SearchableModel ;
110
+ $ model ->syncRemoveFromSearch ($ collection );
76
111
}
77
112
78
113
public function test_overridden_remove_from_search_is_dispatched ()
0 commit comments