Package: php-slim-psr7 / 1.7.0-3

0005-Modernize-PHPUnit-syntax.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
From: =?utf-8?q?David_Pr=C3=A9vot?= <taffit@debian.org>
Date: Sun, 2 Mar 2025 20:24:26 +0100
Subject: Modernize PHPUnit syntax

---
 tests/Factory/ResponseFactoryTest.php |  4 ++--
 tests/HeadersTest.php                 |  9 +++------
 tests/UploadedFileTest.php            | 38 +++++++++++------------------------
 3 files changed, 17 insertions(+), 34 deletions(-)

diff --git a/tests/Factory/ResponseFactoryTest.php b/tests/Factory/ResponseFactoryTest.php
index 7dc557a..c76c29f 100644
--- a/tests/Factory/ResponseFactoryTest.php
+++ b/tests/Factory/ResponseFactoryTest.php
@@ -11,6 +11,7 @@ declare(strict_types=1);
 namespace Slim\Tests\Psr7\Factory;
 
 use Interop\Http\Factory\ResponseFactoryTestCase;
+use PHPUnit\Framework\Attributes\DataProvider;
 use Psr\Http\Message\ResponseInterface;
 use Slim\Psr7\Factory\ResponseFactory;
 
@@ -29,10 +30,9 @@ class ResponseFactoryTest extends ResponseFactoryTestCase
     }
 
     /**
-     * @dataProvider dataCodes
-     *
      * @param int $code
      */
+    #[DataProvider('dataCodes')]
     public function testCreateResponseWithReasonPhrase(int $code)
     {
         $response = $this->factory->createResponse($code, 'Reason');
diff --git a/tests/HeadersTest.php b/tests/HeadersTest.php
index 599ec15..254a401 100644
--- a/tests/HeadersTest.php
+++ b/tests/HeadersTest.php
@@ -11,6 +11,7 @@ declare(strict_types=1);
 namespace Slim\Tests\Psr7;
 
 use InvalidArgumentException;
+use PHPUnit\Framework\Attributes\DataProvider;
 use PHPUnit\Framework\TestCase;
 use Slim\Psr7\Headers;
 use stdClass;
@@ -211,9 +212,7 @@ class HeadersTest extends TestCase
         $this->assertEquals(['digest'], $headers->getHeader('Authorization'));
     }
 
-    /**
-     * @dataProvider provideInvalidHeaderNames
-     */
+    #[DataProvider('provideInvalidHeaderNames')]
     public function testWithInvalidHeaderName($headerName): void
     {
         $headers = new Headers();
@@ -240,9 +239,7 @@ class HeadersTest extends TestCase
         ];
     }
 
-    /**
-     * @dataProvider provideInvalidHeaderValues
-     */
+    #[DataProvider('provideInvalidHeaderValues')]
     public function testSetInvalidHeaderValue($headerValue)
     {
         $headers = new Headers();
diff --git a/tests/UploadedFileTest.php b/tests/UploadedFileTest.php
index b4ba569..8970ee5 100644
--- a/tests/UploadedFileTest.php
+++ b/tests/UploadedFileTest.php
@@ -11,6 +11,8 @@ declare(strict_types=1);
 namespace Slim\Tests\Psr7;
 
 use InvalidArgumentException;
+use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\Depends;
 use PHPUnit\Framework\TestCase;
 use Prophecy\PhpUnit\ProphecyTrait;
 use Psr\Http\Message\StreamInterface;
@@ -95,9 +97,8 @@ class UploadedFileTest extends TestCase
     /**
      * @param array $input    The input array to parse.
      * @param array $expected The expected normalized output.
-     *
-     * @dataProvider providerCreateFromGlobals
      */
+    #[DataProvider('providerCreateFromGlobals')]
     public function testCreateFromGlobalsFromFilesSuperglobal(array $input, array $expected)
     {
         $_FILES = $input;
@@ -108,9 +109,8 @@ class UploadedFileTest extends TestCase
 
     /**
      * @param array $input The input array to parse.
-     *
-     * @dataProvider providerCreateFromGlobals
      */
+    #[DataProvider('providerCreateFromGlobals')]
     public function testCreateFromGlobalsFromUserData(array $input)
     {
         //If slim.files provided - it will return what was provided
@@ -185,12 +185,11 @@ class UploadedFileTest extends TestCase
     }
 
     /**
-     * @depends testConstructor
-     *
      * @param UploadedFile $uploadedFile
      *
      * @return UploadedFile
      */
+    #[Depends('testConstructor')]
     public function testGetStream(UploadedFile $uploadedFile): UploadedFile
     {
         $stream = $uploadedFile->getStream();
@@ -201,11 +200,9 @@ class UploadedFileTest extends TestCase
     }
 
     /**
-     * @depends testConstructor
-     *
      * @param UploadedFile $uploadedFile
-     *
      */
+    #[Depends('testConstructor')]
     public function testMoveToNotWritable(UploadedFile $uploadedFile)
     {
         $this->expectException(InvalidArgumentException::class);
@@ -216,12 +213,11 @@ class UploadedFileTest extends TestCase
     }
 
     /**
-     * @depends testConstructor
-     *
      * @param UploadedFile $uploadedFile
      *
      * @return UploadedFile
      */
+    #[Depends('testConstructor')]
     public function testMoveTo(UploadedFile $uploadedFile): UploadedFile
     {
         $tempName = uniqid('file-');
@@ -251,11 +247,9 @@ class UploadedFileTest extends TestCase
     }
 
     /**
-     * @depends testConstructorSapi
-     *
      * @param UploadedFile $uploadedFile
-     *
      */
+    #[Depends('testConstructorSapi')]
     public function testMoveToSapiNonUploadedFile(UploadedFile $uploadedFile)
     {
         $this->expectException(RuntimeException::class);
@@ -266,11 +260,9 @@ class UploadedFileTest extends TestCase
     }
 
     /**
-     * @depends testConstructorSapi
-     *
      * @param UploadedFile $uploadedFile
-     *
      */
+    #[Depends('testConstructorSapi')]
     public function testMoveToSapiMoveUploadedFileFails(UploadedFile $uploadedFile)
     {
         $this->markTestSkipped('Needs "adriansuter/php-autoload-override" to override a built-in PHP function');
@@ -285,11 +277,9 @@ class UploadedFileTest extends TestCase
     }
 
     /**
-     * @depends testMoveTo
-     *
      * @param UploadedFile $uploadedFile
-     *
      */
+    #[Depends('testMoveTo')]
     public function testMoveToCannotBeDoneTwice(UploadedFile $uploadedFile)
     {
         $this->expectException(RuntimeException::class);
@@ -306,11 +296,9 @@ class UploadedFileTest extends TestCase
     /**
      * This test must run after testMoveTo
      *
-     * @depends testConstructor
-     *
      * @param UploadedFile $uploadedFile
-     *
      */
+    #[Depends('testConstructor')]
     public function testMoveToAgain(UploadedFile $uploadedFile)
     {
         $this->expectException(RuntimeException::class);
@@ -323,11 +311,9 @@ class UploadedFileTest extends TestCase
     /**
      * This test must run after testMoveTo
      *
-     * @depends testConstructor
-     *
      * @param UploadedFile $uploadedFile
-     *
      */
+    #[Depends('testConstructor')]
     public function testMovedStream(UploadedFile $uploadedFile)
     {
         $this->expectException(RuntimeException::class);