Skip to content

Commit fead459

Browse files
committed
Add return typehints, missing docblocks to the test class
1 parent 13318e5 commit fead459

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

tests/MarkupAssertionsTraitTest.php

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class MarkupAssertionsTraitTest extends TestCase
1919
* @testdox assertContainsSelector() should find matching selectors
2020
* @dataProvider provideSelectorVariants
2121
*/
22-
public function assertContainsSelector_should_find_matching_selectors($selector)
22+
public function assertContainsSelector_should_find_matching_selectors(string $selector): void
2323
{
2424
$this->assertContainsSelector(
2525
$selector,
@@ -31,7 +31,7 @@ public function assertContainsSelector_should_find_matching_selectors($selector)
3131
* @test
3232
* @testdox assertContainsSelector() should pick up multiple instances of a selector
3333
*/
34-
public function assertContainsSelector_should_pick_up_multiple_instances()
34+
public function assertContainsSelector_should_pick_up_multiple_instances(): void
3535
{
3636
$this->assertContainsSelector(
3737
'a',
@@ -44,7 +44,7 @@ public function assertContainsSelector_should_pick_up_multiple_instances()
4444
* @testdox assertNotContainsSelector() should verify that the given selector does not exist
4545
* @dataProvider provideSelectorVariants
4646
*/
47-
public function assertNotContainsSelector_should_verify_that_the_given_selector_does_not_exist($selector)
47+
public function assertNotContainsSelector_should_verify_that_the_given_selector_does_not_exist(string $selector): void
4848
{
4949
$this->assertNotContainsSelector(
5050
$selector,
@@ -56,7 +56,7 @@ public function assertNotContainsSelector_should_verify_that_the_given_selector_
5656
* @test
5757
* @testdox assertSelectorCount() should count the instances of a selector
5858
*/
59-
public function assertSelectorCount_should_count_the_number_of_instances()
59+
public function assertSelectorCount_should_count_the_number_of_instances(): void
6060
{
6161
$this->assertSelectorCount(
6262
3,
@@ -69,7 +69,7 @@ public function assertSelectorCount_should_count_the_number_of_instances()
6969
* @test
7070
* @testdox assertHasElementWithAttributes() should find an element with the given attributes
7171
*/
72-
public function assertHasElementWithAttributes_should_find_elements_with_matching_attributes()
72+
public function assertHasElementWithAttributes_should_find_elements_with_matching_attributes(): void
7373
{
7474
$this->assertHasElementWithAttributes(
7575
[
@@ -85,7 +85,7 @@ public function assertHasElementWithAttributes_should_find_elements_with_matchin
8585
* @testdox assertHasElementWithAttributes() should be able to parse spaces in attribute values
8686
* @ticket https://github.com/stevegrunwell/phpunit-markup-assertions/issues/13
8787
*/
88-
public function assertHasElementWithAttributes_should_be_able_to_handle_spaces()
88+
public function assertHasElementWithAttributes_should_be_able_to_handle_spaces(): void
8989
{
9090
$this->assertHasElementWithAttributes(
9191
[
@@ -99,7 +99,7 @@ public function assertHasElementWithAttributes_should_be_able_to_handle_spaces()
9999
* @test
100100
* @testdox assertNotHasElementWithAttributes() should ensure no element has the provided attributes
101101
*/
102-
public function assertNotHasElementWithAttributes_should_find_no_elements_with_matching_attributes()
102+
public function assertNotHasElementWithAttributes_should_find_no_elements_with_matching_attributes(): void
103103
{
104104
$this->assertNotHasElementWithAttributes(
105105
[
@@ -114,7 +114,7 @@ public function assertNotHasElementWithAttributes_should_find_no_elements_with_m
114114
* @test
115115
* @testdox assertElementContains() should be able to search for a selector
116116
*/
117-
public function assertElementContains_can_match_a_selector()
117+
public function assertElementContains_can_match_a_selector(): void
118118
{
119119
$this->assertElementContains(
120120
'ipsum',
@@ -127,7 +127,7 @@ public function assertElementContains_can_match_a_selector()
127127
* @test
128128
* @testdox assertElementContains() should be able to chain multiple selectors
129129
*/
130-
public function assertElementContains_can_chain_multiple_selectors()
130+
public function assertElementContains_can_chain_multiple_selectors(): void
131131
{
132132
$this->assertElementContains(
133133
'ipsum',
@@ -140,7 +140,7 @@ public function assertElementContains_can_chain_multiple_selectors()
140140
* @test
141141
* @testdox assertElementContains() should scope text to the selected element
142142
*/
143-
public function assertElementContains_should_scope_matches_to_selector()
143+
public function assertElementContains_should_scope_matches_to_selector(): void
144144
{
145145
$this->expectException(AssertionFailedError::class);
146146
$this->expectExceptionMessage('The #main div does not contain the string "ipsum".');
@@ -159,7 +159,7 @@ public function assertElementContains_should_scope_matches_to_selector()
159159
* @dataProvider provideGreetingsInDifferentLanguages
160160
* @ticket https://github.com/stevegrunwell/phpunit-markup-assertions/issues/31
161161
*/
162-
public function assertElementContains_should_handle_various_character_sets($greeting)
162+
public function assertElementContains_should_handle_various_character_sets(string $greeting): void
163163
{
164164
$this->assertElementContains(
165165
$greeting,
@@ -172,7 +172,7 @@ public function assertElementContains_should_handle_various_character_sets($gree
172172
* @test
173173
* @testdox assertElementNotContains() should be able to search for a selector
174174
*/
175-
public function assertElementNotContains_can_match_a_selector()
175+
public function assertElementNotContains_can_match_a_selector(): void
176176
{
177177
$this->assertElementNotContains(
178178
'ipsum',
@@ -187,7 +187,7 @@ public function assertElementNotContains_can_match_a_selector()
187187
* @dataProvider provideGreetingsInDifferentLanguages
188188
* @ticket https://github.com/stevegrunwell/phpunit-markup-assertions/issues/31
189189
*/
190-
public function assertElementNotContains_should_handle_various_character_sets($greeting)
190+
public function assertElementNotContains_should_handle_various_character_sets(string $greeting): void
191191
{
192192
$this->assertElementNotContains(
193193
$greeting,
@@ -200,7 +200,7 @@ public function assertElementNotContains_should_handle_various_character_sets($g
200200
* @test
201201
* @testdox assertElementRegExp() should use regular expression matching
202202
*/
203-
public function assertElementRegExp_should_use_regular_expression_matching()
203+
public function assertElementRegExp_should_use_regular_expression_matching(): void
204204
{
205205
$this->assertElementRegExp(
206206
'/[A-Z0-9-]+/',
@@ -213,7 +213,7 @@ public function assertElementRegExp_should_use_regular_expression_matching()
213213
* @test
214214
* @testdox assertElementRegExp() should be able to search for nested contents
215215
*/
216-
public function assertElementRegExp_should_be_able_to_match_nested_contents()
216+
public function assertElementRegExp_should_be_able_to_match_nested_contents(): void
217217
{
218218
$this->assertElementRegExp(
219219
'/[A-Z]+/',
@@ -226,7 +226,7 @@ public function assertElementRegExp_should_be_able_to_match_nested_contents()
226226
* @test
227227
* @testdox assertElementNotRegExp() should use regular expression matching
228228
*/
229-
public function testAssertElementNotRegExp()
229+
public function testAssertElementNotRegExp(): void
230230
{
231231
$this->assertElementNotRegExp(
232232
'/[0-9-]+/',
@@ -240,8 +240,10 @@ public function testAssertElementNotRegExp()
240240
* @test
241241
* @testdox flattenAttributeArray() should flatten an array of attributes
242242
* @dataProvider provideAttributes
243+
*
244+
* @param array<string,string> $attributes
243245
*/
244-
public function flattenArrayAttribute_should_flatten_arrays_of_attributes($attributes, $expected)
246+
public function flattenArrayAttribute_should_flatten_arrays_of_attributes(array $attributes, string $expected): void
245247
{
246248
$method = new \ReflectionMethod($this, 'flattenAttributeArray');
247249
$method->setAccessible(true);
@@ -254,7 +256,7 @@ public function flattenArrayAttribute_should_flatten_arrays_of_attributes($attri
254256
* @testdox flattenAttributeArray() should throw a RiskyTestError if the array is empty
255257
* @dataProvider provideAttributes
256258
*/
257-
public function flattenAttributeArray_should_throw_a_RiskyTestError_if_given_an_empty_array()
259+
public function flattenAttributeArray_should_throw_a_RiskyTestError_if_given_an_empty_array(): void
258260
{
259261
$this->expectException(RiskyTestError::class);
260262

@@ -268,7 +270,7 @@ public function flattenAttributeArray_should_throw_a_RiskyTestError_if_given_an_
268270
* @testdox getInnerHtmlOfMatchedElements() should retrieve the inner HTML
269271
* @dataProvider provideInnerHtml
270272
*/
271-
public function getInnerHtmlOfMatchedElements_should_retrieve_the_inner_HTML($markup, $selector, $expected)
273+
public function getInnerHtmlOfMatchedElements_should_retrieve_the_inner_HTML(string $markup, string $selector, string $expected): void
272274
{
273275
$method = new \ReflectionMethod($this, 'getInnerHtmlOfMatchedElements');
274276
$method->setAccessible(true);
@@ -278,8 +280,10 @@ public function getInnerHtmlOfMatchedElements_should_retrieve_the_inner_HTML($ma
278280

279281
/**
280282
* Data provider for testFlattenAttributeArray().
283+
*
284+
* @return array<string,array{array<string,string>,string}>
281285
*/
282-
public function provideAttributes()
286+
public function provideAttributes(): array
283287
{
284288
return [
285289
'Single attribute' => [
@@ -321,7 +325,7 @@ public function provideAttributes()
321325
*
322326
* @return array<string,array<string>>
323327
*/
324-
public function provideInnerHtml()
328+
public function provideInnerHtml(): array
325329
{
326330
return [
327331
'A single match' => [
@@ -347,7 +351,7 @@ public function provideInnerHtml()
347351
*
348352
* @return array<string,array<string>>
349353
*/
350-
public function provideSelectorVariants()
354+
public function provideSelectorVariants(): array
351355
{
352356
return [
353357
'Simple tag name' => ['a'],
@@ -365,7 +369,7 @@ public function provideSelectorVariants()
365369
*
366370
* @return array<string,array<string>>
367371
*/
368-
public function provideGreetingsInDifferentLanguages()
372+
public function provideGreetingsInDifferentLanguages(): array
369373
{
370374
return [
371375
'Arabic' => ['مرحبا!'],

0 commit comments

Comments
 (0)