Skip to content
Permalink
Browse files

New test to scan for mistakes with IF_PASSED directive

  • Loading branch information...
chrisgraham committed May 21, 2019
1 parent 77992da commit 165bb506d261d2e4cb14581bc957e075c04bc1db
@@ -0,0 +1,46 @@
<?php /*
Composr
Copyright (c) ocProducts, 2004-2016
See text/EN/licence.txt for full licencing information.
*/
/**
* @license http://opensource.org/licenses/cpal_1.0 Common Public Attribution License
* @copyright ocProducts Ltd
* @package testing_platform
*/
/**
* Composr test case class (unit testing).
*/
class Tempcode_mistakes_test_set extends cms_test_case
{
public function testIfPassedGuards()
{
require_code('files');
require_code('files2');
$files = get_directory_contents(get_file_base() . '/themes');
$regexp = '#\{\+START,IF_PASSED,(\w+)\}[^\{\}]*\{(?:(?!\1)\w)*\*?\}[^\{\}]*\{\+END\}#';
$exceptions = array(
'default/templates/ATTACHMENT.tpl',
'default/templates/FORM_SCREEN_INPUT_UPLOAD.tpl',
'default/templates/FORM_SCREEN_INPUT_UPLOAD_MULTI.tpl',
);
foreach ($files as $file) {
if (in_array($file, $exceptions)) {
continue;
}
if (substr($file, -4) == '.tpl') {
$c = file_get_contents(get_file_base() . '/themes/' . $file);
$this->assertTrue(preg_match($regexp, $c) == 0, 'Found dodgy looking IF_PASSED situation in ' . $file);
}
}
}
}
@@ -399,6 +399,7 @@ public function get_file_list()
'_tests/tests/unit_tests/versioning.php',
'_tests/tests/unit_tests/dev_environment.php',
'_tests/tests/unit_tests/filter_xml.php',
'_tests/tests/unit_tests/tempcode_mistakes.php',
'_tests/tests/unit_tests/upload_directory.php',
'_tests/tests/unit_tests/sitemap.php',
'_tests/tests/unit_tests/cdn_config.php',

0 comments on commit 165bb50

Please sign in to comment.
You can’t perform that action at this time.