Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: symfony/phpunit-bridge
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v7.1.6
Choose a base ref
...
head repository: symfony/phpunit-bridge
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v7.2.0-BETA1
Choose a head ref
  • 17 commits
  • 33 files changed
  • 9 contributors

Commits on Jun 20, 2024

  1. Prefix all sprintf() calls

    derrabus committed Jun 20, 2024
    Copy the full SHA
    d4c5787 View commit details

Commits on Jun 25, 2024

  1. Merge branch '7.1' into 7.2

    * 7.1: (31 commits)
      [DependencyInjection] Fix phpdoc for $calls
      [Security] check token in payload instead just request
      fix tests
      add missing method
      fix merge
      fix test
      fix merge
      fix test
      change test to use a real ObjectManager
      [Mailer] Document the usage of custom headers in Infobip bridge
      [SecurityBundle] Add `provider` XML attribute to the authenticators it’s missing from
      [DoctrineBridge] Test reset with a true manager
      Sync php-cs-fixer config file with 7.2
      [HttpClient] Fix parsing SSE
      [Notifier] Fix thread key in GoogleChat bridge
      [HttpKernel][Security] Fix accessing session for stateless request
      [Serializer] Fix `ObjectNormalizer` with property path
      test handling of special "value" constraint option
      [PhpUnitBridge] Add missing import
      [FrameworkBundle] Fix setting default context for certain normalizers
      ...
    xabbuh committed Jun 25, 2024
    Copy the full SHA
    a09ae68 View commit details

Commits on Jul 1, 2024

  1. Copy the full SHA
    7963168 View commit details

Commits on Jul 6, 2024

  1. Update .gitattributes

    fabpot committed Jul 6, 2024
    Copy the full SHA
    5b396e1 View commit details

Commits on Jul 22, 2024

  1. Copy the full SHA
    ca07fb9 View commit details

Commits on Jul 26, 2024

  1. Merge branch '7.1' into 7.2

    * 7.1:
      Fix ProcessTest - testIgnoringSignal for local
      [Console][PhpUnitBridge][VarDumper] Fix `NO_COLOR` empty value handling
      [Translation] Fix CSV escape char in `CsvFileLoader` on PHP >= 7.4
      [DoctrineBridge] fix messenger bus dispatch inside an active transaction
      [HttpFoundation] Add tests for uncovered sections
      treat uninitialized properties referenced by property paths as null
      [PropertyInfo] Check if property is nullable when using `ReflectionExtractor`
      properly set up constraint options
      [ErrorHandler][VarDumper] Remove PHP 8.4 deprecations
      move adding detailed JSON error messages to the validate phase
      [Profiler] Add word wrap in tables in dialog to see all the text
      [Core] Fix & Enhance security arabic translation.
      [HttpFoundation] Add tests for `MethodRequestMatcher` and `SchemeRequestMatcher`
    nicolas-grekas committed Jul 26, 2024
    Copy the full SHA
    46827fe View commit details

Commits on Aug 2, 2024

  1. Copy the full SHA
    6cc75e5 View commit details

Commits on Aug 5, 2024

  1. Copy the full SHA
    c085e7a View commit details

Commits on Aug 13, 2024

  1. Copy the full SHA
    ed42358 View commit details
  2. feature #57777 [VarDumper] Add support for FORCE_COLOR environment …

    …variable (artshade)
    
    This PR was squashed before being merged into the 7.2 branch.
    
    Discussion
    ----------
    
    [VarDumper] Add support for `FORCE_COLOR` environment variable
    
    | Q             | A
    | ------------- | ---
    | Branch?       | 7.2
    | Bug fix?      | no
    | New feature?  | yes
    | Deprecations? | no
    | Issues        |
    | License       | MIT
    
    Commits
    -------
    
    5b545240c6 [PhpUnitBridge][Console][VarDumper] Add support for `FORCE_COLOR` environment variable
    nicolas-grekas committed Aug 13, 2024
    Copy the full SHA
    ee553bc View commit details
  3. Merge branch '7.1' into 7.2

    * 7.1:
      Replace external FTP server by a local docker instance
      [PhpUnitBridge][Console][VarDumper] Fix handling NO_COLOR env var
      fix test
      [Validator] Add test for `D` regex modifier in `TimeValidator`
    nicolas-grekas committed Aug 13, 2024
    Copy the full SHA
    89a9cb1 View commit details

Commits on Sep 1, 2024

  1. CS: re-apply trailing_comma_in_multiline

    keradus authored and xabbuh committed Sep 1, 2024
    Copy the full SHA
    d8e704a View commit details

Commits on Sep 19, 2024

  1. Copy the full SHA
    f0c3d51 View commit details

Commits on Sep 25, 2024

  1. Merge branch '7.1' into 7.2

    * 7.1:
      Add PR template and auto-close PR on subtree split repositories
    nicolas-grekas committed Sep 25, 2024
    Copy the full SHA
    3363287 View commit details

Commits on Oct 21, 2024

  1. Copy the full SHA
    676fcfa View commit details

Commits on Oct 22, 2024

  1. do not patch the TestCase class with PHPUnit 11+

    The PHPUnit\TextUI\Command class was removed in PHPUnit 10. Since the sole
    purpose of the class extended the base Command class is to register a the
    Symfony test listener we can completely stop patching it as support for the
    listener-based event system was also removed in PHPUnit 10.
    xabbuh committed Oct 22, 2024
    Copy the full SHA
    2faee18 View commit details

Commits on Oct 23, 2024

  1. Copy the full SHA
    078398e View commit details
Showing with 932 additions and 34 deletions.
  1. +7 −0 CHANGELOG.md
  2. +2 −2 ClockMock.php
  3. +9 −4 DeprecationErrorHandler.php
  4. +8 −8 DeprecationErrorHandler/Configuration.php
  5. +1 −3 DeprecationErrorHandler/Deprecation.php
  6. +30 −0 ExpectUserDeprecationMessageTrait.php
  7. +39 −0 Extension/DisableClockMockSubscriber.php
  8. +39 −0 Extension/DisableDnsMockSubscriber.php
  9. +39 −0 Extension/EnableClockMockSubscriber.php
  10. +39 −0 Extension/RegisterClockMockSubscriber.php
  11. +39 −0 Extension/RegisterDnsMockSubscriber.php
  12. +52 −0 SymfonyExtension.php
  13. +3 −0 Tests/CoverageListenerTest.php
  14. +4 −1 Tests/DeprecationErrorHandler/ConfigurationTest.php
  15. +3 −1 Tests/DeprecationErrorHandler/log_file.phpt
  16. +3 −0 Tests/ExpectDeprecationTraitTest.php
  17. +3 −0 Tests/ExpectedDeprecationAnnotationTest.php
  18. +2 −0 Tests/FailTests/ExpectDeprecationTraitTestFail.php
  19. +2 −0 Tests/FailTests/NoAssertionsTestNotRisky.php
  20. +2 −0 Tests/FailTests/NoAssertionsTestRisky.php
  21. +29 −0 Tests/Fixtures/symfonyextension/phpunit-with-extension.xml.dist
  22. +22 −0 Tests/Fixtures/symfonyextension/phpunit-without-extension.xml.dist
  23. +16 −0 Tests/Fixtures/symfonyextension/src/ClassExtendingFinalClass.php
  24. +19 −0 Tests/Fixtures/symfonyextension/src/FinalClass.php
  25. +34 −0 Tests/Fixtures/symfonyextension/tests/bootstrap.php
  26. +2 −0 Tests/ProcessIsolationTest.php
  27. +140 −0 Tests/SymfonyExtension.php
  28. +2 −0 Tests/expectdeprecationfail.phpt
  29. +3 −1 Tests/expectnotrisky.phpt
  30. +3 −1 Tests/expectrisky.phpt
  31. +19 −0 Tests/symfonyextension.phpt
  32. +296 −0 Tests/symfonyextensionnotregistered.phpt
  33. +21 −13 bin/simple-phpunit.php
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
CHANGELOG
=========

7.2
---

* Add a PHPUnit extension that registers the clock mock and DNS mock and the `DebugClassLoader` from the ErrorHandler component if present
* Add `ExpectUserDeprecationMessageTrait` with a polyfill of PHPUnit's `expectUserDeprecationMessage()`
* Use `total` for asserting deprecation count when a group is not defined

6.4
---

4 changes: 2 additions & 2 deletions ClockMock.php
Original file line number Diff line number Diff line change
@@ -72,7 +72,7 @@ public static function microtime($asFloat = false)
return self::$now;
}

return sprintf('%0.6f00 %d', self::$now - (int) self::$now, (int) self::$now);
return \sprintf('%0.6f00 %d', self::$now - (int) self::$now, (int) self::$now);
}

public static function date($format, $timestamp = null): string
@@ -101,7 +101,7 @@ public static function hrtime($asNumber = false)
$ns = (self::$now - (int) self::$now) * 1000000000;

if ($asNumber) {
$number = sprintf('%d%d', (int) self::$now, $ns);
$number = \sprintf('%d%d', (int) self::$now, $ns);

return \PHP_INT_SIZE === 8 ? (int) $number : (float) $number;
}
13 changes: 9 additions & 4 deletions DeprecationErrorHandler.php
Original file line number Diff line number Diff line change
@@ -301,15 +301,15 @@ private function displayDeprecations(array $groups, Configuration $configuration

if ($configuration->shouldWriteToLogFile()) {
if (false === $handle = @fopen($file = $configuration->getLogFile(), 'a')) {
throw new \InvalidArgumentException(sprintf('The configured log file "%s" is not writeable.', $file));
throw new \InvalidArgumentException(\sprintf('The configured log file "%s" is not writeable.', $file));
}
} else {
$handle = fopen('php://output', 'w');
}

foreach ($groups as $group) {
if ($this->deprecationGroups[$group]->count()) {
$deprecationGroupMessage = sprintf(
$deprecationGroupMessage = \sprintf(
'%s deprecation notices (%d)',
\in_array($group, ['direct', 'indirect', 'self'], true) ? "Remaining $group" : ucfirst($group),
$this->deprecationGroups[$group]->count()
@@ -328,7 +328,7 @@ private function displayDeprecations(array $groups, Configuration $configuration
uasort($notices, $cmp);

foreach ($notices as $msg => $notice) {
fwrite($handle, sprintf("\n %sx: %s\n", $notice->count(), $msg));
fwrite($handle, \sprintf("\n %sx: %s\n", $notice->count(), $msg));

$countsByCaller = $notice->getCountsByCaller();
arsort($countsByCaller);
@@ -340,7 +340,7 @@ private function displayDeprecations(array $groups, Configuration $configuration
fwrite($handle, " ...\n");
break;
}
fwrite($handle, sprintf(" %dx in %s\n", $count, preg_replace('/(.*)\\\\(.*?::.*?)$/', '$2 from $1', $method)));
fwrite($handle, \sprintf(" %dx in %s\n", $count, preg_replace('/(.*)\\\\(.*?::.*?)$/', '$2 from $1', $method)));
}
}
}
@@ -411,6 +411,11 @@ private static function hasColorSupport(): bool
return false;
}

// Follow https://force-color.org/
if ('' !== (($_SERVER['FORCE_COLOR'] ?? getenv('FORCE_COLOR'))[0] ?? '')) {
return true;
}

// Detect msysgit/mingw and assume this is a tty because detection
// does not work correctly, see https://github.com/composer/composer/issues/9690
if (!@stream_isatty(\STDOUT) && !\in_array(strtoupper((string) getenv('MSYSTEM')), ['MINGW32', 'MINGW64'], true)) {
16 changes: 8 additions & 8 deletions DeprecationErrorHandler/Configuration.php
Original file line number Diff line number Diff line change
@@ -76,10 +76,10 @@ private function __construct(array $thresholds = [], string $regex = '', array $

foreach ($thresholds as $group => $threshold) {
if (!\in_array($group, $groups, true)) {
throw new \InvalidArgumentException(sprintf('Unrecognized threshold "%s", expected one of "%s".', $group, implode('", "', $groups)));
throw new \InvalidArgumentException(\sprintf('Unrecognized threshold "%s", expected one of "%s".', $group, implode('", "', $groups)));
}
if (!is_numeric($threshold)) {
throw new \InvalidArgumentException(sprintf('Threshold for group "%s" has invalid value "%s".', $group, $threshold));
throw new \InvalidArgumentException(\sprintf('Threshold for group "%s" has invalid value "%s".', $group, $threshold));
}
$this->thresholds[$group] = (int) $threshold;
}
@@ -96,7 +96,7 @@ private function __construct(array $thresholds = [], string $regex = '', array $
}
foreach ($groups as $group) {
if (!isset($this->thresholds[$group])) {
$this->thresholds[$group] = 999999;
$this->thresholds[$group] = $this->thresholds['total'] ?? 999999;
}
}
$this->regex = $regex;
@@ -111,17 +111,17 @@ private function __construct(array $thresholds = [], string $regex = '', array $

foreach ($verboseOutput as $group => $status) {
if (!isset($this->verboseOutput[$group])) {
throw new \InvalidArgumentException(sprintf('Unsupported verbosity group "%s", expected one of "%s".', $group, implode('", "', array_keys($this->verboseOutput))));
throw new \InvalidArgumentException(\sprintf('Unsupported verbosity group "%s", expected one of "%s".', $group, implode('", "', array_keys($this->verboseOutput))));
}
$this->verboseOutput[$group] = $status;
}

if ($ignoreFile) {
if (!is_file($ignoreFile)) {
throw new \InvalidArgumentException(sprintf('The ignoreFile "%s" does not exist.', $ignoreFile));
throw new \InvalidArgumentException(\sprintf('The ignoreFile "%s" does not exist.', $ignoreFile));
}
set_error_handler(static function ($t, $m) use ($ignoreFile, &$line) {
throw new \RuntimeException(sprintf('Invalid pattern found in "%s" on line "%d"', $ignoreFile, 1 + $line).substr($m, 12));
throw new \RuntimeException(\sprintf('Invalid pattern found in "%s" on line "%d"', $ignoreFile, 1 + $line).substr($m, 12));
});
try {
foreach (file($ignoreFile) as $line => $pattern) {
@@ -147,7 +147,7 @@ private function __construct(array $thresholds = [], string $regex = '', array $
$this->baselineDeprecations[$baseline_deprecation->location][$baseline_deprecation->message] = $baseline_deprecation->count;
}
} else {
throw new \InvalidArgumentException(sprintf('The baselineFile "%s" does not exist.', $this->baselineFile));
throw new \InvalidArgumentException(\sprintf('The baselineFile "%s" does not exist.', $this->baselineFile));
}
}

@@ -312,7 +312,7 @@ public static function fromUrlEncodedString(string $serializedConfiguration): se
parse_str($serializedConfiguration, $normalizedConfiguration);
foreach (array_keys($normalizedConfiguration) as $key) {
if (!\in_array($key, ['max', 'disabled', 'verbose', 'quiet', 'ignoreFile', 'generateBaseline', 'baselineFile', 'logFile'], true)) {
throw new \InvalidArgumentException(sprintf('Unknown configuration option "%s".', $key));
throw new \InvalidArgumentException(\sprintf('Unknown configuration option "%s".', $key));
}
}

4 changes: 1 addition & 3 deletions DeprecationErrorHandler/Deprecation.php
Original file line number Diff line number Diff line change
@@ -149,8 +149,6 @@ public function __construct(string $message, array $trace, string $file, bool $l
if (($test instanceof TestCase || $test instanceof TestSuite) && ('trigger_error' !== $trace[$i - 2]['function'] || isset($trace[$i - 2]['class']))) {
$this->originClass = \get_class($test);
$this->originMethod = $test->getName();

return;
}
}

@@ -313,7 +311,7 @@ private function getPackage(string $path): string
}
}

throw new \RuntimeException(sprintf('No vendors found for path "%s".', $path));
throw new \RuntimeException(\sprintf('No vendors found for path "%s".', $path));
}

/**
30 changes: 30 additions & 0 deletions ExpectUserDeprecationMessageTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bridge\PhpUnit;

use PHPUnit\Runner\Version;

if (version_compare(Version::id(), '11.0.0', '<')) {
trait ExpectUserDeprecationMessageTrait
{
use ExpectDeprecationTrait;

final protected function expectUserDeprecationMessage(string $expectedUserDeprecationMessage): void
{
$this->expectDeprecation(str_replace('%', '%%', $expectedUserDeprecationMessage));
}
}
} else {
trait ExpectUserDeprecationMessageTrait
{
}
}
39 changes: 39 additions & 0 deletions Extension/DisableClockMockSubscriber.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bridge\PhpUnit\Extension;

use PHPUnit\Event\Code\TestMethod;
use PHPUnit\Event\Test\Finished;
use PHPUnit\Event\Test\FinishedSubscriber;
use PHPUnit\Metadata\Group;
use Symfony\Bridge\PhpUnit\ClockMock;

/**
* @internal
*/
class DisableClockMockSubscriber implements FinishedSubscriber
{
public function notify(Finished $event): void
{
$test = $event->test();

if (!$test instanceof TestMethod) {
return;
}

foreach ($test->metadata() as $metadata) {
if ($metadata instanceof Group && 'time-sensitive' === $metadata->groupName()) {
ClockMock::withClockMock(false);
}
}
}
}
39 changes: 39 additions & 0 deletions Extension/DisableDnsMockSubscriber.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bridge\PhpUnit\Extension;

use PHPUnit\Event\Code\TestMethod;
use PHPUnit\Event\Test\Finished;
use PHPUnit\Event\Test\FinishedSubscriber;
use PHPUnit\Metadata\Group;
use Symfony\Bridge\PhpUnit\DnsMock;

/**
* @internal
*/
class DisableDnsMockSubscriber implements FinishedSubscriber
{
public function notify(Finished $event): void
{
$test = $event->test();

if (!$test instanceof TestMethod) {
return;
}

foreach ($test->metadata() as $metadata) {
if ($metadata instanceof Group && 'dns-sensitive' === $metadata->groupName()) {
DnsMock::withMockedHosts([]);
}
}
}
}
39 changes: 39 additions & 0 deletions Extension/EnableClockMockSubscriber.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bridge\PhpUnit\Extension;

use PHPUnit\Event\Code\TestMethod;
use PHPUnit\Event\Test\PreparationStarted;
use PHPUnit\Event\Test\PreparationStartedSubscriber;
use PHPUnit\Metadata\Group;
use Symfony\Bridge\PhpUnit\ClockMock;

/**
* @internal
*/
class EnableClockMockSubscriber implements PreparationStartedSubscriber
{
public function notify(PreparationStarted $event): void
{
$test = $event->test();

if (!$test instanceof TestMethod) {
return;
}

foreach ($test->metadata() as $metadata) {
if ($metadata instanceof Group && 'time-sensitive' === $metadata->groupName()) {
ClockMock::withClockMock(true);
}
}
}
}
39 changes: 39 additions & 0 deletions Extension/RegisterClockMockSubscriber.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bridge\PhpUnit\Extension;

use PHPUnit\Event\Code\TestMethod;
use PHPUnit\Event\TestSuite\Loaded;
use PHPUnit\Event\TestSuite\LoadedSubscriber;
use PHPUnit\Metadata\Group;
use Symfony\Bridge\PhpUnit\ClockMock;

/**
* @internal
*/
class RegisterClockMockSubscriber implements LoadedSubscriber
{
public function notify(Loaded $event): void
{
foreach ($event->testSuite()->tests() as $test) {
if (!$test instanceof TestMethod) {
continue;
}

foreach ($test->metadata() as $metadata) {
if ($metadata instanceof Group && 'time-sensitive' === $metadata->groupName()) {
ClockMock::register($test->className());
}
}
}
}
}
39 changes: 39 additions & 0 deletions Extension/RegisterDnsMockSubscriber.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bridge\PhpUnit\Extension;

use PHPUnit\Event\Code\TestMethod;
use PHPUnit\Event\TestSuite\Loaded;
use PHPUnit\Event\TestSuite\LoadedSubscriber;
use PHPUnit\Metadata\Group;
use Symfony\Bridge\PhpUnit\DnsMock;

/**
* @internal
*/
class RegisterDnsMockSubscriber implements LoadedSubscriber
{
public function notify(Loaded $event): void
{
foreach ($event->testSuite()->tests() as $test) {
if (!$test instanceof TestMethod) {
continue;
}

foreach ($test->metadata() as $metadata) {
if ($metadata instanceof Group && 'dns-sensitive' === $metadata->groupName()) {
DnsMock::register($test->className());
}
}
}
}
}
Loading