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


PHP test::assert_true方法代码示例

本文整理汇总了PHP中test::assert_true方法的典型用法代码示例。如果您正苦于以下问题:PHP test::assert_true方法的具体用法?PHP test::assert_true怎么用?PHP test::assert_true使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在test的用法示例。


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

示例1: dirname

require_once dirname(__FILE__) . '/../lib/redis.php';
require_once dirname(__FILE__) . '/../lib/redis.pool.php';
require_once dirname(__FILE__) . '/../lib/redis.peer.php';
require_once dirname(__FILE__) . '/test.lib.php';
# Config
redis_pool::add_servers(array('master' => array('127.0.0.1', 6379)));
class mock_peer extends redis_peer
{
}
# Tests
$ts = time();
$data = array('name' => 'Test', 'time' => $ts);
$p = new mock_peer();
$id = $p->insert($data);
test::assert_true($id > 0, 'Insert tests');
$v = $p->get_by_id($id);
test::assert_value($v['id'], $id);
test::assert_value($v['time'], $ts);
test::assert_value($v['name'], 'Test');
test::assert_value(count($v), 3);
$id1 = $p->insert($data);
$id2 = $p->insert($data);
$id3 = $p->insert($data);
test::assert_value($id1, $id2 - 1);
test::assert_value($id1, $id3 - 2);
$id = $p->insert($data);
$p->delete($id);
$v = $p->get_by_id($id);
test::assert_null($v, 'Delete tests');
$id = $p->insert($data);
开发者ID:otengkwame,项目名称:php-redis,代码行数:30,代码来源:unit.peer.php

示例2: array

$v = $r->get('test');
test::assert_null($v);
$r->set('test', 1);
$v = $r->get('test');
test::assert_true($v == 1);
$r->set('test', array(2, 1));
$v = $r->get('test');
test::assert_true($v == array(2, 1));
$r->set('test', null);
$v = $r->get('test');
test::assert_null($v);
$v = $r->exists('test');
test::assert_true($v);
$r->set('test', true);
$v = $r->get('test');
test::assert_true($v);
$r->set('test', false);
$v = $r->get('test');
test::assert_false($v);
$r->delete('test');
$v = $r->get('test');
test::assert_null($v);
$v = $r->exists('test');
test::assert_false($v);
# Increment/decrement
$r->delete('test');
$r->set('test', 1);
$v = $r->inc('test');
test::assert_value($v, 2, 'Increment/Decrement');
$v = $r->inc('test', 10);
test::assert_value($v, 12);
开发者ID:otengkwame,项目名称:php-redis,代码行数:31,代码来源:unit.base.php

示例3: dirname

require_once dirname(__FILE__) . '/../lib/redis.php';
require_once dirname(__FILE__) . '/../lib/redis.pool.php';
require_once dirname(__FILE__) . '/../lib/redis_set.peer.php';
require_once dirname(__FILE__) . '/test.lib.php';
# Config
redis_pool::add_servers(array('master' => array('127.0.0.1', 6379)));
class mock_set_peer extends redis_set_peer
{
}
# Tests
$p = new mock_set_peer();
$p->clear('some_set');
$p->add('some_set', 1);
$p->add('some_set', 2);
test::assert_true($p->is_member('some_set', 1), 'Adding/removing');
test::assert_true($p->is_member('some_set', 2));
test::assert_false($p->is_member('some_set', 3));
test::assert_value($p->get_count('some_set'), 2);
$set = $p->get_all('some_set');
test::assert_value(count($set), 2);
test::assert_true(in_array(2, $set));
test::assert_true(in_array(1, $set));
$p->remove('some_set', 2);
test::assert_value($p->get_count('some_set'), 1);
test::assert_false($p->is_member('some_set', 2));
test::assert_true($p->is_member('some_set', 1));
$r = $p->add('some_set', 3);
test::assert_true($r);
$r = $p->add('some_set', 3);
test::assert_false($r);
test::summary();
开发者ID:otengkwame,项目名称:php-redis,代码行数:31,代码来源:unit.set.peer.php


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