-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Yaml] Improve test coverage in DumperTest and ParserTest #46739
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
Conversation
Main difference to 6.1 / 6.2:
|
If we can't have a comma after the last argument of a multi-line function call, I rather put the closing $this->assertSame(
$expected,
$this->parser->parse(
$this->dumper->dump($expected, 10)),
$test['test']); |
I'm a bit undecided about code style because it is already so inconsistent :) |
So how do we bring this to the other branches once it is merged? |
Added "[Yaml] " in the commit messages. |
@donquixote the core team will then merge the 4.4 branch into the 5.4 branch, and so on. |
@@ -104,7 +104,11 @@ public function testSpecifications() | |||
} | |||
|
|||
$expected = eval('return ' . $test['php'] . ';'); | |||
$this->assertSame($expected, $this->parser->parse($this->dumper->dump($expected, 10)), $test['test']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line breaking should be reverted IMO.
@@ -507,6 +512,9 @@ public function testDumpingNotInlinedNullTaggedValue() | |||
YAML; | |||
|
|||
$this->assertSame($expected, $this->dumper->dump($data, 2)); | |||
$this->assertEquals( | |||
['foo' => new TaggedValue('bar', 'null')], | |||
$this->parser->parse($expected, Yaml::PARSE_CUSTOM_TAGS | Yaml::PARSE_CONSTANT)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why adding tests for the parsing in the DumperTest ? That's quite confusing to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to verify that our expected yaml output is correct, and the best way to do this seems to be a round trip.
On the one hand this is not really the responsibility of this test, on the other hand it is more useful than it hurts - imo.
We should standardize the use of local variables. Can we agree on something? $data = new TaggedValue('user', ['name' => 'jane']);
$expected = '!user { name: jane }';
$this->assertSame($expected, $this->dumper->dump($data));
// If we want to keep the round trip test:
$this->assertSameData($data, $this->parser->parse($expected, Yaml::PARSE_CUSTOM_TAGS)); Would be even nicer to work with data providers, but these also need to contain the parameters to send to dumper and parser (unless we drop the parser). |
$expected = ''; | ||
$yaml = $this->dumper->dump($data, 2); | ||
$this->assertSame($expected, $yaml); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stof Fyi I am following a philosophy where we also cover scenarios that currently don't work as intended, as a way to document known issues that we are not currently fixing.
The commit or PR that contains a fix or that changes the nature of the bug will have to include a change in this test, documenting the change of behavior.
I am going to fix code style later as reported by fabbot.io.
|
162d0a9
to
39de9e0
Compare
The PR is ready for another review, just saying :) |
39de9e0
to
21515b3
Compare
Thank you @donquixote. |
Oh no!
|
I know: they failed so I removed them, knowing you would rebase your other PR and resurrect them :) |
Note that these tests are slightly different against 4.4 then they would be against 6.1 or 6.2.
I also tried to be compatible with PHP 7.1, e.g. I did not use null coalesce operator.