Skip to content

Commit 856219c

Browse files
rodrigoprimojrfnl
authored andcommitted
Squiz/ArrayDeclaration: improves test coverage
This commit adds tests that were previously missing. There are still some uncovered lines in this sniff, those lines might be unreachable, but I did not investigate this at this time. There is also potentially some more relevant tests that could be added for lines that are already covered. This is also not addressed in this commit.
1 parent aab0862 commit 856219c

6 files changed

+54
-1
lines changed

src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class TestClass
1919
'height' => '',
2020
);
2121

22-
private $_bad = Array(
22+
private $_bad = ARRAY(
2323
'width' => '',
2424
'height' => ''
2525
);
@@ -547,3 +547,14 @@ $x = array(
547547
1, static::helloWorld(), $class instanceof static,
548548
2,
549549
);
550+
551+
$noSpaceBeforeDoubleArrow = array(
552+
'width'=> '',
553+
'height' => '',
554+
);
555+
556+
$newlineAfterDoubleArrow = array(
557+
'width' =>
558+
'',
559+
'height' => '',
560+
);

src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc.fixed

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,3 +586,13 @@ $x = array(
586586
$class instanceof static,
587587
2,
588588
);
589+
590+
$noSpaceBeforeDoubleArrow = array(
591+
'width' => '',
592+
'height' => '',
593+
);
594+
595+
$newlineAfterDoubleArrow = array(
596+
'width' => '',
597+
'height' => '',
598+
);

src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,3 +536,14 @@ $x = [
536536
1, static::helloWorld(), $class instanceof static,
537537
2,
538538
];
539+
540+
$noSpaceBeforeDoubleArrow = [
541+
'width'=> '',
542+
'height' => '',
543+
];
544+
545+
$newlineAfterDoubleArrow = [
546+
'width' =>
547+
'',
548+
'height' => '',
549+
];

src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc.fixed

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,3 +573,13 @@ $x = [
573573
$class instanceof static,
574574
2,
575575
];
576+
577+
$noSpaceBeforeDoubleArrow = [
578+
'width' => '',
579+
'height' => '',
580+
];
581+
582+
$newlineAfterDoubleArrow = [
583+
'width' => '',
584+
'height' => '',
585+
];
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
// Intentional parse error (missing closing parenthesis).
4+
// This should be the only test in this file.
5+
// Testing that the sniff is *not* triggered.
6+
7+
$array = array(

src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ public function getErrorList($testFile='')
136136
537 => 1,
137137
540 => 1,
138138
547 => 2,
139+
552 => 1,
140+
557 => 1,
139141
];
140142
case 'ArrayDeclarationUnitTest.2.inc':
141143
return [
@@ -229,6 +231,8 @@ public function getErrorList($testFile='')
229231
526 => 1,
230232
529 => 1,
231233
536 => 2,
234+
541 => 1,
235+
546 => 1,
232236
];
233237
default:
234238
return [];

0 commit comments

Comments
 (0)