@@ -45,18 +45,35 @@ public function testContainsWithMultipleArguments()
45
45
public function testContainsIndicatesIfModelInArray ()
46
46
{
47
47
$ mockModel = m::mock ('Illuminate\Database\Eloquent\Model ' );
48
- $ mockModel ->shouldReceive ('getKey ' )->andReturn (1 );
48
+ $ mockModel ->shouldReceive ('is ' )->with ($ mockModel )->andReturn (true );
49
+ $ mockModel ->shouldReceive ('is ' )->andReturn (false );
49
50
$ mockModel2 = m::mock ('Illuminate\Database\Eloquent\Model ' );
50
- $ mockModel2 ->shouldReceive ('getKey ' )->andReturn (2 );
51
+ $ mockModel2 ->shouldReceive ('is ' )->with ($ mockModel2 )->andReturn (true );
52
+ $ mockModel2 ->shouldReceive ('is ' )->andReturn (false );
51
53
$ mockModel3 = m::mock ('Illuminate\Database\Eloquent\Model ' );
52
- $ mockModel3 ->shouldReceive ('getKey ' )->andReturn (3 );
54
+ $ mockModel3 ->shouldReceive ('is ' )->with ($ mockModel3 )->andReturn (true );
55
+ $ mockModel3 ->shouldReceive ('is ' )->andReturn (false );
53
56
$ c = new Collection ([$ mockModel , $ mockModel2 ]);
54
57
55
58
$ this ->assertTrue ($ c ->contains ($ mockModel ));
56
59
$ this ->assertTrue ($ c ->contains ($ mockModel2 ));
57
60
$ this ->assertFalse ($ c ->contains ($ mockModel3 ));
58
61
}
59
62
63
+ public function testContainsIndicatesIfDiffentModelInArray ()
64
+ {
65
+ $ mockModelFoo = m::namedMock ('Foo ' , 'Illuminate\Database\Eloquent\Model ' );
66
+ $ mockModelFoo ->shouldReceive ('is ' )->with ($ mockModelFoo )->andReturn (true );
67
+ $ mockModelFoo ->shouldReceive ('is ' )->andReturn (false );
68
+ $ mockModelBar = m::namedMock ('Bar ' , 'Illuminate\Database\Eloquent\Model ' );
69
+ $ mockModelBar ->shouldReceive ('is ' )->with ($ mockModelBar )->andReturn (true );
70
+ $ mockModelBar ->shouldReceive ('is ' )->andReturn (false );
71
+ $ c = new Collection ([$ mockModelFoo ]);
72
+
73
+ $ this ->assertTrue ($ c ->contains ($ mockModelFoo ));
74
+ $ this ->assertFalse ($ c ->contains ($ mockModelBar ));
75
+ }
76
+
60
77
public function testContainsIndicatesIfKeyedModelInArray ()
61
78
{
62
79
$ mockModel = m::mock ('Illuminate\Database\Eloquent\Model ' );
0 commit comments