/** * @return object * @var boolean $required * @var string $title * @var mixed $var * @var string $message * @var boolean $ini * @var boolean $negative_test */ function &testBoolean($required, $title, $var, $message = '', $ini = true, $negative_test = false) { $test = new StdClass(); $test->title = $title; if ($ini) { testIni($test, $var, 'boolean'); } else { $test->ini_val = $var; } $test->ini_val = $negative_test ? !(bool) $test->ini_val : (bool) $test->ini_val; if ($test->ini_val == false) { #list($test->continueon, $test->special_failed) = testGlobal($required); if (trim($message) != '') { $test->message = $message; } $test->value = $negative_test ? 'On' : 'Off'; $test->secondvalue = $negative_test ? lang('true') : lang('false'); if ($required) { $test->res = 'false'; #$test->res_text = getTestReturn($test->res); } else { $test->res = 'yellow'; #$test->res_text = getTestReturn($test->res); } } else { $test->value = $negative_test ? 'Off' : 'On'; $test->secondvalue = $negative_test ? lang('false') : lang('true'); if ($required) { $test->res = 'true'; #$test->res_text = getTestReturn($test->res); } else { $test->res = 'green'; #$test->res_text = getTestReturn($test->res); } } return $test; }
/** * @return object * @param boolean $required * @param string $title * @param mixed $var * @param string $message * @param mixed $minimum * @param mixed $recommended * @param boolean $ini * @param boolean $test_as_bytes * @param int $unlimited * @param string $error_fragment */ function &testRange($required, $title, $var, $message = '', $minimum, $recommended, $ini = true, $test_as_bytes = false, $unlimited = null, $error_fragment = '') { $test = new CmsInstallTest(); $test->title = $title; global $lang_fn; if ($ini) { testIni($test, $var, 'string'); if (isset($test->error)) { $required = false; } } else { $test->ini_val = $var; } $test->value = $test->ini_val; $test->secondvalue = null; if ($test_as_bytes) { $test->ini_val = returnBytes($test->ini_val); $minimum = returnBytes($minimum); $recommended = returnBytes($recommended); } if (!is_null($unlimited) && (int) $test->ini_val == (int) $unlimited) { $test->value = $lang_fn('unlimited'); $test->res = 'green'; getTestReturn($test, $required); } elseif ((int) $test->ini_val < $minimum) { $test->res = 'red'; getTestReturn($test, $required, $message, $error_fragment); } elseif ((int) $test->ini_val < $recommended) { $test->res = 'yellow'; getTestReturn($test, false, $message, $error_fragment); } else { $test->res = 'green'; getTestReturn($test, $required); } return $test; }
assert(false === $res->hasErrors()); } function testFollowRedirect() { $req = Request::get(TEST_URL . '/301')->doNotFollowRedirects()->send(); assert(301 === $req->code); $req = Request::get(TEST_URL . '/301')->followRedirects()->send(); assert(200 === $req->code); } testInit(); testMethods(); testDefaults(); testShortMime(); testSettingStrictSsl(); testSendsAndExpectsType(); testIni(); testAuthSetup(); testJsonResponseParse(); testXMLResponseParse(); testCustomParse(); testSendsSugar(); testExpectsSugar(); testNoAutoParse(); testParsingContentTypeCharset(); testStatusCodeParse(); testHasErrors(); testCustomHeader(); checkForTestServer(); testSendGet(); testSendPost(); testSendPut();