Skip to content

Commit 3f76feb

Browse files
committed
Fix test failed in new PhpUnit (#2)
1 parent 76c4e45 commit 3f76feb

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

.github/workflows/phpunit.yml

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ jobs:
1919
- 7.3
2020
- 7.4
2121
- 8.0
22+
- 8.1
23+
- 8.2
24+
- 8.3
2225

2326
env:
2427
EXECUTE_COVERAGE: ${{ matrix.php-version == '8.0' }}

tests/TestCase.php

+6
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@
44

55
class TestCase extends \Orchestra\Testbench\TestCase
66
{
7+
// The TestCase::__construct in the new PHPUnit versions requires first argument,
8+
// this workaround allows to instantiate test files in the tests.
9+
public function __construct($name = null)
10+
{
11+
parent::__construct($name ?? get_class($this));
12+
}
713
}

tests/Unit/CardTest.php

+5-6
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,16 @@
1010

1111
class CardTest extends TestCase
1212
{
13-
/** @test @dataProvider badStrings **/
14-
public function it_expects_card_number($input)
13+
public function it_expects_card_number()
1514
{
1615
$this->expectException(CreditCardException::class);
17-
18-
Factory::makeFromNumber($input);
16+
Factory::makeFromNumber(null);
1917
}
2018

21-
public function badStrings()
19+
public function it_expects_not_empty_card_number()
2220
{
23-
return ['empty string' => [''], 'null' => [null]];
21+
$this->expectException(CreditCardException::class);
22+
Factory::makeFromNumber('');
2423
}
2524

2625
/** @test **/

0 commit comments

Comments
 (0)