-
Notifications
You must be signed in to change notification settings - Fork 147
[BUGFIX] Allow commas in attributes in setSelectors
#1419
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
setSelectors
This fixes an issue noted in #1324.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |
| use Sabberworm\CSS\CSSElement; | ||
| use Sabberworm\CSS\CSSList\CSSListItem; | ||
| use Sabberworm\CSS\Parsing\ParserState; | ||
| use Sabberworm\CSS\Parsing\UnexpectedTokenException; | ||
| use Sabberworm\CSS\Position\Positionable; | ||
| use Sabberworm\CSS\Property\Selector; | ||
| use Sabberworm\CSS\Rule\Rule; | ||
|
|
@@ -293,4 +294,58 @@ public function setSelectorsIgnoresKeys(): void | |
|
|
||
| self::assertSame([0, 1], \array_keys($result)); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| * | ||
| * @param non-empty-string $selector | ||
| * | ||
| * @dataProvider provideSelector | ||
| */ | ||
| public function setSelectorsSetsSingleSelectorProvidedAsString(string $selector): void | ||
| { | ||
| $subject = new DeclarationBlock(); | ||
|
|
||
| $subject->setSelectors($selector); | ||
|
|
||
| $result = $subject->getSelectors(); | ||
| self::assertSame([$selector], self::getSelectorsAsStrings($subject)); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| * | ||
| * @param non-empty-string $firstSelector | ||
| * @param non-empty-string $secondSelector | ||
| * | ||
| * @dataProvider provideTwoSelectors | ||
| */ | ||
| public function setSelectorsSetsTwoCommaSeparatedSelectorsProvidedAsString( | ||
| string $firstSelector, | ||
| string $secondSelector | ||
| ): void { | ||
| $joinedSelectors = $firstSelector . ', ' . $secondSelector; | ||
| $subject = new DeclarationBlock(); | ||
|
|
||
| $subject->setSelectors($joinedSelectors); | ||
|
|
||
| $result = $subject->getSelectors(); | ||
| self::assertSame([$firstSelector, $secondSelector], self::getSelectorsAsStrings($subject)); | ||
| } | ||
|
|
||
| /** | ||
| * @test | ||
| * | ||
| * @param non-empty-string $selector | ||
| * | ||
| * @dataProvider provideInvalidSelector | ||
| */ | ||
| public function setSelectorsThrowsExceptionWithInvalidSelector(string $selector): void | ||
| { | ||
| $this->expectException(UnexpectedTokenException::class); | ||
|
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. We should also check for the exception message.
Collaborator
Author
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 looked at the messages and found they were unhelpful, so have fixed that. I also found that the exceptions thrown by the code when |
||
|
|
||
| $subject = new DeclarationBlock(); | ||
|
|
||
| $subject->setSelectors($selector); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.