Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fredden committed Jun 8, 2023
1 parent 01410b4 commit b055898
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
33 changes: 33 additions & 0 deletions src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.3.inc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
<?php } ?>
<?php } ?>

<!-- no problem here -->
<?php if (true) { ?>
<?php foreach ([] as $item) { ?>
<!-- note missing semicolon on next line -->
<?php continue ?>
<?php } ?>
<?php } ?>

<!-- should detect an error here -->
<?php if (true): ?>
<?php foreach ([] as $item): ?>
Expand All @@ -20,6 +28,15 @@
<?php endforeach; ?>
<?php endif; ?>

<!-- should detect an error here -->
<?php if (true): ?>
<?php foreach ([] as $item): ?>
<!-- note missing semicolon on next line -->
<?php continue ?>
<div>non-executable</div>
<?php endforeach; ?>
<?php endif; ?>

<!-- should detect an error here -->
<?php if (true): ?>
<?php foreach ([] as $item): ?>
Expand All @@ -29,3 +46,19 @@

<?php endforeach; ?>
<?php endif; ?>

<!-- should detect an error here -->
<?php if (true): ?>
<?php foreach ([] as $item): ?>
<?php continue; ?>
<?= 'unreachable - no semicolon' ?>
<?php endforeach; ?>
<?php endif; ?>

<!-- should detect an error here -->
<?php if (true): ?>
<?php foreach ([] as $item): ?>
<?php continue; ?>
<?= 'unreachable - with semicolon'; ?>
<?php endforeach; ?>
<?php endif; ?>
7 changes: 5 additions & 2 deletions src/Standards/Squiz/Tests/PHP/NonExecutableCodeUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ public function getWarningList($testFile='')
break;
case 'NonExecutableCodeUnitTest.3.inc':
return [
19 => 1,
28 => 1,
27 => 1,
36 => 1,
45 => 1,
54 => 1,
62 => 1,
];
default:
return [];
Expand Down

0 comments on commit b055898

Please sign in to comment.