Skip to content

Commit

Permalink
Require <?php tag in tests
Browse files Browse the repository at this point in the history
This had me puzzled for some time on several occasions
  • Loading branch information
weirdan committed Mar 3, 2023
1 parent 6975acf commit 7b8a0a6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tests/Traits/InvalidCodeAnalysisTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public function testInvalidCode(
$this->markTestSkipped('Skipped due to a bug.');
}

// sanity check - do we have a PHP tag?
if (strpos($code, '<?php') === false) {
$this->fail('Test case must have a <?php tag');
}

if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$code = str_replace("\n", "\r\n", $code);
}
Expand Down
5 changes: 5 additions & 0 deletions tests/Traits/ValidCodeAnalysisTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ public function testValidCode(
$this->markTestSkipped('Skipped due to a bug.');
}

// sanity check - do we have a PHP tag?
if (strpos($code, '<?php') === false) {
$this->fail('Test case must have a <?php tag');
}

foreach ($ignored_issues as $issue_name) {
Config::getInstance()->setCustomErrorLevel($issue_name, Config::REPORT_SUPPRESS);
}
Expand Down

0 comments on commit 7b8a0a6

Please sign in to comment.