Skip to content

Commit

Permalink
Merge pull request #9443 from weirdan/require-php-tag-in-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Mar 3, 2023
2 parents 6975acf + 7b8a0a6 commit b1b2010
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
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
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 b1b2010

Please sign in to comment.