|
| 1 | +<?php declare(strict_types=1); |
| 2 | +/* |
| 3 | + * This file is part of PHPUnit. |
| 4 | + * |
| 5 | + * (c) Sebastian Bergmann <[email protected]> |
| 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 const E_USER_DEPRECATED; |
| 13 | +use function trigger_error; |
| 14 | +use PHPUnit\Framework\Attributes\IgnoreDeprecations; |
| 15 | +use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; |
| 16 | +use PHPUnit\Framework\TestCase; |
| 17 | + |
| 18 | +#[RunTestsInSeparateProcesses] |
| 19 | +final class TestForDeprecatedFeatureInIsolationTest extends TestCase |
| 20 | +{ |
| 21 | + #[IgnoreDeprecations] |
| 22 | + public function testExpectationOnExactDeprecationMessageWorksWhenExpectedDeprecationIsTriggered(): void |
| 23 | + { |
| 24 | + $this->expectUserDeprecationMessage('message'); |
| 25 | + |
| 26 | + @trigger_error('message', E_USER_DEPRECATED); |
| 27 | + } |
| 28 | + |
| 29 | + #[IgnoreDeprecations] |
| 30 | + public function testExpectationsOnExactDeprecationMessagesWorkWhenExpectedDeprecationsAreTriggered(): void |
| 31 | + { |
| 32 | + $this->expectUserDeprecationMessage('message'); |
| 33 | + $this->expectUserDeprecationMessage('another message'); |
| 34 | + |
| 35 | + @trigger_error('message', E_USER_DEPRECATED); |
| 36 | + @trigger_error('another message', E_USER_DEPRECATED); |
| 37 | + } |
| 38 | + |
| 39 | + #[IgnoreDeprecations] |
| 40 | + public function testExpectationOnExactDeprecationMessageWorksWhenExpectedDeprecationIsNotTriggered(): void |
| 41 | + { |
| 42 | + $this->expectUserDeprecationMessage('message'); |
| 43 | + } |
| 44 | + |
| 45 | + #[IgnoreDeprecations] |
| 46 | + public function testExpectationOnExactDeprecationMessageWorksWhenUnexpectedDeprecationIsTriggered(): void |
| 47 | + { |
| 48 | + $this->expectUserDeprecationMessage('message'); |
| 49 | + |
| 50 | + @trigger_error('another message', E_USER_DEPRECATED); |
| 51 | + } |
| 52 | + |
| 53 | + #[IgnoreDeprecations] |
| 54 | + public function testExpectationOnDeprecationMessageMatchingRegularExpressionWorksWhenExpectedDeprecationIsTriggered(): void |
| 55 | + { |
| 56 | + $this->expectUserDeprecationMessageMatches('/message/'); |
| 57 | + |
| 58 | + @trigger_error('...message...', E_USER_DEPRECATED); |
| 59 | + } |
| 60 | + |
| 61 | + #[IgnoreDeprecations] |
| 62 | + public function testExpectationsOnDeprecationMessagesMatchingRegularExpressionsWorkWhenExpectedDeprecationsAreTriggered(): void |
| 63 | + { |
| 64 | + $this->expectUserDeprecationMessageMatches('/foo/'); |
| 65 | + $this->expectUserDeprecationMessageMatches('/bar/'); |
| 66 | + |
| 67 | + @trigger_error('...foo...', E_USER_DEPRECATED); |
| 68 | + @trigger_error('...bar...', E_USER_DEPRECATED); |
| 69 | + } |
| 70 | + |
| 71 | + #[IgnoreDeprecations] |
| 72 | + public function testExpectationOnDeprecationMessageMatchingRegularExpressionWorksWhenExpectedDeprecationIsNotTriggered(): void |
| 73 | + { |
| 74 | + $this->expectUserDeprecationMessageMatches('/message/'); |
| 75 | + } |
| 76 | + |
| 77 | + #[IgnoreDeprecations] |
| 78 | + public function testExpectationOnDeprecationMessageMatchingRegularExpressionWorksWhenUnepectedDeprecationIsTriggered(): void |
| 79 | + { |
| 80 | + $this->expectUserDeprecationMessageMatches('/message/'); |
| 81 | + |
| 82 | + @trigger_error('something else', E_USER_DEPRECATED); |
| 83 | + } |
| 84 | +} |
0 commit comments