當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Test::assertEqual方法代碼示例

本文整理匯總了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);
 }
開發者ID:EyeOfMidas,項目名稱:punit-lib,代碼行數:7,代碼來源:PhockitoForMockTest.php

示例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();
開發者ID:EyeOfMidas,項目名稱:punit-lib,代碼行數:17,代碼來源:ExampleTest.php

示例3: testGreetAddsWorldWhenNameIsNotSpecified

 public function testGreetAddsWorldWhenNameIsNotSpecified()
 {
     $expected = "Hello, World";
     $actual = $this->testObj->greet("");
     Test::assertEqual($expected, $actual);
 }
開發者ID:EyeOfMidas,項目名稱:punit-lib,代碼行數:6,代碼來源:UsingClassesTest.php

示例4: assertFalse

 public function assertFalse($actual)
 {
     return Test::assertEqual(false, $actual);
 }
開發者ID:EyeOfMidas,項目名稱:punit-lib,代碼行數:4,代碼來源:Test.php

示例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'));
     */
 }
開發者ID:Mirocow,項目名稱:gpz,代碼行數:39,代碼來源:DbTableEngine.php


注:本文中的Test::assertEqual方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。