@@ -137,6 +137,7 @@ public function onConnectionCreatedWithCurrentJob(): void
137
137
$ this ->setCurrentJobInitialization ($ listener , $ this ->initialization );
138
138
139
139
$ this ->initialization ->shouldReceive ('initializeOnNewConnection ' )->once ()->with ($ event )->andReturnSelf ();
140
+ $ connection ->shouldReceive ('getConfig ' )->once ()->with ('sticky ' )->andReturnTrue ();
140
141
$ this ->stickiness ->shouldReceive ('resolveRecordsModified ' )->once ();
141
142
142
143
$ listener ->onConnectionCreated (new ConnectionCreated ($ connection ));
@@ -152,11 +153,28 @@ public function onConnectionCreatedWithoutCurrentJob(): void
152
153
$ this ->setCurrentJobInitialization ($ listener , null );
153
154
154
155
$ this ->initialization ->shouldNotReceive ('initializeOnNewConnection ' );
156
+ $ connection ->shouldReceive ('getConfig ' )->once ()->with ('sticky ' )->andReturnTrue ();
155
157
$ this ->stickiness ->shouldReceive ('resolveRecordsModified ' )->once ();
156
158
157
159
$ listener ->onConnectionCreated (new ConnectionCreated ($ connection ));
158
160
}
159
161
162
+ public function onConnectionCreatedWhenStickyDisabled (): void
163
+ {
164
+ $ connection = Mockery::mock (Connection::class);
165
+
166
+ $ listener = new StickinessEventListener ($ this ->stickiness );
167
+
168
+ $ this ->setCurrentJobProcessingEvent ($ listener , null );
169
+ $ this ->setCurrentJobInitialization ($ listener , null );
170
+
171
+ $ this ->initialization ->shouldNotReceive ('initializeOnNewConnection ' );
172
+ $ connection ->shouldReceive ('getConfig ' )->once ()->with ('sticky ' )->andReturnFalse ();
173
+ $ this ->stickiness ->shouldNotReceive ('resolveRecordsModified ' );
174
+
175
+ $ listener ->onConnectionCreated (new ConnectionCreated ($ connection ));
176
+ }
177
+
160
178
public function testOnRecordsHaveBeenModifiedWithCurrentJob (): void
161
179
{
162
180
$ connection = Mockery::mock (ConnectionInterface::class);
@@ -167,6 +185,7 @@ public function testOnRecordsHaveBeenModifiedWithCurrentJob(): void
167
185
$ this ->setCurrentJobInitialization ($ listener , $ this ->initialization );
168
186
169
187
$ this ->initialization ->shouldReceive ('dontRevokeEffectsOn ' )->once ()->with ($ connection )->andReturnSelf ();
188
+ $ connection ->shouldReceive ('getConfig ' )->once ()->with ('sticky ' )->andReturnTrue ();
170
189
$ this ->stickiness ->shouldReceive ('markAsModified ' )->once ()->with ($ connection );
171
190
172
191
$ listener ->onRecordsHaveBeenModified (new RecordsHaveBeenModified ($ connection ));
@@ -182,8 +201,25 @@ public function testOnRecordsHaveBeenModifiedWithoutCurrentJob(): void
182
201
$ this ->setCurrentJobInitialization ($ listener , null );
183
202
184
203
$ this ->initialization ->shouldNotReceive ('dontRevokeEffectsOn ' );
204
+ $ connection ->shouldReceive ('getConfig ' )->once ()->with ('sticky ' )->andReturnTrue ();
185
205
$ this ->stickiness ->shouldReceive ('markAsModified ' )->once ()->with ($ connection );
186
206
187
207
$ listener ->onRecordsHaveBeenModified (new RecordsHaveBeenModified ($ connection ));
188
208
}
209
+
210
+ public function testOnRecordsHaveBeenModifiedWhenStickyDisabled (): void
211
+ {
212
+ $ connection = Mockery::mock (ConnectionInterface::class);
213
+
214
+ $ listener = new StickinessEventListener ($ this ->stickiness );
215
+
216
+ $ this ->setCurrentJobProcessingEvent ($ listener , null );
217
+ $ this ->setCurrentJobInitialization ($ listener , null );
218
+
219
+ $ this ->initialization ->shouldNotReceive ('dontRevokeEffectsOn ' );
220
+ $ connection ->shouldReceive ('getConfig ' )->once ()->with ('sticky ' )->andReturnFalse ();
221
+ $ this ->stickiness ->shouldNotReceive ('markAsModified ' );
222
+
223
+ $ listener ->onRecordsHaveBeenModified (new RecordsHaveBeenModified ($ connection ));
224
+ }
189
225
}
0 commit comments