Skip to content

Commit 52384ee

Browse files
nikophilsebastianbergmann
authored andcommitted
refactor: change case from IgnorePHPUnitWarnings to IgnorePhpunitWarnings
1 parent df08b7b commit 52384ee

File tree

12 files changed

+173
-130
lines changed

12 files changed

+173
-130
lines changed

src/Event/Emitter/DispatchingEmitter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
use PHPUnit\Event\TestSuite\Started as TestSuiteStarted;
3030
use PHPUnit\Event\TestSuite\TestSuite;
3131
use PHPUnit\Framework\TestCase;
32-
use PHPUnit\Metadata\IgnorePHPUnitWarnings;
32+
use PHPUnit\Metadata\IgnorePhpunitWarnings;
3333
use PHPUnit\Metadata\Parser\Registry;
3434
use PHPUnit\TextUI\Configuration\Configuration;
3535
use SebastianBergmann\Comparator\Comparator;
@@ -1014,9 +1014,9 @@ public function testTriggeredPhpunitWarning(Code\Test $test, string $message): v
10141014
if (
10151015
$test->isTestMethod() &&
10161016
class_exists($test->className()) &&
1017-
($metadata = Registry::parser()->forMethod($test->className(), $test->methodName())->isIgnorePHPUnitWarnings())->isNotEmpty() &&
1017+
($metadata = Registry::parser()->forMethod($test->className(), $test->methodName())->isIgnorePhpunitWarnings())->isNotEmpty() &&
10181018
($ignoreWarnings = $metadata->asArray()[0] ?? null) !== null &&
1019-
$ignoreWarnings instanceof IgnorePHPUnitWarnings &&
1019+
$ignoreWarnings instanceof IgnorePhpunitWarnings &&
10201020
$ignoreWarnings->shouldIgnore($message)
10211021
) {
10221022
return;

src/Framework/Attributes/IgnorePHPUnitWarnings.php renamed to src/Framework/Attributes/IgnorePhpunitWarnings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
1818
*/
1919
#[Attribute(Attribute::TARGET_METHOD)]
20-
final readonly class IgnorePHPUnitWarnings
20+
final readonly class IgnorePhpunitWarnings
2121
{
2222
/** @var null|non-empty-string */
2323
private ?string $messagePattern;

src/Metadata/IgnorePHPUnitWarnings.php renamed to src/Metadata/IgnorePhpunitWarnings.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
1818
*/
19-
final readonly class IgnorePHPUnitWarnings extends Metadata
19+
final readonly class IgnorePhpunitWarnings extends Metadata
2020
{
2121
/** @var null|non-empty-string */
2222
private ?string $messagePattern;
@@ -32,7 +32,7 @@ protected function __construct(int $level, null|string $messagePattern)
3232
$this->messagePattern = $messagePattern;
3333
}
3434

35-
public function isIgnorePHPUnitWarnings(): true
35+
public function isIgnorePhpunitWarnings(): true
3636
{
3737
return true;
3838
}

src/Metadata/Metadata.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,9 @@ public static function withoutErrorHandler(): WithoutErrorHandler
537537
/**
538538
* @param null|non-empty-string $messagePattern
539539
*/
540-
public static function ignorePHPUnitWarnings(?string $messagePattern): IgnorePHPUnitWarnings
540+
public static function ignorePhpunitWarnings(?string $messagePattern): IgnorePhpunitWarnings
541541
{
542-
return new IgnorePHPUnitWarnings(self::METHOD_LEVEL, $messagePattern);
542+
return new IgnorePhpunitWarnings(self::METHOD_LEVEL, $messagePattern);
543543
}
544544

545545
/**
@@ -979,9 +979,9 @@ public function isWithoutErrorHandler(): bool
979979
}
980980

981981
/**
982-
* @phpstan-assert-if-true IgnorePHPUnitWarnings $this
982+
* @phpstan-assert-if-true IgnorePhpunitWarnings $this
983983
*/
984-
public function isIgnorePHPUnitWarnings(): bool
984+
public function isIgnorePhpunitWarnings(): bool
985985
{
986986
return false;
987987
}

src/Metadata/MetadataCollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,12 +641,12 @@ public function isWithoutErrorHandler(): self
641641
);
642642
}
643643

644-
public function isIgnorePHPUnitWarnings(): self
644+
public function isIgnorePhpunitWarnings(): self
645645
{
646646
return new self(
647647
...array_filter(
648648
$this->metadata,
649-
static fn (Metadata $metadata): bool => $metadata->isIgnorePHPUnitWarnings(),
649+
static fn (Metadata $metadata): bool => $metadata->isIgnorePhpunitWarnings(),
650650
),
651651
);
652652
}

src/Metadata/Parser/AttributeParser.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
use PHPUnit\Framework\Attributes\Group;
5353
use PHPUnit\Framework\Attributes\IgnoreDeprecations;
5454
use PHPUnit\Framework\Attributes\IgnorePhpunitDeprecations;
55-
use PHPUnit\Framework\Attributes\IgnorePHPUnitWarnings;
55+
use PHPUnit\Framework\Attributes\IgnorePhpunitWarnings;
5656
use PHPUnit\Framework\Attributes\Large;
5757
use PHPUnit\Framework\Attributes\Medium;
5858
use PHPUnit\Framework\Attributes\PostCondition;
@@ -885,10 +885,10 @@ public function forMethod(string $className, string $methodName): MetadataCollec
885885

886886
break;
887887

888-
case IgnorePHPUnitWarnings::class:
889-
assert($attributeInstance instanceof IgnorePHPUnitWarnings);
888+
case IgnorePhpunitWarnings::class:
889+
assert($attributeInstance instanceof IgnorePhpunitWarnings);
890890

891-
$result[] = Metadata::ignorePHPUnitWarnings($attributeInstance->messagePattern());
891+
$result[] = Metadata::ignorePhpunitWarnings($attributeInstance->messagePattern());
892892

893893
break;
894894
}

tests/_files/Metadata/Attribute/tests/IgnorePHPUnitWarningsTest.php renamed to tests/_files/Metadata/Attribute/tests/IgnorePhpunitWarningsTest.php

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,14 @@
99
*/
1010
namespace PHPUnit\TestFixture\Metadata\Attribute;
1111

12-
use PHPUnit\Framework\Attributes\IgnorePHPUnitWarnings;
12+
use PHPUnit\Framework\Attributes\IgnorePhpunitWarnings;
1313
use PHPUnit\Framework\TestCase;
1414

15-
final class IgnorePHPUnitWarningsTest extends TestCase
15+
final class IgnorePhpunitWarningsTest extends TestCase
1616
{
17-
#[IgnorePHPUnitWarnings]
17+
#[IgnorePhpunitWarnings]
1818
public function testOne(): void
1919
{
2020
$this->assertTrue(true);
2121
}
22-
23-
#[IgnorePHPUnitWarnings('warning.*pattern')]
24-
public function testTwo(): void
25-
{
26-
$this->assertTrue(true);
27-
}
28-
29-
#[IgnorePHPUnitWarnings('exact message')]
30-
public function testThree(): void
31-
{
32-
$this->assertTrue(true);
33-
}
3422
}

tests/end-to-end/event/_files/PhpunitWarningIgnoredTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
use PHPUnit\Event\Facade as EventFacade;
1313
use PHPUnit\Framework\Attributes\DataProvider;
14-
use PHPUnit\Framework\Attributes\IgnorePHPUnitWarnings;
14+
use PHPUnit\Framework\Attributes\IgnorePhpunitWarnings;
1515
use PHPUnit\Framework\TestCase;
1616

1717
final class PhpunitWarningIgnoredTest extends TestCase
@@ -21,7 +21,7 @@ public static function dataProvider(): iterable
2121
yield [true];
2222
}
2323

24-
#[IgnorePHPUnitWarnings]
24+
#[IgnorePhpunitWarnings]
2525
public function testPhpunitWarning(): void
2626
{
2727
EventFacade::emitter()->testTriggeredPhpunitWarning(
@@ -32,7 +32,7 @@ public function testPhpunitWarning(): void
3232
$this->assertTrue(true);
3333
}
3434

35-
#[IgnorePHPUnitWarnings('warning message')]
35+
#[IgnorePhpunitWarnings('warning message')]
3636
public function testPhpunitWarningWithExactMessage(): void
3737
{
3838
EventFacade::emitter()->testTriggeredPhpunitWarning(
@@ -43,7 +43,7 @@ public function testPhpunitWarningWithExactMessage(): void
4343
$this->assertTrue(true);
4444
}
4545

46-
#[IgnorePHPUnitWarnings('warn(.*)mess(.*)')]
46+
#[IgnorePhpunitWarnings('warn(.*)mess(.*)')]
4747
public function testPhpunitWarningWithRegex(): void
4848
{
4949
EventFacade::emitter()->testTriggeredPhpunitWarning(
@@ -54,7 +54,7 @@ public function testPhpunitWarningWithRegex(): void
5454
$this->assertTrue(true);
5555
}
5656

57-
#[IgnorePHPUnitWarnings('warn(.*)mess(.*)')]
57+
#[IgnorePhpunitWarnings('warn(.*)mess(.*)')]
5858
public function testPhpunitWarningWithWrongPattern(): void
5959
{
6060
EventFacade::emitter()->testTriggeredPhpunitWarning(
@@ -66,7 +66,7 @@ public function testPhpunitWarningWithWrongPattern(): void
6666
}
6767

6868
#[DataProvider('dataProvider')]
69-
#[IgnorePHPUnitWarnings]
69+
#[IgnorePhpunitWarnings]
7070
public function testTooManyArgumentsInDataProvider(): void
7171
{
7272
$this->assertTrue(true);

tests/unit/Metadata/IgnorePHPUnitWarningsTest.php renamed to tests/unit/Metadata/IgnorePhpunitWarningsTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
use PHPUnit\Framework\Attributes\Small;
1515
use PHPUnit\Framework\TestCase;
1616

17-
#[CoversClass(IgnorePHPUnitWarnings::class)]
17+
#[CoversClass(IgnorePhpunitWarnings::class)]
1818
#[Small]
19-
final class IgnorePHPUnitWarningsTest extends TestCase
19+
final class IgnorePhpunitWarningsTest extends TestCase
2020
{
2121
public static function shouldIgnoreProvider(): array
2222
{
@@ -32,7 +32,7 @@ public static function shouldIgnoreProvider(): array
3232
#[DataProvider('shouldIgnoreProvider')]
3333
public function testShouldIgnore(?string $messagePattern, string $message, bool $expected): void
3434
{
35-
$metadata = Metadata::ignorePHPUnitWarnings($messagePattern);
35+
$metadata = Metadata::ignorePhpunitWarnings($messagePattern);
3636

3737
$this->assertSame($expected, $metadata->shouldIgnore($message));
3838
}

0 commit comments

Comments
 (0)