@@ -97,6 +97,14 @@ public function testDefaultEagerConstraintsWhenIncrementing()
97
97
$ relation ->addEagerConstraints ($ models );
98
98
}
99
99
100
+ public function testDefaultEagerConstraintsWhenIncrementingAndNonIntKeyType ()
101
+ {
102
+ $ relation = $ this ->getRelation (null , false , 'string ' );
103
+ $ relation ->getQuery ()->shouldReceive ('whereIn ' )->once ()->with ('relation.id ' , m::mustBe ([null ]));
104
+ $ models = [new MissingEloquentBelongsToModelStub , new MissingEloquentBelongsToModelStub ];
105
+ $ relation ->addEagerConstraints ($ models );
106
+ }
107
+
100
108
public function testDefaultEagerConstraintsWhenNotIncrementing ()
101
109
{
102
110
$ relation = $ this ->getRelation (null , false );
@@ -105,12 +113,13 @@ public function testDefaultEagerConstraintsWhenNotIncrementing()
105
113
$ relation ->addEagerConstraints ($ models );
106
114
}
107
115
108
- protected function getRelation ($ parent = null , $ incrementing = true )
116
+ protected function getRelation ($ parent = null , $ incrementing = true , $ keyType = ' int ' )
109
117
{
110
118
$ builder = m::mock ('Illuminate\Database\Eloquent\Builder ' );
111
119
$ builder ->shouldReceive ('where ' )->with ('relation.id ' , '= ' , 'foreign.value ' );
112
120
$ related = m::mock ('Illuminate\Database\Eloquent\Model ' );
113
121
$ related ->incrementing = $ incrementing ;
122
+ $ related ->shouldReceive ('getKeyType ' )->andReturn ($ keyType );
114
123
$ related ->shouldReceive ('getIncrementing ' )->andReturn ($ incrementing );
115
124
$ related ->shouldReceive ('getKeyName ' )->andReturn ('id ' );
116
125
$ related ->shouldReceive ('getTable ' )->andReturn ('relation ' );
0 commit comments