Skip to content

Commit db98372

Browse files
committed
Fix some test issues
1 parent 60c5329 commit db98372

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
lines changed

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"require-dev": {
2121
"phpunit/phpunit": "^6.0",
2222
"orchestra/testbench": "^3.1",
23-
"mockery/mockery": "^0.9",
24-
"satooshi/php-coveralls": "^1.0",
23+
"mockery/mockery": "^1.0",
24+
"satooshi/php-coveralls": "^2.0",
2525
"doctrine/dbal": "^2.5"
2626
},
2727
"autoload": {

docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99
volumes:
1010
- .:/code
1111
working_dir: /code
12-
command: php ./vendor/bin/phpunit
12+
command: docker/entrypoint.sh
1313
depends_on:
1414
- mysql
1515
- mongodb

docker/entrypoint.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
sleep 3 && php ./vendor/bin/phpunit

src/Jenssegers/Mongodb/Query/Builder.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public function hint($index)
198198
*/
199199
public function find($id, $columns = [])
200200
{
201-
return $this->where($this->getKeyName(), '=', $this->convertKey($id))->first($columns);
201+
return $this->where('_id', '=', $this->convertKey($id))->first($columns);
202202
}
203203

204204
/**

tests/EmbeddedRelationsTest.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function testEmbedsManySave()
2121
$address = new Address(['city' => 'London']);
2222

2323
$address->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
24-
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), anything());
24+
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
2525
$events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($address), $address)->andReturn(true);
2626
$events->shouldReceive('until')->once()->with('eloquent.creating: ' . get_class($address), $address)->andReturn(true);
2727
$events->shouldReceive('fire')->once()->with('eloquent.created: ' . get_class($address), $address);
@@ -47,7 +47,7 @@ public function testEmbedsManySave()
4747
$this->assertEquals(['London', 'Paris'], $user->addresses->pluck('city')->all());
4848

4949
$address->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
50-
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), anything());
50+
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
5151
$events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($address), $address)->andReturn(true);
5252
$events->shouldReceive('until')->once()->with('eloquent.updating: ' . get_class($address), $address)->andReturn(true);
5353
$events->shouldReceive('fire')->once()->with('eloquent.updated: ' . get_class($address), $address);
@@ -213,7 +213,7 @@ public function testEmbedsManyDestroy()
213213
$address = $user->addresses->first();
214214

215215
$address->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
216-
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), anything());
216+
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
217217
$events->shouldReceive('until')->once()->with('eloquent.deleting: ' . get_class($address), Mockery::type('Address'))->andReturn(true);
218218
$events->shouldReceive('fire')->once()->with('eloquent.deleted: ' . get_class($address), Mockery::type('Address'));
219219

@@ -252,7 +252,7 @@ public function testEmbedsManyDelete()
252252
$address = $user->addresses->first();
253253

254254
$address->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
255-
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), anything());
255+
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
256256
$events->shouldReceive('until')->once()->with('eloquent.deleting: ' . get_class($address), Mockery::type('Address'))->andReturn(true);
257257
$events->shouldReceive('fire')->once()->with('eloquent.deleted: ' . get_class($address), Mockery::type('Address'));
258258

@@ -301,7 +301,7 @@ public function testEmbedsManyCreatingEventReturnsFalse()
301301
$address = new Address(['city' => 'London']);
302302

303303
$address->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
304-
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), anything());
304+
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
305305
$events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($address), $address)->andReturn(true);
306306
$events->shouldReceive('until')->once()->with('eloquent.creating: ' . get_class($address), $address)->andReturn(false);
307307

@@ -316,7 +316,7 @@ public function testEmbedsManySavingEventReturnsFalse()
316316
$address->exists = true;
317317

318318
$address->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
319-
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), anything());
319+
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
320320
$events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($address), $address)->andReturn(false);
321321

322322
$this->assertFalse($user->addresses()->save($address));
@@ -330,7 +330,7 @@ public function testEmbedsManyUpdatingEventReturnsFalse()
330330
$user->addresses()->save($address);
331331

332332
$address->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
333-
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), anything());
333+
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
334334
$events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($address), $address)->andReturn(true);
335335
$events->shouldReceive('until')->once()->with('eloquent.updating: ' . get_class($address), $address)->andReturn(false);
336336

@@ -348,7 +348,7 @@ public function testEmbedsManyDeletingEventReturnsFalse()
348348
$address = $user->addresses->first();
349349

350350
$address->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
351-
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), anything());
351+
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($address), Mockery::any());
352352
$events->shouldReceive('until')->once()->with('eloquent.deleting: ' . get_class($address), Mockery::mustBe($address))->andReturn(false);
353353

354354
$this->assertEquals(0, $user->addresses()->destroy($address));
@@ -452,7 +452,7 @@ public function testEmbedsOne()
452452
$father = new User(['name' => 'Mark Doe']);
453453

454454
$father->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
455-
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($father), anything());
455+
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($father), Mockery::any());
456456
$events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($father), $father)->andReturn(true);
457457
$events->shouldReceive('until')->once()->with('eloquent.creating: ' . get_class($father), $father)->andReturn(true);
458458
$events->shouldReceive('fire')->once()->with('eloquent.created: ' . get_class($father), $father);
@@ -472,7 +472,7 @@ public function testEmbedsOne()
472472
$this->assertInstanceOf('MongoDB\BSON\ObjectID', $raw['_id']);
473473

474474
$father->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
475-
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($father), anything());
475+
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($father), Mockery::any());
476476
$events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($father), $father)->andReturn(true);
477477
$events->shouldReceive('until')->once()->with('eloquent.updating: ' . get_class($father), $father)->andReturn(true);
478478
$events->shouldReceive('fire')->once()->with('eloquent.updated: ' . get_class($father), $father);
@@ -488,7 +488,7 @@ public function testEmbedsOne()
488488
$father = new User(['name' => 'Jim Doe']);
489489

490490
$father->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
491-
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($father), anything());
491+
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($father), Mockery::any());
492492
$events->shouldReceive('until')->once()->with('eloquent.saving: ' . get_class($father), $father)->andReturn(true);
493493
$events->shouldReceive('until')->once()->with('eloquent.creating: ' . get_class($father), $father)->andReturn(true);
494494
$events->shouldReceive('fire')->once()->with('eloquent.created: ' . get_class($father), $father);
@@ -507,7 +507,7 @@ public function testEmbedsOneAssociate()
507507
$father = new User(['name' => 'Mark Doe']);
508508

509509
$father->setEventDispatcher($events = Mockery::mock('Illuminate\Events\Dispatcher'));
510-
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($father), anything());
510+
$events->shouldReceive('fire')->with('eloquent.retrieved: ' . get_class($father), Mockery::any());
511511
$events->shouldReceive('until')->times(0)->with('eloquent.saving: ' . get_class($father), $father);
512512

513513
$father = $user->father()->associate($father);

0 commit comments

Comments
 (0)