public function testPrepareTokens() { // Test priority ordering $token = ParameterConfirmationToken::prepare_tokens(array('parameterconfirmationtokentest_notoken', 'parameterconfirmationtokentest_empty', 'parameterconfirmationtokentest_noparam')); // Test no invalid tokens $this->assertEquals('parameterconfirmationtokentest_empty', $token->getName()); $token = ParameterConfirmationToken::prepare_tokens(array('parameterconfirmationtokentest_noparam')); $this->assertEmpty($token); }
// Pass back to the webserver for files that exist if (php_sapi_name() === 'cli-server' && file_exists(BASE_PATH . $url) && is_file(BASE_PATH . $url)) { return false; } } // Remove base folders from the URL if webroot is hosted in a subfolder if (substr(strtolower($url), 0, strlen(BASE_URL)) == strtolower(BASE_URL)) { $url = substr($url, strlen(BASE_URL)); } /** * Include SilverStripe's core code */ require_once 'core/startup/ErrorControlChain.php'; require_once 'core/startup/ParameterConfirmationToken.php'; // Prepare tokens and execute chain $reloadToken = ParameterConfirmationToken::prepare_tokens(array('isTest', 'isDev', 'flush')); $chain = new ErrorControlChain(); $chain->then(function ($chain) use($reloadToken) { // If no redirection is necessary then we can disable error supression if (!$reloadToken) { $chain->setSuppression(false); } // Load in core require_once 'core/Core.php'; // Connect to database require_once 'model/DB.php'; global $databaseConfig; if ($databaseConfig) { DB::connect($databaseConfig); } // Check if a token is requesting a redirect