11
11
12
12
use function sprintf ;
13
13
use PHPUnit \Framework \Attributes \CoversClass ;
14
+ use PHPUnit \Framework \Attributes \DataProvider ;
15
+ use PHPUnit \Framework \Attributes \Depends ;
14
16
use PHPUnit \Framework \Attributes \ExcludeGlobalVariableFromBackup ;
15
17
use PHPUnit \TestFixture \TestWithDifferentNames ;
16
18
@@ -21,6 +23,18 @@ class TestCaseTest extends TestCase
21
23
{
22
24
protected static int $ testStatic = 456 ;
23
25
26
+ /**
27
+ * @return array<non-empty-string, array<non-empty-string, string>>
28
+ */
29
+ public static function provider (): array
30
+ {
31
+ return [
32
+ 'case 1 ' => [
33
+ 'fromProvider ' => 'value from provider ' ,
34
+ ],
35
+ ];
36
+ }
37
+
24
38
public static function setUpBeforeClass (): void
25
39
{
26
40
$ GLOBALS ['a ' ] = 'a ' ;
@@ -83,4 +97,19 @@ public function testGetNameReturnsMethodName(): void
83
97
84
98
$ this ->assertSame ($ methodName , $ testCase ->nameWithDataSet ());
85
99
}
100
+
101
+ public function testDependedUponTest (): string
102
+ {
103
+ $ this ->assertTrue (true );
104
+
105
+ return 'value from depended-upon test ' ;
106
+ }
107
+
108
+ #[DataProvider('provider ' )]
109
+ #[Depends('testDependedUponTest ' )]
110
+ public function testTestDataFromProviderAndDependedUponTest (string $ fromProvider , string $ fromDependency ): void
111
+ {
112
+ $ this ->assertSame ('value from provider ' , $ fromProvider );
113
+ $ this ->assertSame ('value from depended-upon test ' , $ fromDependency );
114
+ }
86
115
}
0 commit comments