-
Notifications
You must be signed in to change notification settings - Fork 144
[TASK] Add accessor tests for OutputFormat
(part 1)
#847
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
0063965
to
99fb6e4
Compare
OutputFormat
OutputFormat
(part 1)
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.
Brilliant.
I tried experimentally ramping up PHPStan to level 2 and got loads of warnings re using the magic __call()
. If we can resolve this and increase the PHPStan checking level, it will give us more confidence about future changes.
However, I think some of the test cases could be made more realistic.
tests/Unit/OutputFormatTest.php
Outdated
*/ | ||
public function setStringQuotingTypeSetsStringQuotingType(): void | ||
{ | ||
$value = 'x'; |
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'd prefer a more realistic example here. Given the default is likely to be either "
or '
, how about `
?
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.
Or maybe have a dataProvider
to provide more than one quote type.
tests/Unit/OutputFormatTest.php
Outdated
*/ | ||
public function setStringQuotingTypeProvidesFluentInterface(): void | ||
{ | ||
self::assertSame($this->subject, $this->subject->setStringQuotingType('x')); |
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.
Perhaps also here.
tests/Unit/OutputFormatTest.php
Outdated
*/ | ||
public function setSpaceAfterRuleNameSetsSpaceAfterRuleName(): void | ||
{ | ||
$value = ' '; |
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.
Maybe a newline would be a more realistic example.
tests/Unit/OutputFormatTest.php
Outdated
*/ | ||
public function setSpaceAfterRuleNameProvidesFluentInterface(): void | ||
{ | ||
self::assertSame($this->subject, $this->subject->setSpaceAfterRuleName(' ')); |
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.
And here.
The accessor tests are basically for two things:
Checking that different quote types work is out of scope - I see it more in scope of the tests for the CSS elements that use this particular property. |
99fb6e4
to
1867996
Compare
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.
setStringQuotingTypeSetsStringQuotingType()
appears to now be setting the same as the default value.
Currently, this class uses magic getters and setters. These should be proper methods instead. But first, we should have tests for the accessors. This is part 1.
1867996
to
f0b778f
Compare
Currently, this class uses magic getters and setters. These
should be proper methods instead.
But first, we should have tests for the accessors. This is
part 1.