Skip to content

Commit ccb1e3d

Browse files
kubawerlossebastianbergmann
authored andcommitted
Add test showing current behaviour when test depends on test with data provider
1 parent 8bb0e8b commit ccb1e3d

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/issues/6222
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = '--display-skipped';
8+
$_SERVER['argv'][] = __DIR__ . '/6222/Issue6222Test.php';
9+
10+
require_once __DIR__ . '/../../bootstrap.php';
11+
12+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
13+
--EXPECTF--
14+
PHPUnit %s by Sebastian Bergmann and contributors.
15+
16+
Runtime: %s
17+
18+
F..S.FSFFS 10 / 10 (100%)
19+
20+
Time: %s, Memory: %s
21+
22+
There were 4 failures:
23+
24+
1) PHPUnit\TestFixture\Issue6222\Issue6222Test::testOne
25+
Failed asserting that false is true.
26+
27+
%sIssue6222Test.php:%d
28+
29+
2) PHPUnit\TestFixture\Issue6222\Issue6222Test::testOneCasePassing with data set #1 (2)
30+
Failed asserting that 2 is identical to 1.
31+
32+
%sIssue6222Test.php:%d
33+
34+
3) PHPUnit\TestFixture\Issue6222\Issue6222Test::testZeroCasesPassing with data set #0 (1)
35+
Failed asserting that 1 is identical to 3.
36+
37+
%sIssue6222Test.php:%d
38+
39+
4) PHPUnit\TestFixture\Issue6222\Issue6222Test::testZeroCasesPassing with data set #1 (2)
40+
Failed asserting that 2 is identical to 3.
41+
42+
%sIssue6222Test.php:%d
43+
44+
--
45+
46+
There were 3 skipped tests:
47+
48+
1) PHPUnit\TestFixture\Issue6222\Issue6222Test::testDependingOnTwoCasesPassing
49+
This test depends on "PHPUnit\TestFixture\Issue6222\Issue6222Test::testTwoCasesPassing" to pass
50+
51+
2) PHPUnit\TestFixture\Issue6222\Issue6222Test::testDependingOnOneCasePassing
52+
This test depends on "PHPUnit\TestFixture\Issue6222\Issue6222Test::testOneCasePassing" to pass
53+
54+
3) PHPUnit\TestFixture\Issue6222\Issue6222Test::testDependingOnZeroCasesPassing
55+
This test depends on "PHPUnit\TestFixture\Issue6222\Issue6222Test::testZeroCasesPassing" to pass
56+
57+
FAILURES!
58+
Tests: 10, Assertions: 7, Failures: 4, Skipped: 3.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/*
5+
* This file is part of PHPUnit.
6+
*
7+
* (c) Sebastian Bergmann <[email protected]>
8+
*
9+
* For the full copyright and license information, please view the LICENSE
10+
* file that was distributed with this source code.
11+
*/
12+
namespace PHPUnit\TestFixture\Issue6222;
13+
14+
use PHPUnit\Framework\Attributes\DataProvider;
15+
use PHPUnit\Framework\Attributes\Depends;
16+
use PHPUnit\Framework\TestCase;
17+
18+
class Issue6222Test extends TestCase
19+
{
20+
public static function provider(): iterable
21+
{
22+
yield [1];
23+
24+
yield [2];
25+
}
26+
27+
public function testOne(): void
28+
{
29+
$this->assertTrue(false);
30+
}
31+
32+
#[DataProvider('provider')]
33+
public function testTwoCasesPassing(int $x): void
34+
{
35+
$this->assertGreaterThan(0, $x);
36+
}
37+
38+
#[Depends('testTwoCasesPassing')]
39+
public function testDependingOnTwoCasesPassing(): void
40+
{
41+
$this->assertTrue(true);
42+
}
43+
44+
#[DataProvider('provider')]
45+
public function testOneCasePassing(int $x): void
46+
{
47+
$this->assertSame(1, $x);
48+
}
49+
50+
#[Depends('testOneCasePassing')]
51+
public function testDependingOnOneCasePassing(): void
52+
{
53+
$this->assertTrue(true);
54+
}
55+
56+
#[DataProvider('provider')]
57+
public function testZeroCasesPassing(int $x): void
58+
{
59+
$this->assertSame(3, $x);
60+
}
61+
62+
#[Depends('testZeroCasesPassing')]
63+
public function testDependingOnZeroCasesPassing(): void
64+
{
65+
$this->assertTrue(true);
66+
}
67+
}

0 commit comments

Comments
 (0)