本文整理汇总了PHP中diag函数的典型用法代码示例。如果您正苦于以下问题:PHP diag函数的具体用法?PHP diag怎么用?PHP diag使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了diag函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: trec_destruct
/**
* Destructor cleanup for a test record
*
* @param Doctrine_Record $proto
* @param string $uuid
*/
function trec_destruct($proto, $uuid = null)
{
if (!$uuid) {
if (isset($proto->my_uuid)) {
$uuid = $proto->my_uuid;
} else {
return;
// nothing to delete
}
}
// setup table vars
$vars = trec_get_vars($proto);
$tbl = $proto->getTable();
$name = get_class($proto);
$conn = $tbl->getConnection();
// look for stale record
$stale = $tbl->findOneBy($vars['UUID_COL'], $uuid);
if ($stale && $stale->exists()) {
if (getenv('AIR_DEBUG')) {
diag("delete()ing stale {$name}: {$uuid}");
}
try {
// ACTUALLY ... don't turn off key checks, to get cascading deletes
// $conn->execute('SET FOREIGN_KEY_CHECKS = 0');
$stale->delete();
// $conn->execute('SET FOREIGN_KEY_CHECKS = 1');
} catch (Exception $err) {
diag($err);
}
}
// put UUID back on the stack
$vars['UUIDS'][] = $uuid;
}
示例2: test_is
function test_is($result, $expected, $explanation)
{
if ($result === $expected) {
pass($explanation);
} else {
fail($explanation);
diag("Got '{$result}'");
diag("Expected '{$expected}'");
}
}
示例3: _log_handler_test_wrapper
function _log_handler_test_wrapper($level, $msg, $more = array())
{
$type = $more['type'] ? $more['type'] : $level;
$out = '';
if ($type) {
$out .= "[{$type}] ";
}
$out .= $msg;
if ($more['time'] > -1) {
$out .= " ({$more['time']} ms)";
}
diag($out);
}
示例4: _proclaim
function _proclaim($cond, $desc = '', $todo = false, $have = null, $want = null, $negate = false)
{
global $__Test;
$__Test['run'] += 1;
# We're in a TODO block via todo_start()/todo_end(). TODO via specific
# functions is currently unimplemented and will probably stay that way
if (count($__Test['todo'])) {
$todo = true;
}
# Everything after the first # is special, so escape user-supplied messages
$desc = str_replace('#', '\\#', $desc);
$desc = str_replace("\n", '\\n', $desc);
$ok = $cond ? "ok" : "not ok";
$directive = '';
if ($todo) {
$todo_idx = count($__Test['todo']) - 1;
$directive .= ' # TODO ' . $__Test['todo'][$todo_idx];
}
printf("%s %d %s%s\n", $ok, $__Test['run'], $desc, $directive);
# report a failure
if (!$cond) {
# Every public function in this file calls _proclaim so our culprit is
# the second item in the stack
$caller = debug_backtrace();
$call = $caller['1'];
if ($have != null || $want != null) {
diag(sprintf(" Failed%stest '%s'\n in %s at line %d\n have: %s\n want: %s", $todo ? ' TODO ' : ' ', $desc, $call['file'], $call['line'], $have, $want));
} else {
diag(sprintf(" Failed%stest '%s'\n in %s at line %d", $todo ? ' TODO ' : ' ', $desc, $call['file'], $call['line']));
}
}
return $cond;
}
示例5: dirname
#!/usr/bin/php -q
<?php
require_once dirname(dirname(__FILE__)) . '/test/lib/utils.php';
require_once TEST . 'lib/Test-More.php';
require_once INC . 'config_inc.php';
require_once INC . 'utils.php';
diag('getTagggedMembersInPhoto');
plan(5);
connectDatabase();
$tagged1 = array(1, 2, 3);
$prev1 = array(1);
$result1 = getAddRemoveTaggedMembers($tagged1, $prev1);
$tagged2 = array(1, 2, 3);
$prev2 = array(4);
$result2 = getAddRemoveTaggedMembers($tagged2, $prev2);
$tagged3 = array(2);
$prev3 = array(1, 2, 3);
$result3 = getAddRemoveTaggedMembers($tagged3, $prev3);
$tagged4 = null;
$prev4 = array(1, 2, 3);
$result4 = getAddRemoveTaggedMembers($tagged4, $prev4);
$tagged5 = array(1, 2, 3);
$prev5 = null;
$result5 = getAddRemoveTaggedMembers($tagged5, $prev5);
is($result1, array('add' => array(2, 3), 'remove' => array()), 'Tagged and previous (adding)');
is($result2, array('add' => array(1, 2, 3), 'remove' => array(4)), 'Tagged and previous (adding & removing)');
is($result3, array('add' => array(), 'remove' => array(1, 3)), 'Tagged and previous (removing)');
is($result4, array('add' => array(), 'remove' => array(1, 2, 3)), 'Previous (removing)');
is($result5, array('add' => array(1, 2, 3), 'remove' => array()), 'Tagged (adding)');
示例6: _test_end
function _test_end()
{
global $_no_plan;
global $_num_failures;
global $_test_num;
if ($_no_plan) {
echo "1..{$_test_num}\n";
}
if ($_num_failures) {
diag("Looks like you failed {$_num_failures} tests of {$_test_num}.");
}
}
示例7: dirname
#!/usr/bin/php -q
<?php
require_once dirname(dirname(__FILE__)) . '/test/lib/utils.php';
require_once TEST . 'lib/Test-More.php';
require_once INC . 'config_inc.php';
require_once INC . 'utils.php';
diag('removeBBCode');
plan(3);
$matching_mixed_missing_in = '[b]bold[/b] [b]still bold[/B] [B]also bold';
$matching_mixed_missing_out = removeBBCode($matching_mixed_missing_in);
is($matching_mixed_missing_out, 'bold still bold [B]also bold', 'matching, mixed, missing');
$intermixed_in = '[b]bold [ins]inserted[/ins][/b]';
$intermixed_out = removeBBCode($intermixed_in);
is($intermixed_out, 'bold inserted', 'intermixed');
$bad_intermixed_in = '[b]bold [ins][/b]inserted[/ins]';
$bad_intermixed_out = removeBBCode($bad_intermixed_in);
is($bad_intermixed_out, 'bold inserted', 'bad intermixed');
示例8: dirname
#!/usr/bin/php -q
<?php
require_once dirname(dirname(__FILE__)) . '/test/lib/utils.php';
require_once TEST . 'lib/Test-More.php';
require_once INC . 'config_inc.php';
require_once INC . 'utils.php';
diag('cleanOutput');
plan(2);
$js_in = '<script type="text/javascript">alert("hey")</script>';
$js_out = cleanOutput($js_in);
is($js_out, 'alert("hey")', 'javascript');
$js_html_in = '<script type="text/javascript">alert("hey")</script>';
$js_html_out = cleanOutput($js_html_in, 'html');
is($js_html_out, '<script type="text/javascript">alert("hey")</script>', 'javascript html');
示例9: isset
<?php
$lib = isset($_SERVER['TESTLIB']) ? $_SERVER['TESTLIB'] : 'Test-Simple.php';
require_once $lib;
plan('no_plan');
diag('Test of deprecated Test::More functions provided for compatibility completeness.');
$foo = array(0 => 1, 1 => 'B', 2 => 'third');
$oof = array(0 => 'third', 1 => 'B', 2 => 1);
$bar = array('q' => 23, 'Y' => 42);
$rab = array('Y' => 42, 'q' => 23);
ok(eq_array($foo, $oof), 'eq_array() with misordered array is ok');
ok(eq_array($bar, $rab), 'eq_array() with misordered assoc is ok');
ok(eq_hash($foo, $oof), 'eq_hash() with misordered array is ok');
ok(eq_hash($bar, $rab), 'eq_hash() with misordered assoc is ok');
ok(eq_set($foo, $oof), 'eq_set() with misordered array is ok');
ok(eq_set($bar, $rab), 'eq_set() with misordered assoc is ok');
done_testing();
示例10: check
function check($board, $col)
{
// vertical
if (checkFour(vert($board, $col))) {
return true;
}
// horizontal
if (checkFour(horiz($board, $col))) {
return true;
}
// diagonal (right)
if (checkFour(diag($board, $col, 1))) {
return true;
}
// diagonal (left)
if (checkFour(diag($board, $col, 0))) {
return true;
}
return false;
}
示例11: dirname
#!/usr/bin/php -q
<?php
require_once dirname(dirname(__FILE__)) . '/test/lib/utils.php';
require_once TEST . 'lib/Test-More.php';
require_once INC . 'config_inc.php';
require_once INC . 'User.php';
require_once INC . 'Error.php';
require_once INC . 'Database.php';
require_once INC . 'utils.php';
require_once INC . 'constants.php';
diag("getTheme");
plan(2);
connectDatabase();
$theme_no_id = getTheme();
$theme_bad_id = getTheme(0);
is($theme_no_id, UI . 'themes/default/', 'no userid');
is($theme_bad_id, UI . 'themes/default/', 'bad userid');
示例12: isset
<?php
$lib = isset($_SERVER['TESTLIB']) ? $_SERVER['TESTLIB'] : 'Test-Simple.php';
require_once $lib;
plan(3);
diag('If PHP throws a fatal error, bail as nicely as possible.');
ok(1, "Pass one for good measure");
include_ok($lib, 'Including a library again should redefine a function and bail.');
ok(1, 'This test will not be reached.');
示例13: is
is($message->getID(), $contactMessageId, "Checking opening message ID");
is($message->getBodyContentFormat(), "txt", "Checking body content format");
diag("Setting multiple messages properties to first set");
$message->set(PidTagBody, $pidTagBody1, PidLidWorkAddressStreet, $pidLidWorkAddressStreet1, PidLidEmail1EmailAddress, $pidLidEmail1EmailAddress1);
diag("Setting one property PidTagDisplayName to first set");
$message->set(PidTagDisplayName, $pidTagDisplayName1);
$message->save();
unset($message);
diag("- Saving changes");
$message = $contacts->openMessage($contactMessageId, MAPIMessage::RW);
ok($message, "Reopening message in RW mode");
is($message->get(PidTagDisplayName), $pidTagDisplayName1, "Checking PidTagDisplayName1 has changed properly");
$multipleValues = $message->get(PidTagBody, PidLidWorkAddressStreet, PidLidEmail1EmailAddress);
is($multipleValues[PidTagBody], $pidTagBody1, "Checking value as PidTagBody (retrieved in a multiple value get)");
is($multipleValues[PidLidWorkAddressStreet], $pidLidWorkAddressStreet1, "Checking value as PidLidWorkAddressStreet (retrieved in a multiple value get)");
is($multipleValues[PidLidEmail1EmailAddress], $pidLidEmail1EmailAddress1, "Checking value as PidLidEmail1EmailAddress (retrieved in a multiple value get)");
diag("Setting values again");
$message->set(PidTagBody, $pidTagBody2, PidLidWorkAddressStreet, $pidLidWorkAddressStreet2, PidLidEmail1EmailAddress, $pidLidEmail1EmailAddress2);
$message->set(PidTagDisplayName, $pidTagDisplayName2);
$message->save();
unset($message);
diag("- Saving last changes");
$message = $contacts->openMessage($contactMessageId, MAPIMessage::RO);
ok($message, "Reopening message in RO mode");
is($message->get(PidTagDisplayName), $pidTagDisplayName2, "Checking PidTagDisplayName2 has changed properly");
$multipleValues = $message->get(PidTagBody, PidLidWorkAddressStreet, PidLidEmail1EmailAddress);
is($multipleValues[PidTagBody], $pidTagBody2, "Checking value as PidTagBody (retrieved in a multiple value get)");
is($multipleValues[PidLidWorkAddressStreet], $pidLidWorkAddressStreet2, "Checking value as PidLidWorkAddressStreet (retrieved in a multiple value get)");
is($multipleValues[PidLidEmail1EmailAddress], $pidLidEmail1EmailAddress2, "Checking value as PidLidEmail2EmailAddress (retrieved in a multiple value get)");
unset($message);
endTestSuite("message.php");
示例14: isset
<?php
$lib = isset($_SERVER['TESTLIB']) ? $_SERVER['TESTLIB'] : 'Test-More.php';
require_once $lib;
plan('no_plan');
diag("Assertions:");
is_deeply(NULL, NULL);
is_deeply(TRUE, TRUE);
is_deeply(FALSE, FALSE);
is_deeply(42, 42);
is_deeply('abcdef', 'abcdef');
is_deeply(array(), array());
is_deeply(array(1), array(1));
is_deeply(array(array()), array(array()));
is_deeply(array(array(123)), array(array(123)));
is_deeply(array(1, 'abc'), array(0 => 1, 1 => 'abc'));
diag("Denials:");
isnt_deeply(NULL, TRUE, 'NULL !== TRUE');
isnt_deeply(NULL, FALSE, 'NULL !== FALSE');
isnt_deeply(NULL, 0, 'NULL !== 0');
isnt_deeply(NULL, '', "NULL !== ''");
isnt_deeply(0, FALSE, '0 !== FALSE');
isnt_deeply(1, TRUE, '1 !== TRUE');
示例15: dirname
#!/usr/bin/php -q
<?php
require_once dirname(dirname(__FILE__)) . '/test/lib/utils.php';
require_once TEST . 'lib/Test-More.php';
require_once INC . 'config_inc.php';
require_once INC . 'utils.php';
diag('parse');
plan(3);
define('URL_PREFIX', '');
$in_str_entities = '<a href="#">link</a>';
$out_str_entities = '<a href="#">link</a>';
$in_str_smilies = ':(:smile:';
$out_str_smilies = '<img src="' . URL_PREFIX . 'ui/smileys/sad.gif" alt=":("/><img src="' . URL_PREFIX . 'ui/smileys/smile.gif" alt=":smile:"/>';
$in_str_spaces = 'line 1
line 2
line 4
line 8';
$out_str_spaces = 'line 1<br/>line 2<br/><br/>line 4<br/><br/><br/><br/>line 8';
is($out_str_entities, parse($in_str_entities), 'htmlentities');
is($out_str_smilies, parse($in_str_smilies), 'smilies');
is($out_str_spaces, parse($in_str_spaces), 'spacing');