Skip to content

Commit a3d616e

Browse files
committed
minor #1790 Update Yaml indentation in tests after symfony/symfony#62967 (tcoch)
This PR was squashed before being merged into the 1.x branch. Discussion ---------- Update Yaml indentation in tests after symfony/symfony#62967 symfony/symfony#62967 introduced a change in how YAML files are generated. For this reason, some tests are broken here (e.g. #1785). This PR aims to resolve that. The modifications are: - Test files used have been adapted towards the new format - Special case has been added to `YamlSourceManipulatorTest.php` to address specify of tests in this CI with PHP8.1 and SF6.4.* lowest deps Commits ------- ce97fb4 Update Yaml indentation in tests after symfony/symfony#62967
2 parents 07e50c6 + ce97fb4 commit a3d616e

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

tests/Util/YamlSourceManipulatorTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111

1212
namespace Symfony\Bundle\MakerBundle\Tests\Util;
1313

14+
use Composer\InstalledVersions;
15+
use Composer\Semver\VersionParser;
1416
use PHPUnit\Framework\Attributes\DataProvider;
1517
use PHPUnit\Framework\TestCase;
1618
use Psr\Log\LogLevel;
1719
use Symfony\Bundle\MakerBundle\Util\YamlSourceManipulator;
1820
use Symfony\Component\Finder\Finder;
21+
use Symfony\Component\HttpKernel\Kernel;
1922
use Symfony\Component\HttpKernel\Log\Logger;
2023
use Symfony\Component\Yaml\Yaml;
2124

@@ -48,7 +51,11 @@ public function testSetData(string $startingSource, array $newData, string $expe
4851
*/
4952
$actualContents = $manipulator->getContents();
5053
$actualContents = str_replace("\r\n", "\n", $actualContents);
51-
$this->assertSame($expectedSource, $actualContents);
54+
if (InstalledVersions::satisfies(new VersionParser(), 'symfony/yaml', '<8.1')) {
55+
$this->assertSame(preg_replace('/\s+/', '', $expectedSource), preg_replace('/\s+/', '', $actualContents));
56+
} else {
57+
$this->assertSame($expectedSource, $actualContents);
58+
}
5259
}
5360

5461
private static function getYamlDataTests(): \Generator

tests/Util/yaml_fixtures/simple_sequence_add_array.test

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ $data['security']['access_control'][] = ['path' => '^/login$', 'roles' => 'IS_AU
88
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
99
security:
1010
access_control:
11-
-
12-
path: ^/login$
13-
roles: IS_AUTHENTICATED_ANONYMOUSLY
11+
- path: ^/login$
12+
roles: IS_AUTHENTICATED_ANONYMOUSLY

tests/Util/yaml_fixtures/simple_sequence_add_array_with_comments.test

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ $data['security']['access_control'][] = ['path' => '^/login$', 'roles' => 'IS_AU
1010
# https://symfony.com/doc/current/security.html#where-do-users-come-from-user-providers
1111
security:
1212
access_control:
13-
-
14-
path: ^/login$
15-
roles: IS_AUTHENTICATED_ANONYMOUSLY
13+
- path: ^/login$
14+
roles: IS_AUTHENTICATED_ANONYMOUSLY
1615
# - { path: ^/admin, roles: ROLE_ADMIN }
1716
# - { path: ^/profile, roles: ROLE_USER }

0 commit comments

Comments
 (0)