Skip to content

Commit

Permalink
Closes #5441
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Sep 11, 2023
1 parent 556191d commit a58a6a2
Show file tree
Hide file tree
Showing 82 changed files with 2,565 additions and 100 deletions.
23 changes: 23 additions & 0 deletions .psalm/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,14 @@
<code><![CDATA[!empty($matches['operator']) ? $matches['operator'] : '>=']]></code>
</ArgumentTypeCoercion>
</file>
<file src="src/Runner/Baseline/RelativePathCalculator.php">
<LessSpecificReturnStatement>
<code><![CDATA[array_merge(array_fill(0, $dotsCount, '..'), array_slice($filenameParts, $i))]]></code>
</LessSpecificReturnStatement>
<MoreSpecificReturnType>
<code><![CDATA[list<non-empty-string>]]></code>
</MoreSpecificReturnType>
</file>
<file src="src/Runner/CodeCoverage.php">
<InvalidNullableReturnType>
<code>Driver</code>
Expand Down Expand Up @@ -569,6 +577,17 @@
<code>stop</code>
</PossiblyNullReference>
</file>
<file src="src/Runner/ErrorHandler.php">
<ArgumentTypeCoercion>
<code>$errorFile</code>
<code>$errorLine</code>
<code>$errorString</code>
</ArgumentTypeCoercion>
<MissingThrowsDocblock>
<code>Issue::from($file, $line, null, $description)</code>
<code>Issue::from($file, $line, null, $description)</code>
</MissingThrowsDocblock>
</file>
<file src="src/Runner/Filter/GroupFilterIterator.php">
<MissingTemplateParam>
<code>GroupFilterIterator</code>
Expand Down Expand Up @@ -635,6 +654,9 @@
</ArgumentTypeCoercion>
</file>
<file src="src/TextUI/Application.php">
<ArgumentTypeCoercion>
<code><![CDATA[$configuration->generateBaseline()]]></code>
</ArgumentTypeCoercion>
<InternalMethod>
<code>nameAndVersion</code>
</InternalMethod>
Expand Down Expand Up @@ -726,6 +748,7 @@
<code>hasCoverageCacheDirectory</code>
</DeprecatedMethod>
<MissingThrowsDocblock>
<code>baseline</code>
<code>detect</code>
</MissingThrowsDocblock>
<PossiblyUndefinedArrayOffset>
Expand Down
1 change: 1 addition & 0 deletions ChangeLog-10.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes of the PHPUnit 10.4 release series are documented in this fi

### Added

* [#5441](https://github.com/sebastianbergmann/phpunit/issues/5441): Baseline for `E_(USER_)DEPRECATED`, `E_(USER_)NOTICE`, `E_STRICT`, and `E_(USER_)WARNING`
* [#5462](https://github.com/sebastianbergmann/phpunit/pull/5462): Support for multiple arguments
* [#5471](https://github.com/sebastianbergmann/phpunit/issues/5471): `assertFileMatchesFormat()` and `assertFileMatchesFormatFile()`
* Attribute `id` attribute for `testCaseMethod` elements in the XML document generated by `--list-tests-xml`
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</testsuite>

<testsuite name="end-to-end">
<directory suffix=".phpt">tests/end-to-end/baseline</directory>
<directory suffix=".phpt">tests/end-to-end/cli</directory>
<directory suffix=".phpt">tests/end-to-end/code-coverage</directory>
<directory suffix=".phpt">tests/end-to-end/event</directory>
Expand Down
1 change: 1 addition & 0 deletions phpunit.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="baseline" type="xs:anyURI"/>
<xs:attribute name="restrictDeprecations" type="xs:boolean" default="false"/>
<xs:attribute name="restrictNotices" type="xs:boolean" default="false"/>
<xs:attribute name="restrictWarnings" type="xs:boolean" default="false"/>
Expand Down
18 changes: 12 additions & 6 deletions src/Event/Emitter/DispatchingEmitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ public function testTriggeredPhpunitDeprecation(Code\Test $test, string $message
* @throws InvalidArgumentException
* @throws UnknownEventTypeException
*/
public function testTriggeredPhpDeprecation(Code\Test $test, string $message, string $file, int $line, bool $suppressed): void
public function testTriggeredPhpDeprecation(Code\Test $test, string $message, string $file, int $line, bool $suppressed, bool $ignoredByBaseline): void
{
$this->dispatcher->dispatch(
new Test\PhpDeprecationTriggered(
Expand All @@ -762,6 +762,7 @@ public function testTriggeredPhpDeprecation(Code\Test $test, string $message, st
$file,
$line,
$suppressed,
$ignoredByBaseline,
),
);
}
Expand All @@ -770,7 +771,7 @@ public function testTriggeredPhpDeprecation(Code\Test $test, string $message, st
* @throws InvalidArgumentException
* @throws UnknownEventTypeException
*/
public function testTriggeredDeprecation(Code\Test $test, string $message, string $file, int $line, bool $suppressed): void
public function testTriggeredDeprecation(Code\Test $test, string $message, string $file, int $line, bool $suppressed, bool $ignoredByBaseline): void
{
$this->dispatcher->dispatch(
new Test\DeprecationTriggered(
Expand All @@ -780,6 +781,7 @@ public function testTriggeredDeprecation(Code\Test $test, string $message, strin
$file,
$line,
$suppressed,
$ignoredByBaseline,
),
);
}
Expand All @@ -806,7 +808,7 @@ public function testTriggeredError(Code\Test $test, string $message, string $fil
* @throws InvalidArgumentException
* @throws UnknownEventTypeException
*/
public function testTriggeredNotice(Code\Test $test, string $message, string $file, int $line, bool $suppressed): void
public function testTriggeredNotice(Code\Test $test, string $message, string $file, int $line, bool $suppressed, bool $ignoredByBaseline): void
{
$this->dispatcher->dispatch(
new Test\NoticeTriggered(
Expand All @@ -816,6 +818,7 @@ public function testTriggeredNotice(Code\Test $test, string $message, string $fi
$file,
$line,
$suppressed,
$ignoredByBaseline,
),
);
}
Expand All @@ -824,7 +827,7 @@ public function testTriggeredNotice(Code\Test $test, string $message, string $fi
* @throws InvalidArgumentException
* @throws UnknownEventTypeException
*/
public function testTriggeredPhpNotice(Code\Test $test, string $message, string $file, int $line, bool $suppressed): void
public function testTriggeredPhpNotice(Code\Test $test, string $message, string $file, int $line, bool $suppressed, bool $ignoredByBaseline): void
{
$this->dispatcher->dispatch(
new Test\PhpNoticeTriggered(
Expand All @@ -834,6 +837,7 @@ public function testTriggeredPhpNotice(Code\Test $test, string $message, string
$file,
$line,
$suppressed,
$ignoredByBaseline,
),
);
}
Expand All @@ -842,7 +846,7 @@ public function testTriggeredPhpNotice(Code\Test $test, string $message, string
* @throws InvalidArgumentException
* @throws UnknownEventTypeException
*/
public function testTriggeredWarning(Code\Test $test, string $message, string $file, int $line, bool $suppressed): void
public function testTriggeredWarning(Code\Test $test, string $message, string $file, int $line, bool $suppressed, bool $ignoredByBaseline): void
{
$this->dispatcher->dispatch(
new Test\WarningTriggered(
Expand All @@ -852,6 +856,7 @@ public function testTriggeredWarning(Code\Test $test, string $message, string $f
$file,
$line,
$suppressed,
$ignoredByBaseline,
),
);
}
Expand All @@ -860,7 +865,7 @@ public function testTriggeredWarning(Code\Test $test, string $message, string $f
* @throws InvalidArgumentException
* @throws UnknownEventTypeException
*/
public function testTriggeredPhpWarning(Code\Test $test, string $message, string $file, int $line, bool $suppressed): void
public function testTriggeredPhpWarning(Code\Test $test, string $message, string $file, int $line, bool $suppressed, bool $ignoredByBaseline): void
{
$this->dispatcher->dispatch(
new Test\PhpWarningTriggered(
Expand All @@ -870,6 +875,7 @@ public function testTriggeredPhpWarning(Code\Test $test, string $message, string
$file,
$line,
$suppressed,
$ignoredByBaseline,
),
);
}
Expand Down
12 changes: 6 additions & 6 deletions src/Event/Emitter/Emitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,19 @@ public function testSkipped(Code\Test $test, string $message): void;

public function testTriggeredPhpunitDeprecation(Code\Test $test, string $message): void;

public function testTriggeredPhpDeprecation(Code\Test $test, string $message, string $file, int $line, bool $suppressed): void;
public function testTriggeredPhpDeprecation(Code\Test $test, string $message, string $file, int $line, bool $suppressed, bool $ignoredByBaseline): void;

public function testTriggeredDeprecation(Code\Test $test, string $message, string $file, int $line, bool $suppressed): void;
public function testTriggeredDeprecation(Code\Test $test, string $message, string $file, int $line, bool $suppressed, bool $ignoredByBaseline): void;

public function testTriggeredError(Code\Test $test, string $message, string $file, int $line, bool $suppressed): void;

public function testTriggeredNotice(Code\Test $test, string $message, string $file, int $line, bool $suppressed): void;
public function testTriggeredNotice(Code\Test $test, string $message, string $file, int $line, bool $suppressed, bool $ignoredByBaseline): void;

public function testTriggeredPhpNotice(Code\Test $test, string $message, string $file, int $line, bool $suppressed): void;
public function testTriggeredPhpNotice(Code\Test $test, string $message, string $file, int $line, bool $suppressed, bool $ignoredByBaseline): void;

public function testTriggeredWarning(Code\Test $test, string $message, string $file, int $line, bool $suppressed): void;
public function testTriggeredWarning(Code\Test $test, string $message, string $file, int $line, bool $suppressed, bool $ignoredByBaseline): void;

public function testTriggeredPhpWarning(Code\Test $test, string $message, string $file, int $line, bool $suppressed): void;
public function testTriggeredPhpWarning(Code\Test $test, string $message, string $file, int $line, bool $suppressed, bool $ignoredByBaseline): void;

public function testTriggeredPhpunitError(Code\Test $test, string $message): void;

Expand Down
31 changes: 23 additions & 8 deletions src/Event/Events/Test/Issue/DeprecationTriggered.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,22 @@ final class DeprecationTriggered implements Event
*/
private readonly int $line;
private readonly bool $suppressed;
private readonly bool $ignoredByBaseline;

/**
* @psalm-param non-empty-string $message
* @psalm-param non-empty-string $file
* @psalm-param positive-int $line
*/
public function __construct(Telemetry\Info $telemetryInfo, Test $test, string $message, string $file, int $line, bool $suppressed)
public function __construct(Telemetry\Info $telemetryInfo, Test $test, string $message, string $file, int $line, bool $suppressed, bool $ignoredByBaseline)
{
$this->telemetryInfo = $telemetryInfo;
$this->test = $test;
$this->message = $message;
$this->file = $file;
$this->line = $line;
$this->suppressed = $suppressed;
$this->telemetryInfo = $telemetryInfo;
$this->test = $test;
$this->message = $message;
$this->file = $file;
$this->line = $line;
$this->suppressed = $suppressed;
$this->ignoredByBaseline = $ignoredByBaseline;
}

public function telemetryInfo(): Telemetry\Info
Expand Down Expand Up @@ -95,6 +97,11 @@ public function wasSuppressed(): bool
return $this->suppressed;
}

public function ignoredByBaseline(): bool
{
return $this->ignoredByBaseline;
}

public function asString(): string
{
$message = $this->message;
Expand All @@ -103,9 +110,17 @@ public function asString(): string
$message = PHP_EOL . $message;
}

$status = '';

if ($this->ignoredByBaseline) {
$status = 'Baseline-Ignored ';
} elseif ($this->suppressed) {
$status = 'Suppressed ';
}

return sprintf(
'Test Triggered %sDeprecation (%s)%s',
$this->wasSuppressed() ? 'Suppressed ' : '',
$status,
$this->test->id(),
$message,
);
Expand Down
31 changes: 23 additions & 8 deletions src/Event/Events/Test/Issue/NoticeTriggered.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,22 @@ final class NoticeTriggered implements Event
*/
private readonly int $line;
private readonly bool $suppressed;
private readonly bool $ignoredByBaseline;

/**
* @psalm-param non-empty-string $message
* @psalm-param non-empty-string $file
* @psalm-param positive-int $line
*/
public function __construct(Telemetry\Info $telemetryInfo, Test $test, string $message, string $file, int $line, bool $suppressed)
public function __construct(Telemetry\Info $telemetryInfo, Test $test, string $message, string $file, int $line, bool $suppressed, bool $ignoredByBaseline)
{
$this->telemetryInfo = $telemetryInfo;
$this->test = $test;
$this->message = $message;
$this->file = $file;
$this->line = $line;
$this->suppressed = $suppressed;
$this->telemetryInfo = $telemetryInfo;
$this->test = $test;
$this->message = $message;
$this->file = $file;
$this->line = $line;
$this->suppressed = $suppressed;
$this->ignoredByBaseline = $ignoredByBaseline;
}

public function telemetryInfo(): Telemetry\Info
Expand Down Expand Up @@ -95,6 +97,11 @@ public function wasSuppressed(): bool
return $this->suppressed;
}

public function ignoredByBaseline(): bool
{
return $this->ignoredByBaseline;
}

public function asString(): string
{
$message = $this->message;
Expand All @@ -103,9 +110,17 @@ public function asString(): string
$message = PHP_EOL . $message;
}

$status = '';

if ($this->ignoredByBaseline) {
$status = 'Baseline-Ignored ';
} elseif ($this->suppressed) {
$status = 'Suppressed ';
}

return sprintf(
'Test Triggered %sNotice (%s)%s',
$this->wasSuppressed() ? 'Suppressed ' : '',
$status,
$this->test->id(),
$message,
);
Expand Down
31 changes: 23 additions & 8 deletions src/Event/Events/Test/Issue/PhpDeprecationTriggered.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,22 @@ final class PhpDeprecationTriggered implements Event
*/
private readonly int $line;
private readonly bool $suppressed;
private readonly bool $ignoredByBaseline;

/**
* @psalm-param non-empty-string $message
* @psalm-param non-empty-string $file
* @psalm-param positive-int $line
*/
public function __construct(Telemetry\Info $telemetryInfo, Test $test, string $message, string $file, int $line, bool $suppressed)
public function __construct(Telemetry\Info $telemetryInfo, Test $test, string $message, string $file, int $line, bool $suppressed, bool $ignoredByBaseline)
{
$this->telemetryInfo = $telemetryInfo;
$this->test = $test;
$this->message = $message;
$this->file = $file;
$this->line = $line;
$this->suppressed = $suppressed;
$this->telemetryInfo = $telemetryInfo;
$this->test = $test;
$this->message = $message;
$this->file = $file;
$this->line = $line;
$this->suppressed = $suppressed;
$this->ignoredByBaseline = $ignoredByBaseline;
}

public function telemetryInfo(): Telemetry\Info
Expand Down Expand Up @@ -95,6 +97,11 @@ public function wasSuppressed(): bool
return $this->suppressed;
}

public function ignoredByBaseline(): bool
{
return $this->ignoredByBaseline;
}

public function asString(): string
{
$message = $this->message;
Expand All @@ -103,9 +110,17 @@ public function asString(): string
$message = PHP_EOL . $message;
}

$status = '';

if ($this->ignoredByBaseline) {
$status = 'Baseline-Ignored ';
} elseif ($this->suppressed) {
$status = 'Suppressed ';
}

return sprintf(
'Test Triggered %sPHP Deprecation (%s)%s',
$this->wasSuppressed() ? 'Suppressed ' : '',
$status,
$this->test->id(),
$message,
);
Expand Down
Loading

0 comments on commit a58a6a2

Please sign in to comment.