diff --git a/src/Way/Tests/ModelHelpers.php b/src/Way/Tests/ModelHelpers.php index cf3bb64..7269592 100644 --- a/src/Way/Tests/ModelHelpers.php +++ b/src/Way/Tests/ModelHelpers.php @@ -55,11 +55,42 @@ public function assertRelationship($relationship, $class, $type) { $this->assertRespondsTo($relationship, $class); + $mocked = Mockery::mock($class."[$type]"); + + $mocked->shouldReceive($type) + ->once() + ->andReturnUsing(function () + { + return func_get_args(); + }); + + $args = $mocked->$relationship(); + $class = Mockery::mock($class."[$type]"); - $class->shouldReceive($type) - ->with('/' . str_singular($relationship) . '/i') - ->once(); + switch(count($args)) + { + case 1 : + $class->shouldReceive($type) + ->once() + ->with('/' . str_singular($relationship) . '/i'); + break; + case 2 : + $class->shouldReceive($type) + ->once() + ->with('/' . str_singular($relationship) . '/i', $args[1]); + break; + case 3 : + $class->shouldReceive($type) + ->once() + ->with('/' . str_singular($relationship) . '/i', $args[1], $args[2]); + break; + case 4 : + $class->shouldReceive($type) + ->once() + ->with('/' . str_singular($relationship) . '/i', $args[1], $args[2], $args[3]); + break; + } $class->$relationship(); }