Skip to content

Commit 10a92a9

Browse files
kubawerlossebastianbergmann
authored andcommitted
Add test to show the problem
1 parent 0143f26 commit 10a92a9

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/issues/5891
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = __DIR__ . '/5891/Issue5891Test.php';
8+
9+
require_once __DIR__ . '/../../bootstrap.php';
10+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
11+
--EXPECTF--
12+
PHPUnit %s by Sebastian Bergmann and contributors.
13+
14+
Runtime: %s
15+
16+
.. 2 / 2 (100%)
17+
18+
Time: %s, Memory: %s MB
19+
20+
OK (2 tests, 3 assertions)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\TestFixture\Issue5891;
11+
12+
use PHPUnit\Framework\TestCase;
13+
14+
final class Issue5891Test extends TestCase
15+
{
16+
public function testVariadicParam(): void
17+
{
18+
$variadicParam = $this->createMock(VariadicParam::class);
19+
$variadicParam
20+
->method('foo')
21+
->with($this->callback(static function (...$items): bool
22+
{
23+
self::assertSame([1], $items); // should be "self::assertSame([1, 2, 3], $items);"
24+
25+
return true;
26+
}));
27+
28+
$variadicParam->foo(1, 2, 3);
29+
}
30+
31+
public function testTwoParametersAndVariadicParam(): void
32+
{
33+
$twoParametersAndVariadicParam = $this->createMock(TwoParametersAndVariadicParam::class);
34+
$twoParametersAndVariadicParam
35+
->method('foo')
36+
->with($this->callback(static function ($head, ...$tail): bool
37+
{
38+
self::assertSame('1st', $head);
39+
self::assertSame([], $tail); // should be "self::assertSame(['2nd', '3rd', '4th'], $tail);"
40+
41+
return true;
42+
}));
43+
44+
$twoParametersAndVariadicParam->foo('1st', '2nd', '3rd', '4th');
45+
}
46+
}
47+
48+
interface VariadicParam
49+
{
50+
public function foo(int ...$items): void;
51+
}
52+
interface TwoParametersAndVariadicParam
53+
{
54+
public function foo(string $first, string $second, string ...$rest): void;
55+
}

0 commit comments

Comments
 (0)