Skip to content

Commit ae6596c

Browse files
Merge pull request #52 from stevegrunwell/feature/drop-php-5x-support
Drop PHP 5.6, 7.0 support
2 parents 54761a6 + 8d1e26f commit ae6596c

File tree

6 files changed

+44
-31
lines changed

6 files changed

+44
-31
lines changed

.github/workflows/static-code-analysis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,10 @@ jobs:
1919
- name: Install Composer dependencies
2020
uses: ramsey/composer-install@v2
2121

22+
# PHPUnit Bridge won't install a version of PHPUnit by default, but this will trick
23+
# it into doing so.
24+
- name: Install PHPUnit
25+
run: composer test -- --version
26+
2227
- name: Run PHPStan
2328
run: composer static-analysis

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
11-
php-version: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
11+
php-version: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
1212
steps:
1313
- name: Checkout
1414
uses: actions/checkout@v4

.phpcs.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@
2020

2121
<!-- Ensure we're compatible with PHP 5.6+ -->
2222
<rule ref="PHPCompatibility"/>
23-
<config name="testVersion" value="5.6-"/>
23+
<config name="testVersion" value="7.1-"/>
2424
</ruleset>

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"source": "https://github.com/stevegrunwell/phpunit-markup-assertions/"
1616
},
1717
"require": {
18-
"php": "^5.6 || ^7.0 || ^8.0",
19-
"symfony/css-selector": "^3.4|^4.4|^5.4|^6.0",
20-
"symfony/dom-crawler": "^3.4|^4.4|^5.4|^6.0"
18+
"php": "^7.1 || ^8.0",
19+
"symfony/css-selector": "^4.4|^5.4|^6.0",
20+
"symfony/dom-crawler": "^4.4|^5.4|^6.0"
2121
},
2222
"require-dev": {
2323
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",

src/MarkupAssertionsTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ private function flattenAttributeArray(array $attributes)
249249

250250
array_walk($attributes, function (&$value, $key) {
251251
// Boolean attributes.
252-
if (null === $value) {
252+
if (empty($value)) {
253253
$value = sprintf('[%s]', $key);
254254
} else {
255255
$value = sprintf('[%s="%s"]', $key, htmlspecialchars($value));

tests/MarkupAssertionsTraitTest.php

Lines changed: 33 additions & 25 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,8 +44,9 @@ 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)
48-
{
47+
public function assertNotContainsSelector_should_verify_that_the_given_selector_does_not_exist(
48+
string $selector
49+
): void {
4950
$this->assertNotContainsSelector(
5051
$selector,
5152
'<h1 id="page-title" class="foo bar">This element has little to do with the link.</h1>'
@@ -56,7 +57,7 @@ public function assertNotContainsSelector_should_verify_that_the_given_selector_
5657
* @test
5758
* @testdox assertSelectorCount() should count the instances of a selector
5859
*/
59-
public function assertSelectorCount_should_count_the_number_of_instances()
60+
public function assertSelectorCount_should_count_the_number_of_instances(): void
6061
{
6162
$this->assertSelectorCount(
6263
3,
@@ -69,7 +70,7 @@ public function assertSelectorCount_should_count_the_number_of_instances()
6970
* @test
7071
* @testdox assertHasElementWithAttributes() should find an element with the given attributes
7172
*/
72-
public function assertHasElementWithAttributes_should_find_elements_with_matching_attributes()
73+
public function assertHasElementWithAttributes_should_find_elements_with_matching_attributes(): void
7374
{
7475
$this->assertHasElementWithAttributes(
7576
[
@@ -85,7 +86,7 @@ public function assertHasElementWithAttributes_should_find_elements_with_matchin
8586
* @testdox assertHasElementWithAttributes() should be able to parse spaces in attribute values
8687
* @ticket https://github.com/stevegrunwell/phpunit-markup-assertions/issues/13
8788
*/
88-
public function assertHasElementWithAttributes_should_be_able_to_handle_spaces()
89+
public function assertHasElementWithAttributes_should_be_able_to_handle_spaces(): void
8990
{
9091
$this->assertHasElementWithAttributes(
9192
[
@@ -99,7 +100,7 @@ public function assertHasElementWithAttributes_should_be_able_to_handle_spaces()
99100
* @test
100101
* @testdox assertNotHasElementWithAttributes() should ensure no element has the provided attributes
101102
*/
102-
public function assertNotHasElementWithAttributes_should_find_no_elements_with_matching_attributes()
103+
public function assertNotHasElementWithAttributes_should_find_no_elements_with_matching_attributes(): void
103104
{
104105
$this->assertNotHasElementWithAttributes(
105106
[
@@ -114,7 +115,7 @@ public function assertNotHasElementWithAttributes_should_find_no_elements_with_m
114115
* @test
115116
* @testdox assertElementContains() should be able to search for a selector
116117
*/
117-
public function assertElementContains_can_match_a_selector()
118+
public function assertElementContains_can_match_a_selector(): void
118119
{
119120
$this->assertElementContains(
120121
'ipsum',
@@ -127,7 +128,7 @@ public function assertElementContains_can_match_a_selector()
127128
* @test
128129
* @testdox assertElementContains() should be able to chain multiple selectors
129130
*/
130-
public function assertElementContains_can_chain_multiple_selectors()
131+
public function assertElementContains_can_chain_multiple_selectors(): void
131132
{
132133
$this->assertElementContains(
133134
'ipsum',
@@ -140,7 +141,7 @@ public function assertElementContains_can_chain_multiple_selectors()
140141
* @test
141142
* @testdox assertElementContains() should scope text to the selected element
142143
*/
143-
public function assertElementContains_should_scope_matches_to_selector()
144+
public function assertElementContains_should_scope_matches_to_selector(): void
144145
{
145146
$this->expectException(AssertionFailedError::class);
146147
$this->expectExceptionMessage('The #main div does not contain the string "ipsum".');
@@ -159,7 +160,7 @@ public function assertElementContains_should_scope_matches_to_selector()
159160
* @dataProvider provideGreetingsInDifferentLanguages
160161
* @ticket https://github.com/stevegrunwell/phpunit-markup-assertions/issues/31
161162
*/
162-
public function assertElementContains_should_handle_various_character_sets($greeting)
163+
public function assertElementContains_should_handle_various_character_sets(string $greeting): void
163164
{
164165
$this->assertElementContains(
165166
$greeting,
@@ -172,7 +173,7 @@ public function assertElementContains_should_handle_various_character_sets($gree
172173
* @test
173174
* @testdox assertElementNotContains() should be able to search for a selector
174175
*/
175-
public function assertElementNotContains_can_match_a_selector()
176+
public function assertElementNotContains_can_match_a_selector(): void
176177
{
177178
$this->assertElementNotContains(
178179
'ipsum',
@@ -187,7 +188,7 @@ public function assertElementNotContains_can_match_a_selector()
187188
* @dataProvider provideGreetingsInDifferentLanguages
188189
* @ticket https://github.com/stevegrunwell/phpunit-markup-assertions/issues/31
189190
*/
190-
public function assertElementNotContains_should_handle_various_character_sets($greeting)
191+
public function assertElementNotContains_should_handle_various_character_sets(string $greeting): void
191192
{
192193
$this->assertElementNotContains(
193194
$greeting,
@@ -200,7 +201,7 @@ public function assertElementNotContains_should_handle_various_character_sets($g
200201
* @test
201202
* @testdox assertElementRegExp() should use regular expression matching
202203
*/
203-
public function assertElementRegExp_should_use_regular_expression_matching()
204+
public function assertElementRegExp_should_use_regular_expression_matching(): void
204205
{
205206
$this->assertElementRegExp(
206207
'/[A-Z0-9-]+/',
@@ -213,7 +214,7 @@ public function assertElementRegExp_should_use_regular_expression_matching()
213214
* @test
214215
* @testdox assertElementRegExp() should be able to search for nested contents
215216
*/
216-
public function assertElementRegExp_should_be_able_to_match_nested_contents()
217+
public function assertElementRegExp_should_be_able_to_match_nested_contents(): void
217218
{
218219
$this->assertElementRegExp(
219220
'/[A-Z]+/',
@@ -226,7 +227,7 @@ public function assertElementRegExp_should_be_able_to_match_nested_contents()
226227
* @test
227228
* @testdox assertElementNotRegExp() should use regular expression matching
228229
*/
229-
public function testAssertElementNotRegExp()
230+
public function testAssertElementNotRegExp(): void
230231
{
231232
$this->assertElementNotRegExp(
232233
'/[0-9-]+/',
@@ -240,8 +241,10 @@ public function testAssertElementNotRegExp()
240241
* @test
241242
* @testdox flattenAttributeArray() should flatten an array of attributes
242243
* @dataProvider provideAttributes
244+
*
245+
* @param array<string,string> $attributes
243246
*/
244-
public function flattenArrayAttribute_should_flatten_arrays_of_attributes($attributes, $expected)
247+
public function flattenArrayAttribute_should_flatten_arrays_of_attributes(array $attributes, string $expected): void
245248
{
246249
$method = new \ReflectionMethod($this, 'flattenAttributeArray');
247250
$method->setAccessible(true);
@@ -254,7 +257,7 @@ public function flattenArrayAttribute_should_flatten_arrays_of_attributes($attri
254257
* @testdox flattenAttributeArray() should throw a RiskyTestError if the array is empty
255258
* @dataProvider provideAttributes
256259
*/
257-
public function flattenAttributeArray_should_throw_a_RiskyTestError_if_given_an_empty_array()
260+
public function flattenAttributeArray_should_throw_a_RiskyTestError_if_given_an_empty_array(): void
258261
{
259262
$this->expectException(RiskyTestError::class);
260263

@@ -268,8 +271,11 @@ public function flattenAttributeArray_should_throw_a_RiskyTestError_if_given_an_
268271
* @testdox getInnerHtmlOfMatchedElements() should retrieve the inner HTML
269272
* @dataProvider provideInnerHtml
270273
*/
271-
public function getInnerHtmlOfMatchedElements_should_retrieve_the_inner_HTML($markup, $selector, $expected)
272-
{
274+
public function getInnerHtmlOfMatchedElements_should_retrieve_the_inner_HTML(
275+
string $markup,
276+
string $selector,
277+
string $expected
278+
): void {
273279
$method = new \ReflectionMethod($this, 'getInnerHtmlOfMatchedElements');
274280
$method->setAccessible(true);
275281

@@ -278,8 +284,10 @@ public function getInnerHtmlOfMatchedElements_should_retrieve_the_inner_HTML($ma
278284

279285
/**
280286
* Data provider for testFlattenAttributeArray().
287+
*
288+
* @return array<string,array{array<string,string>,string}>
281289
*/
282-
public function provideAttributes()
290+
public function provideAttributes(): array
283291
{
284292
return [
285293
'Single attribute' => [
@@ -321,7 +329,7 @@ public function provideAttributes()
321329
*
322330
* @return array<string,array<string>>
323331
*/
324-
public function provideInnerHtml()
332+
public function provideInnerHtml(): array
325333
{
326334
return [
327335
'A single match' => [
@@ -347,7 +355,7 @@ public function provideInnerHtml()
347355
*
348356
* @return array<string,array<string>>
349357
*/
350-
public function provideSelectorVariants()
358+
public function provideSelectorVariants(): array
351359
{
352360
return [
353361
'Simple tag name' => ['a'],
@@ -365,7 +373,7 @@ public function provideSelectorVariants()
365373
*
366374
* @return array<string,array<string>>
367375
*/
368-
public function provideGreetingsInDifferentLanguages()
376+
public function provideGreetingsInDifferentLanguages(): array
369377
{
370378
return [
371379
'Arabic' => ['مرحبا!'],

0 commit comments

Comments
 (0)