Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/Assets/AssetRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function it_saves_the_meta_file_to_disk()

$disk->assertExists($path = 'foo/.meta/image.jpg.yaml');
$contents = <<<EOT
data: { }
data: {}
size: 723
last_modified: $timestamp
width: 30
Expand All @@ -45,7 +45,7 @@ public function it_saves_the_meta_file_to_disk()
duration: null

EOT;
$this->assertEquals($contents, $disk->get($path));
$this->assertEquals($contents, $this->normalizeYaml($disk->get($path)));
}

#[Test]
Expand Down
4 changes: 2 additions & 2 deletions tests/Data/Globals/VariablesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions tests/Stache/Stores/CollectionTreeStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions tests/Stache/Stores/NavTreeStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions tests/Yaml/YamlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
Loading