diff --git a/src/Selector.php b/src/Selector.php index 0b0f671..d025262 100644 --- a/src/Selector.php +++ b/src/Selector.php @@ -38,7 +38,7 @@ public function __construct($selector) * * @return string */ - public function __toString() + public function __toString(): string { return $this->getValue(); } @@ -48,7 +48,7 @@ public function __toString() * * @return string */ - public function getValue() + public function getValue(): string { return $this->selector; } @@ -61,7 +61,7 @@ public function getValue() * * @return string The flattened attribute array. */ - private function attributeArrayToString($attributes) + private function attributeArrayToString($attributes): string { if (empty($attributes)) { throw new AttributeArrayException('Attributes array is empty.'); diff --git a/tests/Unit/SelectorTest.php b/tests/Unit/SelectorTest.php index 5ce0fc9..3b4edea 100644 --- a/tests/Unit/SelectorTest.php +++ b/tests/Unit/SelectorTest.php @@ -28,13 +28,29 @@ public function it_should_accept_string_selectors() * * @dataProvider provideAttributes */ - public function it_should_automatically_convert_attribute_arrays_to_strings($attributes, $expected) - { + public function it_should_automatically_convert_attribute_arrays_to_strings( + array $attributes, + string $expected + ) { $selector = new Selector($attributes); $this->assertSame($expected, $selector->getValue()); } + /** + * @test + * + * @ticket https://github.com/stevegrunwell/phpunit-markup-assertions/issues/13 + */ + public function it_should_be_able_to_handle_spaces_in_attribute_values() + { + $selector = new Selector([ + 'data-attr' => 'foo bar baz', + ]); + + $this->assertSame('*[data-attr="foo bar baz"]', $selector->getValue()); + } + /** * @test */ @@ -58,7 +74,7 @@ public function it_should_be_able_to_be_cast_to_a_string() /** * Data provider for testFlattenAttributeArray(). * - * @return Iterable{array, string} The attribute array and teh expected string. + * @return iterable{array, string} The attribute array and the expected string. */ public function provideAttributes() {