Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Nov 25, 2024
1 parent 683009b commit 22250e1
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../phpunit.xsd"
>
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>

<source ignoreSelfDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\TestFixture\Issue6028;
namespace PHPUnit\TestFixture\SelfDirectIndirect;

use const E_USER_DEPRECATED;
use function trigger_error;
use PHPUnit\Framework\TestCase;

final class Issue6028Test extends TestCase
final class DeprecationInTestCodeTest extends TestCase
{
public function testOne(): void
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../phpunit.xsd"
xsi:noNamespaceSchemaLocation="../../../../../phpunit.xsd"
>
<testsuites>
<testsuite name="default">
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\TestFixture\SelfDirectIndirect;

use const E_USER_DEPRECATED;
use function trigger_error;
use PHPUnit\Framework\TestCase;

final class DeprecationInTestCodeTest extends TestCase
{
public function testOne(): void
{
trigger_error('message', E_USER_DEPRECATED);

$this->assertTrue(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
Deprecation in test code is not reported when it is configured to not be reported
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--display-deprecations';
$_SERVER['argv'][] = '--configuration';
$_SERVER['argv'][] = __DIR__ . '/_files/deprecation-in-test-code-ignored';

require __DIR__ . '/../../bootstrap.php';

(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

Runtime: %s
Configuration: %sphpunit.xml

. 1 / 1 (100%)

Time: %s, Memory: %s

OK (1 test, 1 assertion)
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
--TEST--
https://github.com/sebastianbergmann/phpunit/issues/6028
Deprecation in test code is reported when it is configured to be reported
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--display-deprecations';
$_SERVER['argv'][] = '--configuration';
$_SERVER['argv'][] = __DIR__ . '/6028';
$_SERVER['argv'][] = __DIR__ . '/_files/deprecation-in-test-code';

require_once __DIR__ . '/../../bootstrap.php';
require __DIR__ . '/../../bootstrap.php';

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

1 test triggered 1 deprecation:

1) %sIssue6028Test.php:20
1) %sDeprecationInTestCodeTest.php:20
message

Triggered by:

* PHPUnit\TestFixture\Issue6028\Issue6028Test::testOne
%sIssue6028Test.php:18
* PHPUnit\TestFixture\SelfDirectIndirect\DeprecationInTestCodeTest::testOne
%sDeprecationInTestCodeTest.php:18

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

0 comments on commit 22250e1

Please sign in to comment.