当前位置: 首页>>代码示例>>PHP>>正文


PHP test_case函数代码示例

本文整理汇总了PHP中test_case函数的典型用法代码示例。如果您正苦于以下问题:PHP test_case函数的具体用法?PHP test_case怎么用?PHP test_case使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了test_case函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: 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

示例3: __construct

{
    public function __construct(\Pimple\Container $container)
    {
        $this->container = $container;
    }
    public function get($id)
    {
        return $this->container->offsetGet($id);
    }
    public function has($id)
    {
    }
}
test('pimple test-case is identical to unbox test-case', function () {
    $container = (require __DIR__ . '/bootstrap-pimple.php');
    test_case(new PimpleTestAdapter($container));
});
test('can resolve dependencies using dependency maps', function () {
    $container = new Container();
    $container->set('cache.path', '/tmp/cache');
    $container->register('cache', function ($path) {
        return new FileCache($path);
    }, [$container->ref('cache.path')]);
    $container->register(UserRepository::class, function (CacheProvider $cp) {
        return new UserRepository($cp);
    }, ['cp' => $container->ref('cache')]);
    $repo = $container->get(UserRepository::class);
    ok($repo instanceof UserRepository);
    ok($repo->cache instanceof CacheProvider);
    eq($repo->cache->path, '/tmp/cache');
});
开发者ID:boan2010,项目名称:unbox,代码行数:31,代码来源:test.php

示例4: test_instanceof

        //ERROR: please use ':', not ';'
        case 2:
            return 2;
        default:
            return 42;
    }
}
class MiscA
{
}
class MiscB
{
}
function test_instanceof()
{
    $x = new MiscA();
    if ($x instanceof MiscA) {
    }
    //ERROR: please use 'instanceof'
    if ($x instanceof MiscA) {
    }
}
var_dump(test_case());
interface TestInterfaceWithBody
{
    public function foo();
    //ERROR: interface method with a body
    public function wtf_is_this()
    {
    }
}
开发者ID:Halfnhav4,项目名称:pfff,代码行数:31,代码来源:misc.php

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: file_put_contents

    $p2->SetDataValues($data);
    $p2->SetDataType($like);
    // Base data type - alias should match this
    $p2->SetPlotType($plot_type);
    $p2->DrawGraph();
    $p2_image = $p2->EncodeImage('raw');
    if ($test_save) {
        file_put_contents("dta-{$case}b_{$like}.png", $p2_image);
    }
    if ($p1_image == $p2_image) {
        $n_pass++;
        if ($test_verbose) {
            echo "Pass: {$title}\n";
        }
    } else {
        $n_fail++;
        echo "FAIL - Image Mismatch: {$title}\n";
    }
}
# ===== Test Cases =====
# Test all cases:
for ($case = 0; $case < $n_cases; $case++) {
    test_case($case);
}
# ======== End of test cases and error reporting ==========
# Option: Use basename of file, or replace with a string.
echo basename(__FILE__) . " results: {$n_tests} test cases, {$n_pass} pass, {$n_fail} fail\n";
if ($n_fail > 0) {
    exit(1);
}
# PHPlot test suite requires falling off the end, not exit, on success.
开发者ID:myfarms,项目名称:PHPlot,代码行数:31,代码来源:dtaliases.php

示例11: 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


注:本文中的test_case函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。