Skip to content

Commit 3d3fded

Browse files
committed
Merge tbranch '5.4' into 6.0
* 5.4: [Bridge] Corrects bug in test listener trait
2 parents 2e41734 + 102da63 commit 3d3fded

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

Legacy/SymfonyTestsListenerTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public function endTest($test, $time)
271271
$assertions = \count(self::$expectedDeprecations) + $test->getNumAssertions();
272272
if ($test->doesNotPerformAssertions() && $assertions > 0) {
273273
$test->getTestResultObject()->addFailure($test, new RiskyTestError(sprintf('This test is annotated with "@doesNotPerformAssertions", but performed %s assertions', $assertions)), $time);
274-
} elseif ($assertions === 0 && $test->getTestResultObject()->noneSkipped()) {
274+
} elseif ($assertions === 0 && !$test->doesNotPerformAssertions() && $test->getTestResultObject()->noneSkipped()) {
275275
$test->getTestResultObject()->addFailure($test, new RiskyTestError('This test did not perform any assertions'), $time);
276276
}
277277

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\PhpUnit\Tests\FailTests;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
16+
17+
/**
18+
* This class is deliberately suffixed with *TestRisky.php so that it is ignored
19+
* by PHPUnit. This test is designed to fail. See ../expectnotrisky.phpt.
20+
*/
21+
final class NoAssertionsTestNotRisky extends TestCase
22+
{
23+
use ExpectDeprecationTrait;
24+
25+
/**
26+
* Do not remove this test in the next major version.
27+
*/
28+
public function testOne()
29+
{
30+
$this->expectNotToPerformAssertions();
31+
}
32+
}

Tests/expectnotrisky.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Test NoAssertionsTestNotRisky not risky test
3+
--SKIPIF--
4+
<?php if ('\\' === DIRECTORY_SEPARATOR && !extension_loaded('mbstring')) die('Skipping on Windows without mbstring');
5+
--FILE--
6+
<?php
7+
$test = realpath(__DIR__.'/FailTests/NoAssertionsTestNotRisky.php');
8+
passthru('php '.getenv('SYMFONY_SIMPLE_PHPUNIT_BIN_DIR').'/simple-phpunit.php --fail-on-risky --colors=never '.$test);
9+
?>
10+
--EXPECTF--
11+
PHPUnit %s
12+
13+
%ATesting Symfony\Bridge\PhpUnit\Tests\FailTests\NoAssertionsTestNotRisky
14+
. 1 / 1 (100%)
15+
16+
Time: %s, Memory: %s
17+
18+
OK (1 test, 0 assertions)

0 commit comments

Comments
 (0)