diff --git a/tests/Assets/AssetRepositoryTest.php b/tests/Assets/AssetRepositoryTest.php index 6d9d4c755f8..be2ea47f8a3 100644 --- a/tests/Assets/AssetRepositoryTest.php +++ b/tests/Assets/AssetRepositoryTest.php @@ -36,7 +36,7 @@ public function it_saves_the_meta_file_to_disk() $disk->assertExists($path = 'foo/.meta/image.jpg.yaml'); $contents = <<assertEquals($contents, $disk->get($path)); + $this->assertEquals($contents, $this->normalizeYaml($disk->get($path))); } #[Test] diff --git a/tests/Data/Globals/VariablesTest.php b/tests/Data/Globals/VariablesTest.php index 9bcfbb65ad4..806cada0ad1 100644 --- a/tests/Data/Globals/VariablesTest.php +++ b/tests/Data/Globals/VariablesTest.php @@ -96,10 +96,10 @@ public function it_gets_file_contents_for_saving_a_localized_set() - 'second one' string: 'The string' 'null': null -empty: { } +empty: {} EOT; - $this->assertEquals($expected, $b->fileContents()); + $this->assertEquals($expected, $this->normalizeYaml($b->fileContents())); $expected = <<<'EOT' array: diff --git a/tests/Stache/Stores/CollectionTreeStoreTest.php b/tests/Stache/Stores/CollectionTreeStoreTest.php index a98459069c7..0120f43b03b 100644 --- a/tests/Stache/Stores/CollectionTreeStoreTest.php +++ b/tests/Stache/Stores/CollectionTreeStoreTest.php @@ -160,12 +160,11 @@ public function it_saves_to_disk() $expected = <<<'EOT' tree: - - - entry: test + - entry: test EOT; - $this->assertStringEqualsFile($this->tempDir.'/pages.yaml', $expected); + $this->assertEquals($expected, $this->normalizeYaml(file_get_contents($this->tempDir.'/pages.yaml'))); } private function assertTree($array, $item) diff --git a/tests/Stache/Stores/NavTreeStoreTest.php b/tests/Stache/Stores/NavTreeStoreTest.php index 1587391d969..4fb46db6429 100644 --- a/tests/Stache/Stores/NavTreeStoreTest.php +++ b/tests/Stache/Stores/NavTreeStoreTest.php @@ -123,13 +123,12 @@ public function it_saves_to_disk() $expected = <<<'EOT' tree: - - - title: Test + - title: Test url: /test EOT; - $this->assertStringEqualsFile($this->tempDir.'/links.yaml', $expected); + $this->assertEquals($expected, $this->normalizeYaml(file_get_contents($this->tempDir.'/links.yaml'))); } private function assertTree($array, $item) diff --git a/tests/TestCase.php b/tests/TestCase.php index e219e3695e4..e23b8e2056e 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -200,6 +200,15 @@ protected function assertEveryItemIsInstanceOf($class, $items) $this->assertEquals(count($items), $matches, 'Failed asserting that every item is an instance of '.$class); } + protected function normalizeYaml(string $yaml): string + { + // Normalize formatting changes introduced in symfony/yaml 8.1 + $yaml = str_replace('{ }', '{}', $yaml); + $yaml = preg_replace('/^( *)-\n\1 (\S)/m', '$1- $2', $yaml); + + return $yaml; + } + protected function assertContainsHtml($string) { preg_match('/<[^<]+>/', $string, $matches); diff --git a/tests/Yaml/YamlTest.php b/tests/Yaml/YamlTest.php index 1626abd4c45..fc1e6a26300 100644 --- a/tests/Yaml/YamlTest.php +++ b/tests/Yaml/YamlTest.php @@ -68,11 +68,11 @@ public function it_dumps_without_front_matter_when_content_is_an_empty_array() { $expected = <<<'EOT' foo: bar -content: { } +content: {} EOT; - $this->assertEquals($expected, YAML::dump(['foo' => 'bar'], [])); + $this->assertEquals($expected, $this->normalizeYaml(YAML::dump(['foo' => 'bar'], []))); } #[Test] @@ -134,12 +134,12 @@ public function it_explicitly_dumps_front_matter_including_content_when_its_an_e $expected = <<<'EOT' --- foo: bar -content: { } +content: {} --- EOT; - $this->assertStringEqualsStringIgnoringLineEndings($expected, YAML::dumpFrontMatter(['foo' => 'bar'], [])); + $this->assertStringEqualsStringIgnoringLineEndings($expected, $this->normalizeYaml(YAML::dumpFrontMatter(['foo' => 'bar'], []))); } #[Test]