2
2
3
3
class EmbeddedRelationsTest extends TestCase
4
4
{
5
- public function tearDown ()
5
+ public function tearDown (): void
6
6
{
7
7
Mockery::close ();
8
8
@@ -21,11 +21,11 @@ public function testEmbedsManySave()
21
21
$ address = new Address (['city ' => 'London ' ]);
22
22
23
23
$ address ->setEventDispatcher ($ events = Mockery::mock ('Illuminate\Events\Dispatcher ' ));
24
- $ events ->shouldReceive ('fire ' )->with ('eloquent.retrieved: ' . get_class ($ address ), Mockery::any ());
24
+ $ events ->shouldReceive ('dispatch ' )->with ('eloquent.retrieved: ' . get_class ($ address ), Mockery::any ());
25
25
$ events ->shouldReceive ('until ' )->once ()->with ('eloquent.saving: ' . get_class ($ address ), $ address )->andReturn (true );
26
26
$ events ->shouldReceive ('until ' )->once ()->with ('eloquent.creating: ' . get_class ($ address ), $ address )->andReturn (true );
27
- $ events ->shouldReceive ('fire ' )->once ()->with ('eloquent.created: ' . get_class ($ address ), $ address );
28
- $ events ->shouldReceive ('fire ' )->once ()->with ('eloquent.saved: ' . get_class ($ address ), $ address );
27
+ $ events ->shouldReceive ('dispatch ' )->once ()->with ('eloquent.created: ' . get_class ($ address ), $ address );
28
+ $ events ->shouldReceive ('dispatch ' )->once ()->with ('eloquent.saved: ' . get_class ($ address ), $ address );
29
29
30
30
$ address = $ user ->addresses ()->save ($ address );
31
31
$ address ->unsetEventDispatcher ();
@@ -47,11 +47,11 @@ public function testEmbedsManySave()
47
47
$ this ->assertEquals (['London ' , 'Paris ' ], $ user ->addresses ->pluck ('city ' )->all ());
48
48
49
49
$ address ->setEventDispatcher ($ events = Mockery::mock ('Illuminate\Events\Dispatcher ' ));
50
- $ events ->shouldReceive ('fire ' )->with ('eloquent.retrieved: ' . get_class ($ address ), Mockery::any ());
50
+ $ events ->shouldReceive ('dispatch ' )->with ('eloquent.retrieved: ' . get_class ($ address ), Mockery::any ());
51
51
$ events ->shouldReceive ('until ' )->once ()->with ('eloquent.saving: ' . get_class ($ address ), $ address )->andReturn (true );
52
52
$ events ->shouldReceive ('until ' )->once ()->with ('eloquent.updating: ' . get_class ($ address ), $ address )->andReturn (true );
53
- $ events ->shouldReceive ('fire ' )->once ()->with ('eloquent.updated: ' . get_class ($ address ), $ address );
54
- $ events ->shouldReceive ('fire ' )->once ()->with ('eloquent.saved: ' . get_class ($ address ), $ address );
53
+ $ events ->shouldReceive ('dispatch ' )->once ()->with ('eloquent.updated: ' . get_class ($ address ), $ address );
54
+ $ events ->shouldReceive ('dispatch ' )->once ()->with ('eloquent.saved: ' . get_class ($ address ), $ address );
55
55
56
56
$ address ->city = 'New York ' ;
57
57
$ user ->addresses ()->save ($ address );
@@ -94,16 +94,16 @@ public function testEmbedsManySave()
94
94
// $address->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
95
95
// $events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($address), $address)->andReturn(true);
96
96
// $events->shouldReceive('until')->once()->with('eloquent.creating: ' . get_class($address), $address)->andReturn(true);
97
- // $events->shouldReceive('fire ')->once()->with('eloquent.created: ' . get_class($address), $address);
98
- // $events->shouldReceive('fire ')->once()->with('eloquent.saved: ' . get_class($address), $address);
97
+ // $events->shouldReceive('dispatch ')->once()->with('eloquent.created: ' . get_class($address), $address);
98
+ // $events->shouldReceive('dispatch ')->once()->with('eloquent.saved: ' . get_class($address), $address);
99
99
100
100
// $address->save();
101
101
102
102
// $address->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
103
103
// $events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($address), $address)->andReturn(true);
104
104
// $events->shouldReceive('until')->once()->with('eloquent.updating: ' . get_class($address), $address)->andReturn(true);
105
- // $events->shouldReceive('fire ')->once()->with('eloquent.updated: ' . get_class($address), $address);
106
- // $events->shouldReceive('fire ')->once()->with('eloquent.saved: ' . get_class($address), $address);
105
+ // $events->shouldReceive('dispatch ')->once()->with('eloquent.updated: ' . get_class($address), $address);
106
+ // $events->shouldReceive('dispatch ')->once()->with('eloquent.saved: ' . get_class($address), $address);
107
107
108
108
// $address->city = 'Paris';
109
109
// $address->save();
@@ -213,9 +213,9 @@ public function testEmbedsManyDestroy()
213
213
$ address = $ user ->addresses ->first ();
214
214
215
215
$ address ->setEventDispatcher ($ events = Mockery::mock ('Illuminate\Events\Dispatcher ' ));
216
- $ events ->shouldReceive ('fire ' )->with ('eloquent.retrieved: ' . get_class ($ address ), Mockery::any ());
216
+ $ events ->shouldReceive ('dispatch ' )->with ('eloquent.retrieved: ' . get_class ($ address ), Mockery::any ());
217
217
$ events ->shouldReceive ('until ' )->once ()->with ('eloquent.deleting: ' . get_class ($ address ), Mockery::type ('Address ' ))->andReturn (true );
218
- $ events ->shouldReceive ('fire ' )->once ()->with ('eloquent.deleted: ' . get_class ($ address ), Mockery::type ('Address ' ));
218
+ $ events ->shouldReceive ('dispatch ' )->once ()->with ('eloquent.deleted: ' . get_class ($ address ), Mockery::type ('Address ' ));
219
219
220
220
$ user ->addresses ()->destroy ($ address ->_id );
221
221
$ this ->assertEquals (['Bristol ' , 'Bruxelles ' ], $ user ->addresses ->pluck ('city ' )->all ());
@@ -252,9 +252,9 @@ public function testEmbedsManyDelete()
252
252
$ address = $ user ->addresses ->first ();
253
253
254
254
$ address ->setEventDispatcher ($ events = Mockery::mock ('Illuminate\Events\Dispatcher ' ));
255
- $ events ->shouldReceive ('fire ' )->with ('eloquent.retrieved: ' . get_class ($ address ), Mockery::any ());
255
+ $ events ->shouldReceive ('dispatch ' )->with ('eloquent.retrieved: ' . get_class ($ address ), Mockery::any ());
256
256
$ events ->shouldReceive ('until ' )->once ()->with ('eloquent.deleting: ' . get_class ($ address ), Mockery::type ('Address ' ))->andReturn (true );
257
- $ events ->shouldReceive ('fire ' )->once ()->with ('eloquent.deleted: ' . get_class ($ address ), Mockery::type ('Address ' ));
257
+ $ events ->shouldReceive ('dispatch ' )->once ()->with ('eloquent.deleted: ' . get_class ($ address ), Mockery::type ('Address ' ));
258
258
259
259
$ address ->delete ();
260
260
@@ -301,7 +301,7 @@ public function testEmbedsManyCreatingEventReturnsFalse()
301
301
$ address = new Address (['city ' => 'London ' ]);
302
302
303
303
$ address ->setEventDispatcher ($ events = Mockery::mock ('Illuminate\Events\Dispatcher ' ));
304
- $ events ->shouldReceive ('fire ' )->with ('eloquent.retrieved: ' . get_class ($ address ), Mockery::any ());
304
+ $ events ->shouldReceive ('dispatch ' )->with ('eloquent.retrieved: ' . get_class ($ address ), Mockery::any ());
305
305
$ events ->shouldReceive ('until ' )->once ()->with ('eloquent.saving: ' . get_class ($ address ), $ address )->andReturn (true );
306
306
$ events ->shouldReceive ('until ' )->once ()->with ('eloquent.creating: ' . get_class ($ address ), $ address )->andReturn (false );
307
307
@@ -316,7 +316,7 @@ public function testEmbedsManySavingEventReturnsFalse()
316
316
$ address ->exists = true ;
317
317
318
318
$ address ->setEventDispatcher ($ events = Mockery::mock ('Illuminate\Events\Dispatcher ' ));
319
- $ events ->shouldReceive ('fire ' )->with ('eloquent.retrieved: ' . get_class ($ address ), Mockery::any ());
319
+ $ events ->shouldReceive ('dispatch ' )->with ('eloquent.retrieved: ' . get_class ($ address ), Mockery::any ());
320
320
$ events ->shouldReceive ('until ' )->once ()->with ('eloquent.saving: ' . get_class ($ address ), $ address )->andReturn (false );
321
321
322
322
$ this ->assertFalse ($ user ->addresses ()->save ($ address ));
@@ -330,7 +330,7 @@ public function testEmbedsManyUpdatingEventReturnsFalse()
330
330
$ user ->addresses ()->save ($ address );
331
331
332
332
$ address ->setEventDispatcher ($ events = Mockery::mock ('Illuminate\Events\Dispatcher ' ));
333
- $ events ->shouldReceive ('fire ' )->with ('eloquent.retrieved: ' . get_class ($ address ), Mockery::any ());
333
+ $ events ->shouldReceive ('dispatch ' )->with ('eloquent.retrieved: ' . get_class ($ address ), Mockery::any ());
334
334
$ events ->shouldReceive ('until ' )->once ()->with ('eloquent.saving: ' . get_class ($ address ), $ address )->andReturn (true );
335
335
$ events ->shouldReceive ('until ' )->once ()->with ('eloquent.updating: ' . get_class ($ address ), $ address )->andReturn (false );
336
336
@@ -348,7 +348,7 @@ public function testEmbedsManyDeletingEventReturnsFalse()
348
348
$ address = $ user ->addresses ->first ();
349
349
350
350
$ address ->setEventDispatcher ($ events = Mockery::mock ('Illuminate\Events\Dispatcher ' ));
351
- $ events ->shouldReceive ('fire ' )->with ('eloquent.retrieved: ' . get_class ($ address ), Mockery::any ());
351
+ $ events ->shouldReceive ('dispatch ' )->with ('eloquent.retrieved: ' . get_class ($ address ), Mockery::any ());
352
352
$ events ->shouldReceive ('until ' )->once ()->with ('eloquent.deleting: ' . get_class ($ address ), Mockery::mustBe ($ address ))->andReturn (false );
353
353
354
354
$ this ->assertEquals (0 , $ user ->addresses ()->destroy ($ address ));
@@ -452,11 +452,11 @@ public function testEmbedsOne()
452
452
$ father = new User (['name ' => 'Mark Doe ' ]);
453
453
454
454
$ father ->setEventDispatcher ($ events = Mockery::mock ('Illuminate\Events\Dispatcher ' ));
455
- $ events ->shouldReceive ('fire ' )->with ('eloquent.retrieved: ' . get_class ($ father ), Mockery::any ());
455
+ $ events ->shouldReceive ('dispatch ' )->with ('eloquent.retrieved: ' . get_class ($ father ), Mockery::any ());
456
456
$ events ->shouldReceive ('until ' )->once ()->with ('eloquent.saving: ' . get_class ($ father ), $ father )->andReturn (true );
457
457
$ events ->shouldReceive ('until ' )->once ()->with ('eloquent.creating: ' . get_class ($ father ), $ father )->andReturn (true );
458
- $ events ->shouldReceive ('fire ' )->once ()->with ('eloquent.created: ' . get_class ($ father ), $ father );
459
- $ events ->shouldReceive ('fire ' )->once ()->with ('eloquent.saved: ' . get_class ($ father ), $ father );
458
+ $ events ->shouldReceive ('dispatch ' )->once ()->with ('eloquent.created: ' . get_class ($ father ), $ father );
459
+ $ events ->shouldReceive ('dispatch ' )->once ()->with ('eloquent.saved: ' . get_class ($ father ), $ father );
460
460
461
461
$ father = $ user ->father ()->save ($ father );
462
462
$ father ->unsetEventDispatcher ();
@@ -472,11 +472,11 @@ public function testEmbedsOne()
472
472
$ this ->assertInstanceOf ('MongoDB\BSON\ObjectID ' , $ raw ['_id ' ]);
473
473
474
474
$ father ->setEventDispatcher ($ events = Mockery::mock ('Illuminate\Events\Dispatcher ' ));
475
- $ events ->shouldReceive ('fire ' )->with ('eloquent.retrieved: ' . get_class ($ father ), Mockery::any ());
475
+ $ events ->shouldReceive ('dispatch ' )->with ('eloquent.retrieved: ' . get_class ($ father ), Mockery::any ());
476
476
$ events ->shouldReceive ('until ' )->once ()->with ('eloquent.saving: ' . get_class ($ father ), $ father )->andReturn (true );
477
477
$ events ->shouldReceive ('until ' )->once ()->with ('eloquent.updating: ' . get_class ($ father ), $ father )->andReturn (true );
478
- $ events ->shouldReceive ('fire ' )->once ()->with ('eloquent.updated: ' . get_class ($ father ), $ father );
479
- $ events ->shouldReceive ('fire ' )->once ()->with ('eloquent.saved: ' . get_class ($ father ), $ father );
478
+ $ events ->shouldReceive ('dispatch ' )->once ()->with ('eloquent.updated: ' . get_class ($ father ), $ father );
479
+ $ events ->shouldReceive ('dispatch ' )->once ()->with ('eloquent.saved: ' . get_class ($ father ), $ father );
480
480
481
481
$ father ->name = 'Tom Doe ' ;
482
482
$ user ->father ()->save ($ father );
@@ -488,11 +488,11 @@ public function testEmbedsOne()
488
488
$ father = new User (['name ' => 'Jim Doe ' ]);
489
489
490
490
$ father ->setEventDispatcher ($ events = Mockery::mock ('Illuminate\Events\Dispatcher ' ));
491
- $ events ->shouldReceive ('fire ' )->with ('eloquent.retrieved: ' . get_class ($ father ), Mockery::any ());
491
+ $ events ->shouldReceive ('dispatch ' )->with ('eloquent.retrieved: ' . get_class ($ father ), Mockery::any ());
492
492
$ events ->shouldReceive ('until ' )->once ()->with ('eloquent.saving: ' . get_class ($ father ), $ father )->andReturn (true );
493
493
$ events ->shouldReceive ('until ' )->once ()->with ('eloquent.creating: ' . get_class ($ father ), $ father )->andReturn (true );
494
- $ events ->shouldReceive ('fire ' )->once ()->with ('eloquent.created: ' . get_class ($ father ), $ father );
495
- $ events ->shouldReceive ('fire ' )->once ()->with ('eloquent.saved: ' . get_class ($ father ), $ father );
494
+ $ events ->shouldReceive ('dispatch ' )->once ()->with ('eloquent.created: ' . get_class ($ father ), $ father );
495
+ $ events ->shouldReceive ('dispatch ' )->once ()->with ('eloquent.saved: ' . get_class ($ father ), $ father );
496
496
497
497
$ father = $ user ->father ()->save ($ father );
498
498
$ father ->unsetEventDispatcher ();
@@ -507,7 +507,7 @@ public function testEmbedsOneAssociate()
507
507
$ father = new User (['name ' => 'Mark Doe ' ]);
508
508
509
509
$ father ->setEventDispatcher ($ events = Mockery::mock ('Illuminate\Events\Dispatcher ' ));
510
- $ events ->shouldReceive ('fire ' )->with ('eloquent.retrieved: ' . get_class ($ father ), Mockery::any ());
510
+ $ events ->shouldReceive ('dispatch ' )->with ('eloquent.retrieved: ' . get_class ($ father ), Mockery::any ());
511
511
$ events ->shouldReceive ('until ' )->times (0 )->with ('eloquent.saving: ' . get_class ($ father ), $ father );
512
512
513
513
$ father = $ user ->father ()->associate ($ father );
0 commit comments