Skip to content

Commit c20c85f

Browse files
1 parent 793693f commit c20c85f

File tree

6 files changed

+89
-0
lines changed

6 files changed

+89
-0
lines changed

ChangeLog-11.1.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

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

5+
## [11.1.2] - 2024-MM-DD
6+
7+
### Fixed
8+
9+
* [#5807](https://github.com/sebastianbergmann/phpunit/issues/5807): The `#[CoversMethod]` attribute is not considered for risky test check
10+
511
## [11.1.1] - 2024-04-06
612

713
### Fixed
@@ -32,5 +38,6 @@ All notable changes of the PHPUnit 11.1 release series are documented in this fi
3238
* [#5689](https://github.com/sebastianbergmann/phpunit/issues/5689): The `restrictDeprecations` attribute on the `<source>` element of the XML configuration file is now deprecated in favor of the `ignoreSelfDeprecations`, `ignoreDirectDeprecations`, and `ignoreIndirectDeprecations` attributes
3339
* [#5709](https://github.com/sebastianbergmann/phpunit/issues/5709): Deprecate support for using comma-separated values with the `--group`, `--exclude-group`, `--covers`, `--uses`, and `--test-suffix` CLI options
3440

41+
[11.1.2]: https://github.com/sebastianbergmann/phpunit/compare/11.1.1...11.1
3542
[11.1.1]: https://github.com/sebastianbergmann/phpunit/compare/11.1.0...11.1.1
3643
[11.1.0]: https://github.com/sebastianbergmann/phpunit/compare/11.0.10...11.1.0

src/Framework/TestRunner.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,10 @@ private function hasCoverageMetadata(string $className, string $methodName): boo
359359
return true;
360360
}
361361

362+
if ($metadata->isCoversMethod()->isNotEmpty()) {
363+
return true;
364+
}
365+
362366
if ($metadata->isCoversFunction()->isNotEmpty()) {
363367
return true;
364368
}

tests/end-to-end/regression/5807.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/issues/5807
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--configuration';
7+
$_SERVER['argv'][] = __DIR__ . '/5807/phpunit.xml';
8+
9+
require_once __DIR__ . '/../../bootstrap.php';
10+
11+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
12+
--EXPECTF--
13+
PHPUnit %s by Sebastian Bergmann and contributors.
14+
15+
Runtime: %s
16+
Configuration: %s
17+
18+
. 1 / 1 (100%)
19+
20+
Time: %s, Memory: %s
21+
22+
OK (1 test, 1 assertion)
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+
requireCoverageMetadata="true">
5+
<testsuites>
6+
<testsuite name="default">
7+
<directory>tests</directory>
8+
</testsuite>
9+
</testsuites>
10+
11+
<source>
12+
<include>
13+
<directory>src</directory>
14+
</include>
15+
</source>
16+
</phpunit>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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\Issue5807;
11+
12+
final class Greeter
13+
{
14+
public function greet(): string
15+
{
16+
return 'Hello world!';
17+
}
18+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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\Issue5807;
11+
12+
use PHPUnit\Framework\Attributes\CoversMethod;
13+
use PHPUnit\Framework\TestCase;
14+
15+
#[CoversMethod(Greeter::class, 'greet')]
16+
final class GreeterTest extends TestCase
17+
{
18+
public function testGreets(): void
19+
{
20+
$this->assertSame('Hello world!', (new Greeter)->greet());
21+
}
22+
}

0 commit comments

Comments
 (0)