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 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
|
From: =?utf-8?q?David_Pr=C3=A9vot?= <taffit@debian.org>
Date: Mon, 17 Feb 2025 18:33:21 +0100
Subject: Modernize PHPUnit syntax
---
tests/integration/TypedTagsTest.php | 11 ++++++-----
tests/unit/DocBlock/DescriptionFactoryTest.php | 5 +++--
tests/unit/DocBlock/StandardTagFactoryTest.php | 9 +++------
tests/unit/DocBlock/Tags/AuthorTest.php | 3 ++-
tests/unit/DocBlock/Tags/ExampleTest.php | 5 +++--
tests/unit/DocBlock/Tags/Factory/MethodFactoryTest.php | 3 ++-
tests/unit/DocBlock/Tags/Factory/ParamFactoryTest.php | 3 ++-
tests/unit/DocBlock/Tags/MethodParameterTest.php | 3 ++-
tests/unit/DocBlock/Tags/MethodTest.php | 3 ++-
tests/unit/DocBlockFactoryTest.php | 3 ++-
tests/unit/Exception/PcreExceptionTest.php | 3 ++-
11 files changed, 29 insertions(+), 22 deletions(-)
diff --git a/tests/integration/TypedTagsTest.php b/tests/integration/TypedTagsTest.php
index b0f6d65..ca43c8f 100644
--- a/tests/integration/TypedTagsTest.php
+++ b/tests/integration/TypedTagsTest.php
@@ -22,6 +22,7 @@ use phpDocumentor\Reflection\Types\Nullable;
use phpDocumentor\Reflection\Types\Object_;
use phpDocumentor\Reflection\Types\String_;
use phpDocumentor\Reflection\Types\Void_;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
/**
@@ -29,7 +30,7 @@ use PHPUnit\Framework\TestCase;
*/
final class TypedTagsTest extends TestCase
{
- /** @dataProvider typeProvider */
+ #[DataProvider('typeProvider')]
public function testParamFormats(string $type, Type $expectedType): void
{
$docblock = <<<DOCBLOCK
@@ -45,7 +46,7 @@ DOCBLOCK;
$this->assertEquals($expectedType, $phpdoc->getTags()[0]->getType());
}
- /** @dataProvider typeProvider */
+ #[DataProvider('typeProvider')]
public function testVarFormats(string $type, Type $expectedType): void
{
$docblock = <<<DOCBLOCK
@@ -61,7 +62,7 @@ DOCBLOCK;
$this->assertEquals($expectedType, $phpdoc->getTags()[0]->getType());
}
- /** @dataProvider typeProvider */
+ #[DataProvider('typeProvider')]
public function testMethodFormats(string $type, Type $expectedType): void
{
$docblock = <<<DOCBLOCK
@@ -78,7 +79,7 @@ DOCBLOCK;
$this->assertEquals($expectedType, $phpdoc->getTags()[0]->getParameters()[0]->getType());
}
- /** @dataProvider invalidFormatsProvider */
+ #[DataProvider('invalidFormatsProvider')]
public function testInvalidParam(string $type): void
{
$docblock = <<<DOCBLOCK
@@ -95,7 +96,7 @@ DOCBLOCK;
}
- /** @dataProvider invalidFormatsProvider */
+ #[DataProvider('invalidFormatsProvider')]
public function testInvalidMethod(string $type): void
{
$docblock = <<<DOCBLOCK
diff --git a/tests/unit/DocBlock/DescriptionFactoryTest.php b/tests/unit/DocBlock/DescriptionFactoryTest.php
index ef00350..bfcfc74 100644
--- a/tests/unit/DocBlock/DescriptionFactoryTest.php
+++ b/tests/unit/DocBlock/DescriptionFactoryTest.php
@@ -18,6 +18,7 @@ use Mockery as m;
use phpDocumentor\Reflection\DocBlock\Tags\InvalidTag;
use phpDocumentor\Reflection\DocBlock\Tags\Link as LinkTag;
use phpDocumentor\Reflection\Types\Context;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use function str_replace;
@@ -43,8 +44,8 @@ class DescriptionFactoryTest extends TestCase
*
* @covers ::__construct
* @covers ::create
- * @dataProvider provideSimpleExampleDescriptions
*/
+ #[DataProvider('provideSimpleExampleDescriptions')]
public function testDescriptionCanParseASimpleString(string $contents): void
{
$tagFactory = m::mock(TagFactory::class);
@@ -61,8 +62,8 @@ class DescriptionFactoryTest extends TestCase
*
* @covers ::__construct
* @covers ::create
- * @dataProvider provideEscapeSequences
*/
+ #[DataProvider('provideEscapeSequences')]
public function testEscapeSequences(string $contents, string $expected): void
{
$tagFactory = m::mock(TagFactory::class);
diff --git a/tests/unit/DocBlock/StandardTagFactoryTest.php b/tests/unit/DocBlock/StandardTagFactoryTest.php
index 2606cc5..1428f81 100644
--- a/tests/unit/DocBlock/StandardTagFactoryTest.php
+++ b/tests/unit/DocBlock/StandardTagFactoryTest.php
@@ -30,6 +30,7 @@ use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
/**
@@ -463,9 +464,7 @@ class StandardTagFactoryTest extends TestCase
$this->assertInstanceOf(InvalidTag::class, $tag);
}
- /**
- * @dataProvider validTagProvider
- */
+ #[DataProvider('validTagProvider')]
public function testValidFormattedTags(string $input, string $tagName, string $render): void
{
$fqsenResolver = m::mock(FqsenResolver::class);
@@ -528,9 +527,7 @@ class StandardTagFactoryTest extends TestCase
];
}
- /**
- * @dataProvider invalidTagProvider
- */
+ #[DataProvider('invalidTagProvider')]
public function testInValidFormattedTags(string $input): void
{
$this->expectException(InvalidArgumentException::class);
diff --git a/tests/unit/DocBlock/Tags/AuthorTest.php b/tests/unit/DocBlock/Tags/AuthorTest.php
index e0e2a0b..9c7238e 100644
--- a/tests/unit/DocBlock/Tags/AuthorTest.php
+++ b/tests/unit/DocBlock/Tags/AuthorTest.php
@@ -14,6 +14,7 @@ declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags;
use Mockery as m;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
/**
@@ -150,8 +151,8 @@ class AuthorTest extends TestCase
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Author::<public>
*
* @covers ::create
- * @dataProvider authorTagProvider
*/
+ #[DataProvider('authorTagProvider')]
public function testFactoryMethod(string $input, string $output, string $name, string $email): void
{
$fixture = Author::create($input);
diff --git a/tests/unit/DocBlock/Tags/ExampleTest.php b/tests/unit/DocBlock/Tags/ExampleTest.php
index 4741778..a21ed95 100644
--- a/tests/unit/DocBlock/Tags/ExampleTest.php
+++ b/tests/unit/DocBlock/Tags/ExampleTest.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace phpDocumentor\Reflection\DocBlock\Tags;
use InvalidArgumentException;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
/**
@@ -141,7 +142,6 @@ class ExampleTest extends TestCase
/**
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
*
- * @dataProvider tagContentProvider
* @covers ::create
* @covers ::__construct
* @covers ::getFilePath
@@ -150,6 +150,7 @@ class ExampleTest extends TestCase
* @covers ::getDescription
* @covers ::getContent
*/
+ #[DataProvider('tagContentProvider')]
public function testFactoryMethod(
string $input,
string $filePath,
@@ -222,9 +223,9 @@ class ExampleTest extends TestCase
}
/**
- * @dataProvider invalidExampleProvider
* @covers ::__construct
*/
+ #[DataProvider('invalidExampleProvider')]
public function testValidatesArguments(
string $filePath,
bool $isUrl,
diff --git a/tests/unit/DocBlock/Tags/Factory/MethodFactoryTest.php b/tests/unit/DocBlock/Tags/Factory/MethodFactoryTest.php
index 3c5c064..b41bf17 100644
--- a/tests/unit/DocBlock/Tags/Factory/MethodFactoryTest.php
+++ b/tests/unit/DocBlock/Tags/Factory/MethodFactoryTest.php
@@ -21,6 +21,7 @@ use phpDocumentor\Reflection\Types\Integer;
use phpDocumentor\Reflection\Types\Mixed_;
use phpDocumentor\Reflection\Types\String_;
use phpDocumentor\Reflection\Types\Void_;
+use PHPUnit\Framework\Attributes\DataProvider;
final class MethodFactoryTest extends TagFactoryTestCase
{
@@ -28,8 +29,8 @@ final class MethodFactoryTest extends TagFactoryTestCase
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\MethodFactory::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\MethodFactory::create
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\MethodFactory::supports
- * @dataProvider tagProvider
*/
+ #[DataProvider('tagProvider')]
public function testIsCreated(string $tagLine, Method $tag): void
{
$ast = $this->parseTag($tagLine);
diff --git a/tests/unit/DocBlock/Tags/Factory/ParamFactoryTest.php b/tests/unit/DocBlock/Tags/Factory/ParamFactoryTest.php
index 9c7bac2..cd1fc8b 100644
--- a/tests/unit/DocBlock/Tags/Factory/ParamFactoryTest.php
+++ b/tests/unit/DocBlock/Tags/Factory/ParamFactoryTest.php
@@ -26,6 +26,7 @@ use phpDocumentor\Reflection\Types\Integer;
use phpDocumentor\Reflection\Types\Mixed_;
use phpDocumentor\Reflection\Types\Object_;
use phpDocumentor\Reflection\Types\String_;
+use PHPUnit\Framework\Attributes\DataProvider;
final class ParamFactoryTest extends TagFactoryTestCase
{
@@ -33,8 +34,8 @@ final class ParamFactoryTest extends TagFactoryTestCase
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory::__construct
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory::create
* @covers \phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory::supports
- * @dataProvider paramInputProvider
*/
+ #[DataProvider('paramInputProvider')]
public function testParamIsCreated(string $input, Tag $expected): void
{
$ast = $this->parseTag($input);
diff --git a/tests/unit/DocBlock/Tags/MethodParameterTest.php b/tests/unit/DocBlock/Tags/MethodParameterTest.php
index 751b4a0..fe3ba23 100644
--- a/tests/unit/DocBlock/Tags/MethodParameterTest.php
+++ b/tests/unit/DocBlock/Tags/MethodParameterTest.php
@@ -23,6 +23,7 @@ use phpDocumentor\Reflection\Types\Integer;
use phpDocumentor\Reflection\Types\Nullable;
use phpDocumentor\Reflection\Types\Object_;
use phpDocumentor\Reflection\Types\String_;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use stdClass;
@@ -66,10 +67,10 @@ class MethodParameterTest extends TestCase
*
* @param mixed $defaultValue
*
- * @dataProvider collectionDefaultValuesProvider
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::render
* @covers \phpDocumentor\Reflection\DocBlock\Tags\BaseTag::getName
*/
+ #[DataProvider('collectionDefaultValuesProvider')]
public function testIfTagCanBeRenderedUsingMethodParameterWithDefaultValue(
Type $type,
$defaultValue,
diff --git a/tests/unit/DocBlock/Tags/MethodTest.php b/tests/unit/DocBlock/Tags/MethodTest.php
index d662158..35f03a9 100644
--- a/tests/unit/DocBlock/Tags/MethodTest.php
+++ b/tests/unit/DocBlock/Tags/MethodTest.php
@@ -27,6 +27,7 @@ use phpDocumentor\Reflection\Types\Object_;
use phpDocumentor\Reflection\Types\String_;
use phpDocumentor\Reflection\Types\This;
use phpDocumentor\Reflection\Types\Void_;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
/**
@@ -429,9 +430,9 @@ class MethodTest extends TestCase
* @uses \phpDocumentor\Reflection\Types\Integer
* @uses \phpDocumentor\Reflection\Types\Object_
*
- * @dataProvider collectionReturnTypesProvider
* @covers ::create
*/
+ #[DataProvider('collectionReturnTypesProvider')]
public function testCollectionReturnTypes(
string $returnType,
string $expectedType,
diff --git a/tests/unit/DocBlockFactoryTest.php b/tests/unit/DocBlockFactoryTest.php
index 49a0762..977b365 100644
--- a/tests/unit/DocBlockFactoryTest.php
+++ b/tests/unit/DocBlockFactoryTest.php
@@ -20,6 +20,7 @@ use phpDocumentor\Reflection\DocBlock\Tag;
use phpDocumentor\Reflection\DocBlock\TagFactory;
use phpDocumentor\Reflection\DocBlock\Tags\Param;
use phpDocumentor\Reflection\Types\Context;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
@@ -128,8 +129,8 @@ class DocBlockFactoryTest extends TestCase
* @covers ::__construct
* @covers ::create
*
- * @dataProvider provideSummaryAndDescriptions
*/
+ #[DataProvider('provideSummaryAndDescriptions')]
public function testSummaryAndDescriptionAreSeparated(string $given, string $summary, string $description): void
{
$tagFactory = m::mock(TagFactory::class);
diff --git a/tests/unit/Exception/PcreExceptionTest.php b/tests/unit/Exception/PcreExceptionTest.php
index f979976..7eac76f 100644
--- a/tests/unit/Exception/PcreExceptionTest.php
+++ b/tests/unit/Exception/PcreExceptionTest.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace phpDocumentor\Reflection\Exception;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use const PREG_BACKTRACK_LIMIT_ERROR;
@@ -21,8 +22,8 @@ final class PcreExceptionTest extends TestCase
{
/**
* @covers ::createFromPhpError
- * @dataProvider errorCodeProvider
*/
+ #[DataProvider('errorCodeProvider')]
public function testErrorConversion(int $errorCode, string $message): void
{
$this->assertSame($message, PcreException::createFromPhpError($errorCode)->getMessage());
|