Skip to content

Commit 58b3dc8

Browse files
committed
Increase test coverage to 100%
1 parent aa5962d commit 58b3dc8

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

src/JsonMapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ protected function isArrayOfType($strType)
822822

823823
/**
824824
* Returns true if accessor is a method and has only one parameter
825-
* which is variadic.
825+
* which is variadic ("...$args").
826826
*
827827
* @param ReflectionMethod|ReflectionProperty|null $accessor accessor
828828
* to set value

tests/ArrayTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,20 @@ public function testMapArrayFromVariadicFunctionWithObjectType()
527527
$this->assertSame('2014-01-02', $variadicArray[0]->format('Y-m-d'));
528528
$this->assertSame('2014-05-07', $variadicArray[1]->format('Y-m-d'));
529529
}
530+
531+
/**
532+
* Test the "if (count($parameters) !== 1) {" condition in "hasVariadicArrayType()"
533+
*/
534+
public function testMapArrayVariadicMethodWithMultipleParams()
535+
{
536+
$jm = new JsonMapper();
537+
$sn = $jm->map(
538+
json_decode('{"multipleParams":[23]}'),
539+
new JsonMapperTest_VariadicArray()
540+
);
541+
542+
$this->assertSame([23], $sn->multipleParamsVal);
543+
}
530544
}
531545

532546
?>

tests/support/JsonMapperTest/VariadicArray.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class JsonMapperTest_VariadicArray
3030
*/
3131
private $variadicInt;
3232

33+
public $multipleParamsVal;
34+
3335
/**
3436
* @param DateTime[] $items
3537
*
@@ -69,5 +71,10 @@ public function setVariadicInt(int ...$items): self
6971

7072
return $this;
7173
}
74+
75+
public function setMultipleParams(array $param, int ...$dummy)
76+
{
77+
$this->multipleParamsVal = $param;
78+
}
7279
}
7380
?>

0 commit comments

Comments
 (0)