Skip to content

Commit 22250e1

Browse files
Add test
1 parent 683009b commit 22250e1

File tree

8 files changed

+72
-9
lines changed

8 files changed

+72
-9
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="../../../../../phpunit.xsd"
4+
>
5+
<testsuites>
6+
<testsuite name="default">
7+
<directory>tests</directory>
8+
</testsuite>
9+
</testsuites>
10+
11+
<source ignoreSelfDeprecations="true" restrictNotices="true" restrictWarnings="true">
12+
<include>
13+
<directory>src</directory>
14+
</include>
15+
</source>
16+
</phpunit>

tests/end-to-end/regression/6028/tests/Issue6028Test.php renamed to tests/end-to-end/self-direct-indirect/_files/deprecation-in-test-code-ignored/tests/DeprecationInTestCodeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
* For the full copyright and license information, please view the LICENSE
88
* file that was distributed with this source code.
99
*/
10-
namespace PHPUnit\TestFixture\Issue6028;
10+
namespace PHPUnit\TestFixture\SelfDirectIndirect;
1111

1212
use const E_USER_DEPRECATED;
1313
use function trigger_error;
1414
use PHPUnit\Framework\TestCase;
1515

16-
final class Issue6028Test extends TestCase
16+
final class DeprecationInTestCodeTest extends TestCase
1717
{
1818
public function testOne(): void
1919
{

tests/end-to-end/regression/6028/phpunit.xml renamed to tests/end-to-end/self-direct-indirect/_files/deprecation-in-test-code/phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="../../../../phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="../../../../../phpunit.xsd"
44
>
55
<testsuites>
66
<testsuite name="default">

tests/end-to-end/self-direct-indirect/_files/deprecation-in-test-code/src/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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\SelfDirectIndirect;
11+
12+
use const E_USER_DEPRECATED;
13+
use function trigger_error;
14+
use PHPUnit\Framework\TestCase;
15+
16+
final class DeprecationInTestCodeTest extends TestCase
17+
{
18+
public function testOne(): void
19+
{
20+
trigger_error('message', E_USER_DEPRECATED);
21+
22+
$this->assertTrue(true);
23+
}
24+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Deprecation in test code is not reported when it is configured to not be reported
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--display-deprecations';
7+
$_SERVER['argv'][] = '--configuration';
8+
$_SERVER['argv'][] = __DIR__ . '/_files/deprecation-in-test-code-ignored';
9+
10+
require __DIR__ . '/../../bootstrap.php';
11+
12+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
13+
--EXPECTF--
14+
PHPUnit %s by Sebastian Bergmann and contributors.
15+
16+
Runtime: %s
17+
Configuration: %sphpunit.xml
18+
19+
. 1 / 1 (100%)
20+
21+
Time: %s, Memory: %s
22+
23+
OK (1 test, 1 assertion)

tests/end-to-end/regression/6028.phpt renamed to tests/end-to-end/self-direct-indirect/deprecation-in-test-code.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
--TEST--
2-
https://github.com/sebastianbergmann/phpunit/issues/6028
2+
Deprecation in test code is reported when it is configured to be reported
33
--FILE--
44
<?php declare(strict_types=1);
55
$_SERVER['argv'][] = '--do-not-cache-result';
66
$_SERVER['argv'][] = '--display-deprecations';
77
$_SERVER['argv'][] = '--configuration';
8-
$_SERVER['argv'][] = __DIR__ . '/6028';
8+
$_SERVER['argv'][] = __DIR__ . '/_files/deprecation-in-test-code';
99

10-
require_once __DIR__ . '/../../bootstrap.php';
10+
require __DIR__ . '/../../bootstrap.php';
1111

1212
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
1313
--EXPECTF--
@@ -22,13 +22,13 @@ Time: %s, Memory: %s
2222

2323
1 test triggered 1 deprecation:
2424

25-
1) %sIssue6028Test.php:20
25+
1) %sDeprecationInTestCodeTest.php:20
2626
message
2727

2828
Triggered by:
2929

30-
* PHPUnit\TestFixture\Issue6028\Issue6028Test::testOne
31-
%sIssue6028Test.php:18
30+
* PHPUnit\TestFixture\SelfDirectIndirect\DeprecationInTestCodeTest::testOne
31+
%sDeprecationInTestCodeTest.php:18
3232

3333
OK, but there were issues!
3434
Tests: 1, Assertions: 1, Deprecations: 1.

0 commit comments

Comments
 (0)