<?php // runtest interface // get the option $options = Snap_Request::getLongOptions(array('file' => 'null', 'test' => 'null', 'klass' => 'null')); if (!$options['file']) { echo ''; exit; } $file = $options['file']; $test = $options['test']; $klass = $options['klass']; // decrypt if required if (SNAP_WI_CRYPT) { $file = snap_decrypt($file, SNAP_WI_CRYPT); } // ensure file path matches test path prefix $file = str_replace(array('..', '//'), array('.', '/'), $file); if (!is_file($file)) { echo ''; exit; } if (strpos($file, SNAP_WI_TEST_PATH) !== 0 || !preg_match('#' . SNAP_WI_TEST_MATCH . '#', $file)) { echo ''; exit; } // file is safe, check test and klass if (!$test || !$klass) { echo ''; exit; }
<?php // loadtests module. Scans a file, and adds all tests found to an array // get the option $options = Snap_Request::getLongOptions(array('file' => 'null')); if (!$options['file']) { echo ''; exit; } $file = $options['file']; $file_original = $options['file']; // decrypt if required if (SNAP_WI_CRYPT) { $file = snap_decrypt($file, SNAP_WI_CRYPT); } // ensure file path matches test path prefix $file = str_replace(array('..', '//'), array('.', '/'), $file); if (!is_file($file)) { echo ''; exit; } if (strpos($file, SNAP_WI_TEST_PATH) !== 0 || !preg_match('#' . SNAP_WI_TEST_MATCH . '#', $file)) { echo ''; exit; } $analyzer = new Snap_FileAnalyzer(); $results = $analyzer->analyzeFile($file); $output = array(); foreach ($results as $klassname => $classes) { if (!is_array($classes)) { $out = array();
<?php // snaptest web core initialization // requires PHP 5.2+ if (version_compare(phpversion(), '5.0.0') < 0) { echo "\n"; echo "SnapTest requires a PHP version >= 5.0.0\n"; exit; } define('SNAPTEST_CLI_INTERFACE', FALSE); require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'constants.php'; $options = Snap_Request::getLongOptions(array('mode' => 'index', 'key' => '')); require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'util' . DIRECTORY_SEPARATOR . 'webfiles' . DIRECTORY_SEPARATOR . 'functions.php'; Snap_Request::setURLBase(SNAP_WI_URL_PATH); switch ($options['mode']) { case 'index': include SNAPTEST_WEBFILES . 'index.php'; exit; case 'resource': include SNAPTEST_WEBFILES . 'resource.php'; exit; case 'getfiles': include SNAPTEST_WEBFILES . 'getfiles.php'; exit; case 'loadtests': include SNAPTEST_WEBFILES . 'loadtests.php'; exit; case 'runtest': include SNAPTEST_WEBFILES . 'runtest.php'; exit; default:
<?php // requires PHP 5.2+ if (version_compare(phpversion(), '5.0.0') < 0) { echo "\n"; echo "SnapTest requires a PHP version >= 5.0.0\n"; exit; } define('SNAPTEST_CLI_INTERFACE', TRUE); require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'constants.php'; $options = Snap_Request::getLongOptions(array(0 => '', 'out' => 'text', 'php' => 'php', 'match' => '^.*\\.stest\\.php$', 'help' => FALSE, 'test' => '', 'analyze' => FALSE, 'verbose' => FALSE)); $path = str_replace('\\ ', ' ', $options[0]); $out_mode = $options['out']; $php = $options['php']; $xtn = $options['match']; $help = $options['help']; $test = $options['test']; $analyze = $options['analyze']; define('SNAPTEST_VERBOSE_MODE', $options['verbose']); writelog('Initialized'); // help output if no path is specified if ((!$path || $help) && !$test) { echo SNAP_usage(); exit; } // okay, there is some sort of path, get a realpath for it $path = realpath($path); // analyze subprocess if ($analyze) { writelog('Doing analyze substep'); $analyzer = new Snap_FileAnalyzer();