-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial work on expected E_USER_DEPRECATED issues
- Loading branch information
1 parent
6efa643
commit 9233648
Showing
6 changed files
with
208 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
tests/end-to-end/event/_files/TestForDeprecatedFeatureTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of PHPUnit. | ||
* | ||
* (c) Sebastian Bergmann <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace PHPUnit\TestFixture\Event; | ||
|
||
use const E_USER_DEPRECATED; | ||
use function trigger_error; | ||
use PHPUnit\Framework\Attributes\IgnoreDeprecations; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class TestForDeprecatedFeatureTest extends TestCase | ||
{ | ||
#[IgnoreDeprecations] | ||
public function testOne(): void | ||
{ | ||
$this->expectUserDeprecationMessage('message'); | ||
|
||
@trigger_error('message', E_USER_DEPRECATED); | ||
} | ||
|
||
#[IgnoreDeprecations] | ||
public function testTwo(): void | ||
{ | ||
$this->expectUserDeprecationMessage('message'); | ||
|
||
@trigger_error('something else', E_USER_DEPRECATED); | ||
} | ||
|
||
#[IgnoreDeprecations] | ||
public function testThree(): void | ||
{ | ||
$this->expectUserDeprecationMessageMatches('/message/'); | ||
|
||
@trigger_error('...message...', E_USER_DEPRECATED); | ||
} | ||
|
||
#[IgnoreDeprecations] | ||
public function testFour(): void | ||
{ | ||
$this->expectUserDeprecationMessage('message'); | ||
|
||
@trigger_error('something else', E_USER_DEPRECATED); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
tests/end-to-end/event/expectation-on-user-deprecation.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--TEST-- | ||
The right events are emitted in the right order for a test which expects the tested code to trigger E_USER_DEPRECATED issues | ||
--FILE-- | ||
<?php declare(strict_types=1); | ||
$traceFile = tempnam(sys_get_temp_dir(), __FILE__); | ||
|
||
$_SERVER['argv'][] = '--do-not-cache-result'; | ||
$_SERVER['argv'][] = '--no-configuration'; | ||
$_SERVER['argv'][] = '--no-output'; | ||
$_SERVER['argv'][] = '--log-events-text'; | ||
$_SERVER['argv'][] = $traceFile; | ||
$_SERVER['argv'][] = __DIR__ . '/_files/TestForDeprecatedFeatureTest.php'; | ||
|
||
require __DIR__ . '/../../bootstrap.php'; | ||
|
||
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']); | ||
|
||
print file_get_contents($traceFile); | ||
|
||
unlink($traceFile); | ||
--EXPECTF-- | ||
PHPUnit Started (PHPUnit %s using %s) | ||
Test Runner Configured | ||
Test Suite Loaded (4 tests) | ||
Event Facade Sealed | ||
Test Runner Started | ||
Test Suite Sorted | ||
Test Runner Execution Started (4 tests) | ||
Test Suite Started (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest, 4 tests) | ||
Test Preparation Started (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest::testOne) | ||
Test Prepared (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest::testOne) | ||
Test Triggered Test-Ignored Deprecation (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest::testOne) | ||
message | ||
Test Passed (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest::testOne) | ||
Test Finished (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest::testOne) | ||
Test Preparation Started (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest::testTwo) | ||
Test Prepared (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest::testTwo) | ||
Test Triggered Test-Ignored Deprecation (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest::testTwo) | ||
something else | ||
Test Failed (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest::testTwo) | ||
Expected deprecation with message "message" was not triggered | ||
Test Finished (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest::testTwo) | ||
Test Preparation Started (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest::testThree) | ||
Test Prepared (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest::testThree) | ||
Test Triggered Test-Ignored Deprecation (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest::testThree) | ||
...message... | ||
Test Passed (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest::testThree) | ||
Test Finished (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest::testThree) | ||
Test Preparation Started (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest::testFour) | ||
Test Prepared (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest::testFour) | ||
Test Triggered Test-Ignored Deprecation (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest::testFour) | ||
something else | ||
Test Failed (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest::testFour) | ||
Expected deprecation with message "message" was not triggered | ||
Test Finished (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest::testFour) | ||
Test Suite Finished (PHPUnit\TestFixture\Event\TestForDeprecatedFeatureTest, 4 tests) | ||
Test Runner Execution Finished | ||
Test Runner Finished | ||
PHPUnit Finished (Shell Exit Code: 1) |