Skip to content

Commit b030aa0

Browse files
committed
Tests/HeredocNowdocCloserTest: use named data sets
With non-named data sets, when a test fails, PHPUnit will display the number of the test which failed. With tests which have a _lot_ of data sets, this makes it _interesting_ (and time-consuming) to debug those, as one now has to figure out which of the data sets in the data provider corresponds to that number. Using named data sets makes debugging failing tests more straight forward as PHPUnit will display the data set name instead of the number. Using named data sets also documents what exactly each data set is testing. Includes making the data type in the docblock more specific. Includes fixing up the docblock description for the file.
1 parent c8d68d6 commit b030aa0

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tests/Core/Tokenizer/HeredocNowdocCloserTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/**
3-
* Tests the tokenization of goto declarations and statements.
3+
* Tests the tokenization of heredoc/nowdoc closer tokens.
44
*
55
* @author Juliette Reinders Folmer <[email protected]>
66
* @copyright 2020 Squiz Pty Ltd (ABN 77 084 670 600)
@@ -23,8 +23,8 @@ final class HeredocNowdocCloserTest extends AbstractMethodUnitTest
2323
/**
2424
* Verify that leading (indent) whitespace in a heredoc/nowdoc closer token get the tab replacement treatment.
2525
*
26-
* @param string $testMarker The comment prefacing the target token.
27-
* @param array $expected Expectations for the token array.
26+
* @param string $testMarker The comment prefacing the target token.
27+
* @param array<string, int|string|null> $expected Expectations for the token array.
2828
*
2929
* @dataProvider dataHeredocNowdocCloserTabReplacement
3030
* @covers PHP_CodeSniffer\Tokenizers\Tokenizer::createPositionMap
@@ -55,52 +55,52 @@ public function testHeredocNowdocCloserTabReplacement($testMarker, $expected)
5555
*
5656
* @see testHeredocNowdocCloserTabReplacement()
5757
*
58-
* @return array
58+
* @return array<string, array<string, string|array<string, int|string|null>>>
5959
*/
6060
public static function dataHeredocNowdocCloserTabReplacement()
6161
{
6262
return [
63-
[
63+
'Heredoc closer without indent' => [
6464
'testMarker' => '/* testHeredocCloserNoIndent */',
6565
'expected' => [
6666
'length' => 3,
6767
'content' => 'EOD',
6868
'orig_content' => null,
6969
],
7070
],
71-
[
71+
'Nowdoc closer without indent' => [
7272
'testMarker' => '/* testNowdocCloserNoIndent */',
7373
'expected' => [
7474
'length' => 3,
7575
'content' => 'EOD',
7676
'orig_content' => null,
7777
],
7878
],
79-
[
79+
'Heredoc closer with indent, spaces' => [
8080
'testMarker' => '/* testHeredocCloserSpaceIndent */',
8181
'expected' => [
8282
'length' => 7,
8383
'content' => ' END',
8484
'orig_content' => null,
8585
],
8686
],
87-
[
87+
'Nowdoc closer with indent, spaces' => [
8888
'testMarker' => '/* testNowdocCloserSpaceIndent */',
8989
'expected' => [
9090
'length' => 8,
9191
'content' => ' END',
9292
'orig_content' => null,
9393
],
9494
],
95-
[
95+
'Heredoc closer with indent, tabs' => [
9696
'testMarker' => '/* testHeredocCloserTabIndent */',
9797
'expected' => [
9898
'length' => 8,
9999
'content' => ' END',
100100
'orig_content' => ' END',
101101
],
102102
],
103-
[
103+
'Nowdoc closer with indent, tabs' => [
104104
'testMarker' => '/* testNowdocCloserTabIndent */',
105105
'expected' => [
106106
'length' => 7,

0 commit comments

Comments
 (0)