|
| 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\TestFixture\Event; |
| 11 | + |
| 12 | +use PHPUnit\Event\Facade as EventFacade; |
| 13 | +use PHPUnit\Framework\Attributes\DataProvider; |
| 14 | +use PHPUnit\Framework\Attributes\IgnorePHPUnitWarnings; |
| 15 | +use PHPUnit\Framework\TestCase; |
| 16 | + |
| 17 | +final class PhpunitWarningIgnoredTest extends TestCase |
| 18 | +{ |
| 19 | + public static function dataProvider(): iterable |
| 20 | + { |
| 21 | + yield [true]; |
| 22 | + } |
| 23 | + |
| 24 | + #[IgnorePHPUnitWarnings] |
| 25 | + public function testPhpunitWarning(): void |
| 26 | + { |
| 27 | + EventFacade::emitter()->testTriggeredPhpunitWarning( |
| 28 | + $this->valueObjectForEvents(), |
| 29 | + 'warning message', |
| 30 | + ); |
| 31 | + |
| 32 | + $this->assertTrue(true); |
| 33 | + } |
| 34 | + |
| 35 | + #[IgnorePHPUnitWarnings('warning message')] |
| 36 | + public function testPhpunitWarningWithExactMessage(): void |
| 37 | + { |
| 38 | + EventFacade::emitter()->testTriggeredPhpunitWarning( |
| 39 | + $this->valueObjectForEvents(), |
| 40 | + 'warning message', |
| 41 | + ); |
| 42 | + |
| 43 | + $this->assertTrue(true); |
| 44 | + } |
| 45 | + |
| 46 | + #[IgnorePHPUnitWarnings('warn(.*)mess(.*)')] |
| 47 | + public function testPhpunitWarningWithRegex(): void |
| 48 | + { |
| 49 | + EventFacade::emitter()->testTriggeredPhpunitWarning( |
| 50 | + $this->valueObjectForEvents(), |
| 51 | + 'warning message', |
| 52 | + ); |
| 53 | + |
| 54 | + $this->assertTrue(true); |
| 55 | + } |
| 56 | + |
| 57 | + #[IgnorePHPUnitWarnings('warn(.*)mess(.*)')] |
| 58 | + public function testPhpunitWarningWithWrongPattern(): void |
| 59 | + { |
| 60 | + EventFacade::emitter()->testTriggeredPhpunitWarning( |
| 61 | + $this->valueObjectForEvents(), |
| 62 | + 'another message', |
| 63 | + ); |
| 64 | + |
| 65 | + $this->assertTrue(true); |
| 66 | + } |
| 67 | + |
| 68 | + #[DataProvider('dataProvider')] |
| 69 | + #[IgnorePHPUnitWarnings] |
| 70 | + public function testTooManyArgumentsInDataProvider(): void |
| 71 | + { |
| 72 | + $this->assertTrue(true); |
| 73 | + } |
| 74 | +} |
0 commit comments