本文整理汇总了PHP中Test::assertEqual方法的典型用法代码示例。如果您正苦于以下问题:PHP Test::assertEqual方法的具体用法?PHP Test::assertEqual怎么用?PHP Test::assertEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Test
的用法示例。
在下文中一共展示了Test::assertEqual方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGreetNameReturnsWorldWhenGeneratorIsBlank
public function testGreetNameReturnsWorldWhenGeneratorIsBlank()
{
Phockito::when($this->nameGenerator)->generate()->return("");
$actual = $this->testObj->greet();
$expected = "Hello, World";
Test::assertEqual($expected, $actual);
}
示例2: array
<?php
require_once "../PUnit.php";
echo "Tautology: ";
Test::assertTrue(true);
Test::report();
echo "Multi with failure: ";
Test::assertEqual("abc", "123");
Test::assertEqual(12.3, 12.3);
Test::assertEqual(array("joe", "bloggs"), array("joe", "bloggs"));
Test::report();
echo "Deep array failure: ";
$expected = array("data" => true, "structure" => array("top" => 123, "left" => "abc"));
$actual = array("data" => true, "structure" => array("top" => 123, "left" => "abcde"));
Test::assertEqual($expected, $actual);
Test::report();
Test::end();
示例3: testGreetAddsWorldWhenNameIsNotSpecified
public function testGreetAddsWorldWhenNameIsNotSpecified()
{
$expected = "Hello, World";
$actual = $this->testObj->greet("");
Test::assertEqual($expected, $actual);
}
示例4: assertFalse
public function assertFalse($actual)
{
return Test::assertEqual(false, $actual);
}
示例5: runTests
public static function runTests()
{
/**
* TODO:
* 1. Auto-create table
* 2. Handle expiration date
*/
$sql = "DROP TABLE IF EXISTS `%1\$s`;\nCREATE TABLE `%1\$s` (\n `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n `created` datetime NOT NULL,\n `modified` datetime DEFAULT NULL,\n `expires` datetime DEFAULT NULL,\n `hash` varchar(40) NOT NULL,\n `key` text,\n `value` longtext,\n `used` int(11) unsigned NOT NULL DEFAULT '0',\n PRIMARY KEY (`id`),\n UNIQUE KEY `hash` (`hash`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$model = new AppModel(0, false);
$model->query(sprintf($sql, 'cache_test'));
$model->query(sprintf($sql, 'cache_test2'));
$cache = new AppModel(0, 'cache_test');
$cache2 = new AppModel(0, 'cache_test2');
Cache::config('default', array('engine' => 'DbTable', 'duration' => '+1 days', 'storage' => 'cache_test', 'lock' => false, 'serialize' => true));
Cache::config('testcache2', array('engine' => 'DbTable', 'duration' => false, 'storage' => 'cache_test2', 'lock' => false, 'serialize' => true));
App::uses('Test', 'Vendor');
$key1 = 'testkey1';
$key2 = 'testkey_2';
$key3 = 'sometestkey3';
$value1 = 'some value1';
$value2 = 2;
$value3 = array('key1' => 'value1', 'key2' => 'value_2');
// Test 1 - read empty cache
Test::assertEqual('Test1', array(null, null), array(Cache::read($key1), Cache::read($key3, 'testcache2')));
// Test 2 - write cache on diff.configs
$time = time();
$dt = date('Y-m-d H:i:s', $time);
$dt2 = date('Y-m-d H:i:s', $time + DAY);
// Cache::write($key1, $value1);
Cache::write($key2, $value2, 'testcache2');
// Cache::write($key3, $value3);
$trueRes = array(array(array('AppModel' => array('id' => '1', 'created' => $dt, 'modified' => $dt, 'expires' => $dt2, 'hash' => sha1($key1), 'key' => $key1, 'value' => serialize($value1), 'used' => '0')), array('AppModel' => array('id' => '2', 'created' => $dt, 'modified' => $dt, 'expires' => $dt2, 'hash' => sha1($key3), 'key' => $key3, 'value' => serialize($value3), 'used' => '0'))), array(array('AppModel' => array('id' => '1', 'created' => $dt, 'modified' => $dt, 'expires' => null, 'hash' => sha1($key2), 'key' => $key2, 'value' => serialize($value2), 'used' => '0'))));
Test::assertEqual('Test2', $trueRes, array($cache->find('all'), $cache2->find('all')));
/*
$sql = 'DROP TABLE IF EXISTS `%s`';
$model->query(sprintf($sql, 'cache_test'));
$model->query(sprintf($sql, 'cache_test2'));
*/
}