Skip to content

Commit 83320d3

Browse files
staabmsebastianbergmann
authored andcommitted
Cover #[DataProviderExternal] variant in a test
1 parent 202d7d2 commit 83320d3

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php declare(strict_types=1);
2+
3+
/*
4+
* This file is part of PHPUnit.
5+
*
6+
* (c) Sebastian Bergmann <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
namespace PHPUnit\TestFixture;
12+
13+
use PHPUnit\Framework\Attributes\DataProviderExternal;
14+
use PHPUnit\Framework\Attributes\TestWith;
15+
use PHPUnit\Framework\TestCase;
16+
17+
final class TestWithAttributeAndExternalDataProviderTest extends TestCase
18+
{
19+
public static function provider(): iterable
20+
{
21+
yield 'foo' => ['bar', 'baz'];
22+
}
23+
24+
#[TestWith(['a', 'b'], 'foo')]
25+
#[DataProviderExternal(self::class, 'provider')]
26+
public function testWithDifferentProviderTypes($one, $two): void
27+
{
28+
$this->assertTrue(true);
29+
}
30+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
phpunit ../_files/TestWithAttributeAndDataProviderTest.php
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = __DIR__ . '/../_files/TestWithAttributeAndExternalDataProviderTest.php';
8+
9+
require __DIR__ . '/../../bootstrap.php';
10+
11+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
12+
--EXPECTF--
13+
PHPUnit %s by Sebastian Bergmann and contributors.
14+
15+
Runtime: %s
16+
17+
W 1 / 1 (100%)
18+
19+
Time: %s, Memory: %s
20+
21+
1 test triggered 1 PHPUnit warning:
22+
23+
1) PHPUnit\TestFixture\TestWithAttributeAndExternalDataProviderTest::testWithDifferentProviderTypes
24+
Mixing #[DataProvider*] and #[TestWith*] attributes is not supported, only the data provided by #[DataProvider*] will be used
25+
26+
%sTestWithAttributeAndExternalDataProviderTest.php:%d
27+
28+
OK, but there were issues!
29+
Tests: 1, Assertions: 1, PHPUnit Warnings: 1.

0 commit comments

Comments
 (0)