Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ysm] handle linebreak followed by an immediate root-level comment #1476

Merged
merged 12 commits into from
Mar 28, 2024
2 changes: 1 addition & 1 deletion .github/workflows/ci-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@ jobs:
run: vendor/bin/simple-phpunit --version

- name: Run tests
run: vendor/bin/simple-phpunit ${{ env.PHPUNIT_FLAGS }}
run: vendor/bin/simple-phpunit ${{ env.PHPUNIT_FLAGS }} --filter YamlSourceManipulator
2 changes: 1 addition & 1 deletion .github/workflows/ci-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ jobs:
run: vendor/bin/simple-phpunit --version

- name: Run Tests
run: vendor/bin/simple-phpunit ${{ env.PHPUNIT_FLAGS }}
run: vendor/bin/simple-phpunit ${{ env.PHPUNIT_FLAGS }} --filter YamlSourceManipulator
10 changes: 5 additions & 5 deletions tests/Util/YamlSourceManipulatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testSetData(string $startingSource, array $newData, string $expe

$logger = $this->createLogger();
// uncomment to enhance debugging
// $manipulator->setLogger($logger);
$manipulator->setLogger($logger);

$manipulator->setData($newData);

Expand All @@ -48,12 +48,12 @@ public function testSetData(string $startingSource, array $newData, string $expe
$this->assertSame($expectedSource, $actualContents);
}

private function getYamlDataTests()
private function getYamlDataTests(): \Generator
{
$finder = new Finder();
$finder->in(__DIR__.'/yaml_fixtures')
->files()
->name('*.test');
->name('a_wip.test');

foreach ($finder as $file) {
[$source, $changeCode, $expected] = explode('===', $file->getContents());
Expand Down Expand Up @@ -82,14 +82,14 @@ private function getYamlDataTests()
*/
}

public function getYamlDataTestsUnixSlashes()
public function getYamlDataTestsUnixSlashes(): \Generator
{
foreach ($this->getYamlDataTests() as $key => $data) {
yield 'unix_'.$key => $data;
}
}

public function getYamlDataTestsWindowsSlashes()
public function getYamlDataTestsWindowsSlashes(): \Generator
{
foreach ($this->getYamlDataTests() as $key => $data) {
$data['source'] = str_replace("\n", "\r\n", $data['source']);
Expand Down
13 changes: 13 additions & 0 deletions tests/Util/yaml_fixtures/a_wip.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
security:
firewalls:
# main:
===
$data['security'] = [
'firewalls' => 'a firewall',
'providers' => 'a provider'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ysm has the wrong indentation i think for providers - it looks like its trying to set it at 0 when it should be 2?

];
===
security:
firewalls: 'a firewall'
providers: 'a provider'
# main: