* @since Class available since 0.7 */ class CrashTester extends CustomTester { /** * @param string $htaccessRules The rules to check * @param string $subSubDir subdir for the test files. If not supplied, a fingerprint of the rules will be used */ public function __construct($htaccessRules, $subSubDir = null) { if (is_null($subSubDir)) { $subSubDir = hash('md5', $htaccessRules); } $test = [ 'subdir' => 'crash-tester/' . $subSubDir, 'subtests' => [ [ 'subdir' => 'the-suspect', 'files' => [ ['.htaccess', $htaccessRules], ['request-me.txt', 'thanks'], ], 'request' => [ 'url' => 'request-me.txt', 'bypass-standard-error-handling' => ['403', '404', '500'] ], 'interpretation' => [ ['success', 'status-code', 'not-equals', '500'], // Otherwise fall through to next subtest ] ], [ 'subdir' => 'the-innocent', 'files' => [ ['.htaccess', '# I am no trouble'], ['request-me.txt', 'thanks'], ], 'request' => [ 'url' => 'request-me.txt', 'bypass-standard-error-handling' => ['403', '404', '500'] ], 'interpretation' => [ // The suspect crashed. But if the innocent crashes too, we cannot judge ['inconclusive', 'status-code', 'equals', '500'], // The innocent did not crash. The suspect is guilty! ['failure'], ] ], ] ]; parent::__construct($test); } /** * Child classes must implement this method, which tells which subdir the * test files are to be put. * * @return string A subdir for the test files */ public function getSubDir() { return 'crash-tester'; } }