Skip to content

Commit

Permalink
Closes #5351
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastian Bergmann <sb@sebastian-bergmann.de>
Co-authored-by: Arne Blankerts <Arne@Blankerts.de>
Co-authored-by: Andreas Möller <am@localheinz.com>
Co-authored-by: Sebastian Heuer <sebastian@phpeople.de>
Co-authored-by: Fabian Blechschmidt <blechschmidt@fabian-blechschmidt.de>
Co-authored-by: Frank Sons <frank.sons@code-quality.de>
  • Loading branch information
6 people committed Mar 9, 2024
1 parent 41a9886 commit b5d1fe7
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ChangeLog-10.5.md
Expand Up @@ -2,6 +2,10 @@

All notable changes of the PHPUnit 10.5 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.

## [10.5.13] - 2024-MM-DD

* [#5351](https://github.com/sebastianbergmann/phpunit/issues/5351): Incorrect code coverage metadata does not prevent code coverage data from being collected

## [10.5.12] - 2024-03-09

### Fixed
Expand Down Expand Up @@ -131,6 +135,7 @@ All notable changes of the PHPUnit 10.5 release series are documented in this fi

* [#5563](https://github.com/sebastianbergmann/phpunit/issues/5563): `createMockForIntersectionOfInterfaces()` does not automatically register mock object for expectation verification

[10.5.13]: https://github.com/sebastianbergmann/phpunit/compare/10.5.12...10.5
[10.5.12]: https://github.com/sebastianbergmann/phpunit/compare/10.5.11...10.5.12
[10.5.11]: https://github.com/sebastianbergmann/phpunit/compare/10.5.10...10.5.11
[10.5.10]: https://github.com/sebastianbergmann/phpunit/compare/10.5.9...10.5.10
Expand Down
2 changes: 2 additions & 0 deletions src/Framework/TestRunner.php
Expand Up @@ -173,6 +173,8 @@ public function run(TestCase $test): void
$test->valueObjectForEvents(),
$cce->getMessage(),
);

$append = false;
}
}

Expand Down
47 changes: 47 additions & 0 deletions tests/end-to-end/regression/5351.phpt
@@ -0,0 +1,47 @@
--TEST--
https://github.com/sebastianbergmann/phpunit/issues/5351
--INI--
pcov.directory=tests/end-to-end/regression/5351/src/
--SKIPIF--
<?php declare(strict_types=1);
require __DIR__ . '/../../_files/skip-if-requires-code-coverage-driver.php';
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--colors=never';
$_SERVER['argv'][] = '--coverage-text';
$_SERVER['argv'][] = '--configuration';
$_SERVER['argv'][] = __DIR__ . '/5351/phpunit.xml';

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

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

Runtime: %s
Configuration: %s

W 1 / 1 (100%)

Time: %s, Memory: %s MB

1 test triggered 1 PHPUnit warning:

1) PHPUnit\TestFixture\Issue5351\GreeterTest::testGreets
Class "PHPUnit\TestFixture\Issue5351\DoesNotExist" is not a valid target for code coverage

%sGreeterTest.php:18

WARNINGS!
Tests: 1, Assertions: 1, Warnings: 1.


Code Coverage Report:
%s

Summary:
Classes: 0.00% (0/1)
Methods: 0.00% (0/1)
Lines: 0.00% (0/1)

22 changes: 22 additions & 0 deletions tests/end-to-end/regression/5351/phpunit.xml
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../phpunit.xsd"
bootstrap="src/Greeter.php"
executionOrder="depends,defects"
requireCoverageMetadata="true"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
failOnRisky="true"
failOnWarning="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>

<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true">
<include>
<directory>src</directory>
</include>
</source>
</phpunit>
18 changes: 18 additions & 0 deletions tests/end-to-end/regression/5351/src/Greeter.php
@@ -0,0 +1,18 @@
<?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\Issue5351;

final class Greeter
{
public function greet(): string
{
return 'Hello world!';
}
}
22 changes: 22 additions & 0 deletions tests/end-to-end/regression/5351/tests/GreeterTest.php
@@ -0,0 +1,22 @@
<?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\Issue5351;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

#[CoversClass('PHPUnit\TestFixture\Issue5351\DoesNotExist')]
final class GreeterTest extends TestCase
{
public function testGreets(): void
{
$this->assertSame('Hello world!', (new Greeter)->greet());
}
}

0 comments on commit b5d1fe7

Please sign in to comment.