本文整理汇总了PHP中test_case_describe函数的典型用法代码示例。如果您正苦于以下问题:PHP test_case_describe函数的具体用法?PHP test_case_describe怎么用?PHP test_case_describe使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了test_case_describe函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: test_case
<?php
test_case("Router");
test_case_describe("Testing limonade router functions.");
function before_each_test_in_router()
{
route_reset();
}
function test_router_build_route()
{
assert_trigger_error('route_build', array('UNKOWN', '/', 'aaa'));
/* testing route returned array */
$r = route_build("GET", "/index", 'get_index');
assert_equal($r["method"], "GET");
assert_equal($r["pattern"], "#^/index(?:/*?)?\$#i");
assert_empty($r["names"]);
assert_equal($r["function"], "get_index");
/* testing very simple route with no parameters */
assert_match($r["pattern"], "/index");
assert_no_match($r["pattern"], "/other");
assert_no_match($r["pattern"], "/");
assert_no_match($r["pattern"], "/index/1");
/* testing empty route */
$r = route_build("GET", "/", 'get_index');
assert_match($r["pattern"], "/");
assert_match($r["pattern"], "");
assert_no_match($r["pattern"], "/test2");
$r = route_build("GET", "", 'get_index');
assert_match($r["pattern"], "/");
assert_match($r["pattern"], "");
assert_no_match($r["pattern"], "/test2");
开发者ID:robotmay,项目名称:limonade,代码行数:31,代码来源:router.php
示例2: endtestcase
/**
* Displays and ending the current tests suite
*
* @return void
*/
function endtestcase()
{
$name = $GLOBALS["limonade"]["test_case_current"];
echo "## " . strtoupper($name) . "\n";
$desc = test_case_describe();
if (!is_null($desc)) {
echo $desc . "\n";
}
echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n";
test_case_execute_current();
if (!is_null($name)) {
$test = $GLOBALS["limonade"]["test_cases"][$name];
// closing previous test
echo "\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n";
echo $test['failures'] > 0 ? test_cli_format("|FAILED!|", "red") : test_cli_format("|PASSED|", "green");
echo " Test case '{$name}' finished: ";
echo count(test_case_all_func()) . " tests, ";
echo " {$test['failures']} failures for {$test['assertions']} assertions.\n";
echo "-----------------------------------------------------------\n";
}
$GLOBALS["limonade"]["test_case_current"] = null;
}
开发者ID:sofadesign,项目名称:fizzy,代码行数:27,代码来源:tests.php
示例3: header
<?php
if (!defined('LIMONADE')) {
$h = "HTTP/1.0 401 Unauthorized";
header($h);
die($h);
}
// Security check
test_case("Functional");
test_case_describe("Functional tests");
function before_each_test_in_functional()
{
env(null);
}
function test_functional_request()
{
$response = test_request(TESTS_DOC_ROOT . '01-hello_world.php', 'GET', true);
//echo $response;
assert_header($response, 'Content-type', 'text/html');
}
end_test_case();
开发者ID:sniemela,项目名称:limonade,代码行数:21,代码来源:functional.php
示例4: test_case
<?php
test_case("Test");
test_case_describe("Testing test and assertions functions.\n" . "Must run first, before all other tests.");
function before_each_test_in_test()
{
// echo "// test_before_test(): executed before each test\n";
global $val;
$val = NULL;
}
function before_each_assert_in_test()
{
// echo "// test_before_test(): executed before each test\n";
global $val;
$val = 10;
}
// fake function for test purpose
function my_triggering_error_func($trigger)
{
if ($trigger) {
trigger_error("Mmmm... error", E_USER_ERROR);
}
}
// tests
function test_test_simple_assertions()
{
assert_true(true);
assert_false(false);
assert_equal("aaa", "aaa");
assert_not_equal("aaas", "aaa");
}
开发者ID:Energeyser,项目名称:projet_framework,代码行数:31,代码来源:tests.php
示例5: test_case
<?php
test_case("Output");
test_case_describe("Testing limonade output functions.");
if (!defined('URL_FOR_OUTPUT_TEST')) {
define('URL_FOR_OUTPUT_TEST', TESTS_DOC_ROOT . '02-outputs.php');
}
function before_each_test_in_output()
{
env(null);
option('encoding', 'utf-8');
}
function test_output_layout()
{
}
function test_output_render()
{
$lorem = "Lorem ipsum dolor sit amet.";
$q_lorem = preg_quote($lorem);
# Testing standard rendering with sprint string
assert_equal(render($lorem), $lorem);
assert_equal(render($lorem, null, array('unused')), $lorem);
assert_equal(render("Lorem %s dolor sit amet.", null, array('ipsum')), $lorem);
assert_equal(render("Lorem %s dolor sit amet.", null, array('var1' => 'ipsum')), $lorem);
$response = test_request(URL_FOR_OUTPUT_TEST . '/render0', 'GET');
assert_equal($response, $lorem);
$response = test_request(URL_FOR_OUTPUT_TEST . '/render1', 'GET');
assert_equal($response, $lorem);
# Testing rendering with a view (inline function case)
$view = '_test_output_html_hello_world';
$html = render($view);
开发者ID:jblanche,项目名称:limonade,代码行数:31,代码来源:output.php
示例6: header
<?php
if (!defined('LIMONADE')) {
$h = "HTTP/1.0 401 Unauthorized";
header($h);
die($h);
}
// Security check
test_case("File");
test_case_describe("Testing limonade file functions.");
function before_each_test_in_file()
{
}
function test_file_mime_type()
{
$mimes = mime_type();
assert_true(is_array($mimes));
assert_not_empty($mimes);
assert_empty(mime_type(''));
assert_null(mime_type('unknown_extension'));
assert_equal(mime_type('txt'), 'text/plain');
assert_equal(mime_type('TXT'), 'text/plain');
assert_equal(mime_type('jpg'), 'image/jpeg');
assert_equal(mime_type('JPG'), 'image/jpeg');
}
function test_file_extension()
{
assert_equal(file_extension('my_file'), '');
assert_equal(file_extension('my_file.txt'), 'txt');
assert_equal(file_extension('my_file.html.php'), 'php');
assert_equal(file_extension('my_file.JPG'), 'JPG');
开发者ID:karupanerura,项目名称:isucon4,代码行数:31,代码来源:file.php
示例7: header
<?php
if (!defined('LIMONADE')) {
$h = "HTTP/1.0 401 Unauthorized";
header($h);
die($h);
}
// Security check
test_case("HTTP");
test_case_describe("Testing limonade HTTP utils functions.");
function test_http_response_status_code()
{
$response = test_request(TESTS_DOC_ROOT . '02-outputs.php/render0', 'GET', true);
assert_match("/HTTP\\/1\\./", $response);
assert_status($response, 200);
}
function test_http_ua_accepts()
{
$env = env();
$env['SERVER']['HTTP_ACCEPT'] = null;
assert_true(http_ua_accepts('text/plain'));
$env['SERVER']['HTTP_ACCEPT'] = 'text/html';
assert_true(http_ua_accepts('html'));
$env['SERVER']['HTTP_ACCEPT'] = 'text/*; application/json';
assert_true(http_ua_accepts('html'));
assert_true(http_ua_accepts('text/html'));
assert_true(http_ua_accepts('text/plain'));
assert_true(http_ua_accepts('application/json'));
assert_false(http_ua_accepts('image/png'));
assert_false(http_ua_accepts('png'));
assert_true(defined('TESTS_DOC_ROOT'), "Undefined 'TESTS_DOC_ROOT' constant");
开发者ID:karupanerura,项目名称:isucon4,代码行数:31,代码来源:http.php
示例8: test_case
<?php
if(!defined('LIMONADE')){$h="HTTP/1.0 401 Unauthorized";header($h);die($h);}// Security check
test_case("Main");
test_case_describe("Testing limonade main functions.");
function before_each_test_in_main()
{
env(null);
}
function test_main_option()
{
assert_true(is_array(option()));
assert_true(is_array(option(null)));
assert_empty(option());
$my_first_option = option('my_first_option');
assert_true(empty($my_first_option));
assert_not_equal(option('my_first_option', 'my first value'), 123);
assert_true(is_string(option('my_first_option')));
assert_equal(option('my_first_option'), 'my first value');
assert_equal(option('my_first_option'), 'my first value');
assert_true(is_array(option('my_first_option', 123, 456)));
$my_first_option = option('my_first_option');
assert_equal($my_first_option[0], 123);
assert_equal($my_first_option[1], 456);
}
function test_main_params()
{
assert_empty(params());
开发者ID:reith2004,项目名称:limonade,代码行数:31,代码来源:main.php
示例9: test_case
<?php
test_case("Request");
test_case_describe("Testing limonade request functions.");
function before_each_test_in_request()
{
env(null);
}
function test_request_methods()
{
$m = request_methods();
assert_length_of($m, 5);
}
function test_request_method_is_allowed()
{
assert_true(request_method_is_allowed("GET"));
assert_true(request_method_is_allowed("get"));
assert_true(request_method_is_allowed("POST"));
assert_true(request_method_is_allowed("PUT"));
assert_true(request_method_is_allowed("DELETE"));
assert_true(request_method_is_allowed("HEAD"));
}
function test_request_method()
{
$env = env();
$env['SERVER']['REQUEST_METHOD'] = null;
assert_trigger_error("request_method");
$methods = request_methods();
foreach ($methods as $method) {
$env['SERVER']['REQUEST_METHOD'] = $method;
assert_equal(request_method($env), $method);
开发者ID:sniemela,项目名称:limonade,代码行数:31,代码来源:request.php
示例10: end_test_case
/**
* Displays and ending the current tests suite.
*
* @return void
*/
function end_test_case()
{
$name = $GLOBALS['limonade']['test_case_current'];
echo '## ' . strtoupper($name) . "\n";
$desc = test_case_describe();
if (!is_null($desc)) {
echo $desc . "\n";
}
echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n";
test_case_execute_current();
if (!is_null($name)) {
$test = $GLOBALS['limonade']['test_cases'][$name];
// closing previous test
echo "\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n";
echo $test['failures'] > 0 ? test_cli_format('|FAILED!|', 'red') : test_cli_format('|PASSED|', 'green');
echo " Test case '{$name}' finished: ";
echo count(test_case_all_func()) . ' tests, ';
echo " {$test['failures']} failures for {$test['assertions']} assertions.\n";
echo "-----------------------------------------------------------\n";
}
$GLOBALS['limonade']['test_case_current'] = null;
}
开发者ID:nsystem1,项目名称:leaderboard,代码行数:27,代码来源:tests.php
注:本文中的test_case_describe函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论