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


PHP assert_equal函数代码示例

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


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

示例1: test_test_before_each_assert_method

function test_test_before_each_assert_method()
{
    global $val;
    assert_null($val);
    $val = 400;
    assert_equal(&$val, 10, '$val should be 10, not 400');
}
开发者ID:sniemela,项目名称:limonade,代码行数:7,代码来源:tests.php

示例2: test_http_ua_accepts

   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");
     
     $response =  test_request(TESTS_DOC_ROOT.'05-content_negociation.php', 'GET', false, array(), array("Accept: image/png"));
     assert_equal("Oops", $response);
     
     $response =  test_request(TESTS_DOC_ROOT.'05-content_negociation.php', 'GET', false, array(), array("Accept: text/html"));
     assert_equal("<h1>HTML</h1>", $response);
     
     $response =  test_request(TESTS_DOC_ROOT.'05-content_negociation.php', 'GET', false, array(), array("Accept: application/json"));
     assert_equal("json", $response);
   }
开发者ID:neochrome,项目名称:limonade,代码行数:30,代码来源:http.php

示例3: test_output_render

function test_output_render()
{
    $response = test_request(URL_FOR_OUTPUT_TEST . '/render0', 'GET');
    assert_equal($response, "Lorem ipsum dolor sit amet.");
    $response = test_request(URL_FOR_OUTPUT_TEST . '/render1', 'GET');
    assert_equal($response, "Lorem % ipsum dolor sit amet.");
}
开发者ID:sniemela,项目名称:limonade,代码行数:7,代码来源:output.php

示例4: test_array_path_to_name

 function test_array_path_to_name()
 {
     $expect = array('foo' => 'foo', 'foo.bar' => 'foo[bar]', 'foo.bar.baz' => 'foo[bar][baz]');
     foreach ($expect as $in => $out) {
         assert_equal($out, array_path_to_name($in));
     }
 }
开发者ID:jaz303,项目名称:php-helpers,代码行数:7,代码来源:array_path_test.php

示例5: assert_no_difference

function assert_no_difference($expression, $lambda)
{
    $expression = 'return ' . $expression . ';';
    $value = eval($expression);
    $lambda();
    assert_equal($value, eval($expression));
}
开发者ID:rm9233,项目名称:curl,代码行数:7,代码来源:test_helper.php

示例6: test_interface_delegation

 public function test_interface_delegation()
 {
     parse_and_eval(dirname(__FILE__) . '/interface_delegation_test_interface.phpx');
     parse_and_eval(dirname(__FILE__) . '/interface_delegation_test_class.phpx');
     $a = new EIDTC_Addressable();
     assert_equal("message sent to foo@bar.com", $a->send_to("foo@bar.com"));
 }
开发者ID:jaz303,项目名称:phpx,代码行数:7,代码来源:interface_delegation_test.php

示例7: test_auto_quote_array

 public function test_auto_quote_array()
 {
     $out = $this->db->auto_quote_array(array('s:s1' => 'foobar', 'str:s2' => 'bar', 'string:s3' => 'moose', 'b:b1' => true, 'bool:b2' => false, 'boolean:b3' => true, 'f:f1' => 1.23, 'float:f2' => 2.46, 'i:i1' => 100, 'int:i2' => 120, 'integer:i3' => 140, 'x:x1' => 'sadasd', 'binary:x2' => '1315ft4g'));
     $expect = array('s1' => $this->db->quote_string('foobar'), 's2' => $this->db->quote_string('bar'), 's3' => $this->db->quote_string('moose'), 'b1' => $this->db->quote_boolean(true), 'b2' => $this->db->quote_boolean(false), 'b3' => $this->db->quote_boolean(true), 'f1' => $this->db->quote_float(1.23), 'f2' => $this->db->quote_float(2.46), 'i1' => $this->db->quote_integer(100), 'i2' => $this->db->quote_integer(120), 'i3' => $this->db->quote_integer(140), 'x1' => $this->db->quote_binary('sadasd'), 'x2' => $this->db->quote_binary('1315ft4g'));
     foreach ($expect as $k => $v) {
         assert_equal($v, $out[$k]);
     }
 }
开发者ID:jaz303,项目名称:base-php,代码行数:8,代码来源:quoting_test.php

示例8: test_mixins

 public function test_mixins()
 {
     parse_and_eval(dirname(__FILE__) . '/mixin_test_mixins.phpx');
     parse_and_eval(dirname(__FILE__) . '/mixin_test_classes.phpx');
     $thing = new EMT_Foo();
     assert_equal('foo', $thing->foo());
     assert_equal('bar', EMT_Foo::bar());
     assert_equal('baz', EMT_Foo::BAZ);
 }
开发者ID:jaz303,项目名称:phpx,代码行数:9,代码来源:mixin_test.php

示例9: test_annotations

 public function test_annotations()
 {
     parse_and_eval(dirname(__FILE__) . '/annotation_test_class.phpx');
     assert_equal(array('model' => true), phpx\annotations_for('ExamplesAnnotationTestClass'));
     assert_equal(array('model' => true), phpx\annotations_for(new ExamplesAnnotationTestClass()));
     assert_equal(array('foo' => 'bar'), phpx\annotations_for('ExamplesAnnotationTestClass', '$baz'));
     assert_equal(array('foo' => 'bar'), phpx\annotations_for(new ExamplesAnnotationTestClass(), '$baz'));
     assert_equal(array('access' => array('admin', 'public')), phpx\annotations_for('ExamplesAnnotationTestClass', 'find_all'));
     assert_equal(array('access' => array('admin', 'public')), phpx\annotations_for(new ExamplesAnnotationTestClass(), 'find_all'));
 }
开发者ID:jaz303,项目名称:phpx,代码行数:10,代码来源:annotation_test.php

示例10: test_test_before_each_assert_method

function test_test_before_each_assert_method()
{
    global $val;
    assert_null($val);
    $val = 400;
    assert_true(true);
    // run before_each_assert_in_test() first
    // so now
    assert_equal($val, 10, '$val should be 10, not 400');
}
开发者ID:Energeyser,项目名称:projet_framework,代码行数:10,代码来源:tests.php

示例11: test_file_path

function test_file_path()
{
    $p = "/one/two/three";
    assert_equal(file_path('/one', 'two', 'three'), $p);
    assert_equal(file_path('/one', '/two', 'three'), $p);
    assert_equal(file_path('/one', 'two', '///three'), $p);
    assert_equal(file_path('/one', 'two', 'three/'), $p . '/');
    assert_equal(file_path('/one', 'two', 'three//'), $p . '/');
    assert_equal(file_path('/one', '\\two', '\\three//'), $p . '/');
}
开发者ID:karupanerura,项目名称:isucon4,代码行数:10,代码来源:file.php

示例12: test_mixins

 public function test_mixins()
 {
     phpx\register_macro('ecet_greet', 'ECET_GreetMacro');
     parse_and_eval(dirname(__FILE__) . '/class_eval_test_class.phpx');
     assert_equal(15, ExamplesClassEvalTestClass::add(10, 5));
     $foo = new ExamplesClassEvalTestClass();
     $foo->set_foo('hello world');
     assert_equal('HELLO WORLD', $foo->get_foo());
     assert_equal('Hello Jason', $foo->greet('Jason'));
 }
开发者ID:jaz303,项目名称:phpx,代码行数:10,代码来源:class_eval_test.php

示例13: test_http_redirect

function test_http_redirect()
{
    $url = TESTS_DOC_ROOT . '09-redirect.php?/';
    $response = test_request($url, 'GET');
    assert_equal($response, '/redirected');
    $response = test_request($url . '&key1=value1', 'GET');
    assert_equal($response, '/redirected&key1=value1');
    $response = test_request($url . '&key1=value1&key2=value2', 'GET');
    assert_equal($response, '/redirected&key1=value1&key2=value2');
}
开发者ID:karupanerura,项目名称:isucon4,代码行数:10,代码来源:http.php

示例14: test_equal

 public function test_equal()
 {
     assert_equal(1, 1);
     assert_equal(1, "1");
     assert_fails(function () {
         assert_equal(1, 2);
     });
     assert_fails(function () {
         assert_equal(1, "2");
     });
 }
开发者ID:jaz303,项目名称:ztest,代码行数:11,代码来源:TestAssertions.php

示例15: test_mixins

 public function test_mixins()
 {
     parse_and_eval(dirname(__FILE__) . '/hierarchy_test_1.phpx');
     parse_and_eval(dirname(__FILE__) . '/hierarchy_test_2.phpx');
     parse_and_eval(dirname(__FILE__) . '/hierarchy_test_3.phpx');
     $class_def = \phpx\Library::get_class_definition('\\HHT3');
     $hierarchy = $class_def->get_class_hierarchy();
     assert_equal(3, count($hierarchy));
     assert_equal('\\HHT1', $hierarchy[0]->get_qualified_name());
     assert_equal('\\HHT2', $hierarchy[1]->get_qualified_name());
     assert_equal('\\HHT3', $hierarchy[2]->get_qualified_name());
 }
开发者ID:jaz303,项目名称:phpx,代码行数:12,代码来源:hierarchy_test.php


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