-
Notifications
You must be signed in to change notification settings - Fork 150
[TASK] Add more tests for OutputFormat
#893
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1016,6 +1016,16 @@ public function createCompactReturnsInstanceWithSpaceAfterSelectorSeparatorSetTo | |
| self::assertSame('', $newInstance->getSpaceAfterSelectorSeparator()); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function createCompactReturnsInstanceWithSpaceAfterListArgumentSeparatorsSetToEmptyArray(): void | ||
| { | ||
| $newInstance = OutputFormat::createCompact(); | ||
|
|
||
| self::assertSame([], $newInstance->getSpaceAfterListArgumentSeparators()); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
|
|
@@ -1025,4 +1035,133 @@ public function createCompactReturnsInstanceWithRenderCommentsDisabled(): void | |
|
|
||
| self::assertFalse($newInstance->getRenderComments()); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function createPrettyReturnsNewOutputFormatInstance(): void | ||
| { | ||
| self::assertInstanceOf(OutputFormat::class, OutputFormat::createPretty()); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function createPrettyCalledTwoTimesReturnsDifferentInstances(): void | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm thinking (and agreeing) "TwoTimes" is better than "Twice" for non-native-English speaking coders. |
||
| { | ||
| $firstCallResult = OutputFormat::createPretty(); | ||
| $secondCallResult = OutputFormat::createPretty(); | ||
|
|
||
| self::assertNotSame($firstCallResult, $secondCallResult); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function createPrettyReturnsInstanceWithSpaceBeforeRulesSetToNewline(): void | ||
| { | ||
| $newInstance = OutputFormat::createPretty(); | ||
|
|
||
| self::assertSame("\n", $newInstance->getSpaceBeforeRules()); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function createPrettyReturnsInstanceWithSpaceBetweenRulesSetToNewline(): void | ||
| { | ||
| $newInstance = OutputFormat::createPretty(); | ||
|
|
||
| self::assertSame("\n", $newInstance->getSpaceBetweenRules()); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function createPrettyReturnsInstanceWithSpaceAfterRulesSetToNewline(): void | ||
| { | ||
| $newInstance = OutputFormat::createPretty(); | ||
|
|
||
| self::assertSame("\n", $newInstance->getSpaceAfterRules()); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function createPrettyReturnsInstanceWithSpaceBeforeBlocksSetToNewline(): void | ||
| { | ||
| $newInstance = OutputFormat::createPretty(); | ||
|
|
||
| self::assertSame("\n", $newInstance->getSpaceBeforeBlocks()); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function createPrettyReturnsInstanceWithSpaceBetweenBlocksSetToTwoNewlines(): void | ||
| { | ||
| $newInstance = OutputFormat::createPretty(); | ||
|
|
||
| self::assertSame("\n\n", $newInstance->getSpaceBetweenBlocks()); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function createPrettyReturnsInstanceWithSpaceAfterBlocksSetToNewline(): void | ||
| { | ||
| $newInstance = OutputFormat::createPretty(); | ||
|
|
||
| self::assertSame("\n", $newInstance->getSpaceAfterBlocks()); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function createPrettyReturnsInstanceWithSpaceAfterRuleNameSetSpace(): void | ||
oliverklee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| $newInstance = OutputFormat::createPretty(); | ||
|
|
||
| self::assertSame(' ', $newInstance->getSpaceAfterRuleName()); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function createPrettyReturnsInstanceWithSpaceBeforeOpeningBraceSetToSpace(): void | ||
| { | ||
| $newInstance = OutputFormat::createPretty(); | ||
|
|
||
| self::assertSame(' ', $newInstance->getSpaceBeforeOpeningBrace()); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function createPrettyReturnsInstanceWithSpaceAfterSelectorSeparatorSetToSpace(): void | ||
| { | ||
| $newInstance = OutputFormat::createPretty(); | ||
|
|
||
| self::assertSame(' ', $newInstance->getSpaceAfterSelectorSeparator()); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function createPrettyReturnsInstanceWithSpaceAfterListArgumentSeparatorsSetToSpaceForComma(): void | ||
| { | ||
| $newInstance = OutputFormat::createPretty(); | ||
|
|
||
| self::assertSame([',' => ' '], $newInstance->getSpaceAfterListArgumentSeparators()); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this just test that the key
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or maybe the test method should be renamed to indicate it's checking the whole array by adding |
||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| */ | ||
| public function createPrettyReturnsInstanceWithRenderCommentsEnabled(): void | ||
| { | ||
| $newInstance = OutputFormat::createPretty(); | ||
|
|
||
| self::assertTrue($newInstance->getRenderComments()); | ||
| } | ||
| } | ||
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 think "New" is redundant in the test method name, but it's consistent with
createCompactReturnsNewOutputFormatInstance, which I signed off 🤷