From 1c85f4c98f3b9b206e099a1d3ce0589762f6c5a3 Mon Sep 17 00:00:00 2001 From: soyuka Date: Sun, 16 Aug 2026 20:48:33 +0200 Subject: [PATCH] test(openapi): assert the yaml export structurally, not by key order testExecuteWithYaml matched rendered YAML blocks that assumed operationId came directly after get:. symfony/serializer 8.2.x-dev emits the Operation properties in a different order -- responses first -- so the blocks no longer matched even though every key is present with the same value. Object key order carries no meaning in YAML, so assert the parsed structure for the paths and keep separate string assertions for the formatting this test is actually about: block sequences and inline empty arrays. Verified on symfony/yaml 8.1.2 and 8.2.x-dev. --- tests/OpenApi/Command/OpenApiCommandTest.php | 26 ++++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/tests/OpenApi/Command/OpenApiCommandTest.php b/tests/OpenApi/Command/OpenApiCommandTest.php index 6112badb2d2..a210e9a4eee 100644 --- a/tests/OpenApi/Command/OpenApiCommandTest.php +++ b/tests/OpenApi/Command/OpenApiCommandTest.php @@ -76,27 +76,21 @@ public function testExecuteWithYaml(): void $this->assertYaml($result); - $operationId = 'api_dummy_cars_get_collection'; + // the serializer does not guarantee property order, so assert the structure rather than a + // rendered block, and keep separate assertions for the formatting this test cares about + $parsed = Yaml::parse($result); + + $this->assertSame('api_dummy_cars_get_collection', $parsed['paths']['/dummy_cars']['get']['operationId'], 'nested object should be present.'); + $this->assertSame(['DummyCar'], $parsed['paths']['/dummy_cars']['get']['tags']); + $this->assertSame('api_dummy_cars_id_get', $parsed['paths']['/dummy_cars/{id}']['get']['operationId']); + $this->assertSame([], $parsed['paths']['/dummy_cars/{id}']['get']['tags']); $expected = <<assertStringContainsString($expected, $result, 'nested object should be present.'); - - $operationId = 'api_dummy_cars_id_get'; - $expected = <<assertStringContainsString($expected, $result, 'arrays should be correctly formatted.'); + $this->assertStringContainsString($expected, $result, 'sequences should be correctly formatted.'); + $this->assertStringContainsString(' tags: []', $result, 'arrays should be correctly formatted.'); $this->assertStringContainsString('openapi: '.OpenApi::VERSION, $result); $expected = <<