|
| 1 | +<?php declare(strict_types=1); |
| 2 | +/* |
| 3 | + * This file is part of PHPUnit. |
| 4 | + * |
| 5 | + * (c) Sebastian Bergmann <sebastian@phpunit.de> |
| 6 | + * |
| 7 | + * For the full copyright and license information, please view the LICENSE |
| 8 | + * file that was distributed with this source code. |
| 9 | + */ |
| 10 | +namespace PHPUnit\Metadata; |
| 11 | + |
| 12 | +use PHPUnit\Framework\Attributes\CoversClass; |
| 13 | +use PHPUnit\Framework\Attributes\DataProvider; |
| 14 | +use PHPUnit\Framework\Attributes\Small; |
| 15 | +use PHPUnit\Framework\TestCase; |
| 16 | + |
| 17 | +#[CoversClass(IgnoreDeprecations::class)] |
| 18 | +#[Small] |
| 19 | +final class IgnoreDeprecationsTest extends TestCase |
| 20 | +{ |
| 21 | + public static function shouldIgnoreProvider(): array |
| 22 | + { |
| 23 | + return [ |
| 24 | + 'null pattern ignores any message' => [null, 'any warning message', true], |
| 25 | + 'pattern matches message' => ['warning.*message', 'warning test message', true], |
| 26 | + 'pattern does not match different message' => ['warning.*message', 'different message', false], |
| 27 | + 'exact match works' => ['exact warning message', 'exact warning message', true], |
| 28 | + 'exact match does not match different' => ['exact warning message', 'different warning message', false], |
| 29 | + ]; |
| 30 | + } |
| 31 | + |
| 32 | + #[DataProvider('shouldIgnoreProvider')] |
| 33 | + public function testShouldIgnoreOnClass(?string $messagePattern, string $message, bool $expected): void |
| 34 | + { |
| 35 | + $metadata = Metadata::ignoreDeprecationsOnClass($messagePattern); |
| 36 | + |
| 37 | + $this->assertSame($expected, $metadata->shouldIgnore($message)); |
| 38 | + } |
| 39 | + |
| 40 | + #[DataProvider('shouldIgnoreProvider')] |
| 41 | + public function testShouldIgnoreOnMethod(?string $messagePattern, string $message, bool $expected): void |
| 42 | + { |
| 43 | + $metadata = Metadata::ignoreDeprecationsOnMethod($messagePattern); |
| 44 | + |
| 45 | + $this->assertSame($expected, $metadata->shouldIgnore($message)); |
| 46 | + } |
| 47 | +} |
0 commit comments