Skip to content

Commit

Permalink
Do not emit issues in test code for baseline-related end-to-end tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Nov 26, 2024
1 parent 6629680 commit 05c1687
Show file tree
Hide file tree
Showing 25 changed files with 505 additions and 206 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../phpunit.xsd"
cacheResult="false"
bootstrap="src/Source.php"
>
<testsuites>
<testsuite name="default">
Expand All @@ -15,7 +16,9 @@
ignoreSuppressionOfNotices="true"
ignoreSuppressionOfPhpNotices="true"
ignoreSuppressionOfWarnings="true"
ignoreSuppressionOfPhpWarnings="true"
>
ignoreSuppressionOfPhpWarnings="true">
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?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\Baseline;

use const E_USER_DEPRECATED;
use const E_USER_NOTICE;
use const E_USER_WARNING;
use function trigger_error;
use Serializable;

final class Source
{
public function triggerDeprecation(): void
{
$this->deprecation();
}

public function triggerNotice(): void
{
$this->notice();
}

public function triggerWarning(): void
{
$this->warning();
}

public function triggerPhpDeprecation(): void
{
$this->phpDeprecation();
}

public function triggerPhpNoticeAndWarning(): void
{
$this->phpNoticeAndWarning();
}

private function deprecation(): void
{
@trigger_error('deprecation', E_USER_DEPRECATED);
}

private function notice(): void
{
@trigger_error('notice', E_USER_NOTICE);
}

private function warning(): void
{
@trigger_error('warning', E_USER_WARNING);
}

private function phpDeprecation(): void
{
@$o = new class implements Serializable
{
public function serialize(): void
{
}

public function unserialize(string $data): void
{
}
};
}

private function phpNoticeAndWarning(): void
{
$o = new class
{
public static $a = 'b';
};

@$o->a;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,60 +9,41 @@
*/
namespace PHPUnit\TestFixture\Baseline;

use const E_USER_DEPRECATED;
use const E_USER_NOTICE;
use const E_USER_WARNING;
use function trigger_error;
use PHPUnit\Framework\TestCase;
use Serializable;

final class Test extends TestCase
{
public function testDeprecation(): void
{
@trigger_error('deprecation', E_USER_DEPRECATED);
(new Source)->triggerDeprecation();

$this->assertTrue(true);
}

public function testNotice(): void
{
@trigger_error('notice', E_USER_NOTICE);
(new Source)->triggerNotice();

$this->assertTrue(true);
}

public function testWarning(): void
{
@trigger_error('warning', E_USER_WARNING);
(new Source)->triggerWarning();

$this->assertTrue(true);
}

public function testPhpDeprecation(): void
{
@$o = new class implements Serializable
{
public function serialize(): void
{
}

public function unserialize(string $data): void
{
}
};
(new Source)->triggerPhpDeprecation();

$this->assertTrue(true);
}

public function testPhpNoticeAndWarning(): void
{
$o = new class
{
public static $a = 'b';
};

@$o->a;
(new Source)->triggerPhpNoticeAndWarning();

$this->assertTrue(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../phpunit.xsd"
cacheResult="false"
bootstrap="src/Source.php"
>
<testsuites>
<testsuite name="default">
Expand All @@ -10,5 +11,8 @@
</testsuites>

<source baseline="baseline.xml">
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?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\Baseline;

use const E_USER_DEPRECATED;
use const E_USER_NOTICE;
use const E_USER_WARNING;
use function trigger_error;
use Serializable;

final class Source
{
public function triggerDeprecation(): void
{
$this->deprecation();
}

public function triggerNotice(): void
{
$this->notice();
}

public function triggerWarning(): void
{
$this->warning();
}

public function triggerPhpDeprecation(): void
{
$this->phpDeprecation();
}

public function triggerPhpNoticeAndWarning(): void
{
$this->phpNoticeAndWarning();
}

private function deprecation(): void
{
@trigger_error('deprecation', E_USER_DEPRECATED);
}

private function notice(): void
{
@trigger_error('notice', E_USER_NOTICE);
}

private function warning(): void
{
@trigger_error('warning', E_USER_WARNING);
}

private function phpDeprecation(): void
{
@$o = new class implements Serializable
{
public function serialize(): void
{
}

public function unserialize(string $data): void
{
}
};
}

private function phpNoticeAndWarning(): void
{
$o = new class
{
public static $a = 'b';
};

@$o->a;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,60 +9,41 @@
*/
namespace PHPUnit\TestFixture\Baseline;

use const E_USER_DEPRECATED;
use const E_USER_NOTICE;
use const E_USER_WARNING;
use function trigger_error;
use PHPUnit\Framework\TestCase;
use Serializable;

final class Test extends TestCase
{
public function testDeprecation(): void
{
@trigger_error('deprecation', E_USER_DEPRECATED);
(new Source)->triggerDeprecation();

$this->assertTrue(true);
}

public function testNotice(): void
{
@trigger_error('notice', E_USER_NOTICE);
(new Source)->triggerNotice();

$this->assertTrue(true);
}

public function testWarning(): void
{
@trigger_error('warning', E_USER_WARNING);
(new Source)->triggerWarning();

$this->assertTrue(true);
}

public function testPhpDeprecation(): void
{
@$o = new class implements Serializable
{
public function serialize(): void
{
}

public function unserialize(string $data): void
{
}
};
(new Source)->triggerPhpDeprecation();

$this->assertTrue(true);
}

public function testPhpNoticeAndWarning(): void
{
$o = new class
{
public static $a = 'b';
};

@$o->a;
(new Source)->triggerPhpNoticeAndWarning();

$this->assertTrue(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../phpunit.xsd"
cacheResult="false"
bootstrap="src/Source.php"
>
<testsuites>
<testsuite name="default">
Expand All @@ -10,5 +11,8 @@
</testsuites>

<source baseline="baseline.xml">
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
Loading

0 comments on commit 05c1687

Please sign in to comment.