Skip to content

Commit 7e96a3c

Browse files
Merge branch '11.5' into 12.0
2 parents 1974eee + fc52a09 commit 7e96a3c

File tree

6 files changed

+72
-16
lines changed

6 files changed

+72
-16
lines changed

ChangeLog-12.0.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 12.0 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
44

5+
## [12.0.6] - 2025-MM-DD
6+
7+
### Fixed
8+
9+
* [#6142](https://github.com/sebastianbergmann/phpunit/issues/6142): `$expected` and `$actual` are mixed up in failure description when `assertJsonFileEqualsJsonFile()` fails
10+
511
## [12.0.5] - 2025-02-25
612

713
### Fixed
@@ -86,6 +92,7 @@ All notable changes of the PHPUnit 12.0 release series are documented in this fi
8692
* [#5801](https://github.com/sebastianbergmann/phpunit/issues/5801): Support for targeting traits with `#[CoversClass]` and `#[UsesClass]` attributes
8793
* [#5978](https://github.com/sebastianbergmann/phpunit/issues/5978): Support for PHP 8.2
8894

95+
[12.0.6]: https://github.com/sebastianbergmann/phpunit/compare/12.0.5...12.0
8996
[12.0.5]: https://github.com/sebastianbergmann/phpunit/compare/12.0.4...12.0.5
9097
[12.0.4]: https://github.com/sebastianbergmann/phpunit/compare/12.0.3...12.0.4
9198
[12.0.3]: https://github.com/sebastianbergmann/phpunit/compare/12.0.2...12.0.3

src/Framework/Assert.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2675,14 +2675,7 @@ final public static function assertJsonFileEqualsJsonFile(string $expectedFile,
26752675
self::assertIsString($actualJson);
26762676
self::assertJson($actualJson, $message);
26772677

2678-
$constraintExpected = new JsonMatches(
2679-
$expectedJson,
2680-
);
2681-
2682-
$constraintActual = new JsonMatches($actualJson);
2683-
2684-
self::assertThat($expectedJson, $constraintActual, $message);
2685-
self::assertThat($actualJson, $constraintExpected, $message);
2678+
self::assertThat($actualJson, new JsonMatches($expectedJson), $message);
26862679
}
26872680

26882681
/**
@@ -2706,14 +2699,7 @@ final public static function assertJsonFileNotEqualsJsonFile(string $expectedFil
27062699
self::assertIsString($actualJson);
27072700
self::assertJson($actualJson, $message);
27082701

2709-
$constraintExpected = new JsonMatches(
2710-
$expectedJson,
2711-
);
2712-
2713-
$constraintActual = new JsonMatches($actualJson);
2714-
2715-
self::assertThat($expectedJson, new LogicalNot($constraintActual), $message);
2716-
self::assertThat($actualJson, new LogicalNot($constraintExpected), $message);
2702+
self::assertThat($actualJson, LogicalNot(new JsonMatches($expectedJson)), $message);
27172703
}
27182704

27192705
/**

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
https://github.com/sebastianbergmann/phpunit/issues/6142
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = __DIR__ . '/6142/Issue6142Test.php';
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+
17+
F 1 / 1 (100%)
18+
19+
Time: %s, Memory: %s
20+
21+
There was 1 failure:
22+
23+
1) PHPUnit\TestFixture\Issue6142\Issue6142Test::testOne
24+
Failed asserting that '{"key": false}\n
25+
' matches JSON string "{"key": true}
26+
".
27+
--- Expected
28+
+++ Actual
29+
@@ @@
30+
{
31+
- "key": true
32+
+ "key": false
33+
}
34+
35+
%sIssue6142Test.php:%d
36+
37+
FAILURES!
38+
Tests: 1, Assertions: 7, Failures: 1.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
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\Issue6142;
11+
12+
use PHPUnit\Framework\TestCase;
13+
14+
final class Issue6142Test extends TestCase
15+
{
16+
public function testOne(): void
17+
{
18+
$expected = __DIR__ . '/expected.json';
19+
$actual = __DIR__ . '/actual.json';
20+
21+
$this->assertJsonFileEqualsJsonFile($expected, $actual);
22+
}
23+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"key": false}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"key": true}

0 commit comments

Comments
 (0)