Annotation of embedaddon/php/ext/pdo_mysql/tests/pdo_mysql_attr_server_info.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: PDO::ATTR_SERVER_INFO
3: --SKIPIF--
4: <?php
5: require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
6: require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
7: MySQLPDOTest::skip();
8: $db = MySQLPDOTest::factory();
9: ?>
10: --FILE--
11: <?php
12: require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
13: $db = MySQLPDOTest::factory();
14:
15: assert(('' == $db->errorCode()) || ('00000' == $db->errorCode()));
16:
17: $info = $db->getAttribute(PDO::ATTR_SERVER_INFO);
18: if ('' == $info)
19: printf("[001] Server info must not be empty\n");
20:
21: // Read-only?
22: if (false !== $db->setAttribute(PDO::ATTR_SERVER_INFO, 'new uptime: 0s'))
23: printf("[002] Wonderful, I can change the client version!\n");
24:
25: $new_info = $db->getAttribute(PDO::ATTR_SERVER_INFO);
1.1.1.2 ! misho 26: if (soundex($new_info) != soundex($info))
1.1 misho 27: printf("[003] Did we change it from '%s' to '%s'?\n", $info, $info);
28:
29: // lets hope we always run this in the same second as we did run the server info request...
30: if (!$stmt = $db->query("SHOW STATUS LIKE '%uptime%'"))
31: printf("[004] Cannot run SHOW STATUS, [%s]\n", $db->errorCode());
32: else {
33: if (!$row = $stmt->fetch(PDO::FETCH_NUM))
34: printf("[005] Unable to fetch uptime, [%s]\n", $db->errorCode());
35: else
36: $uptime = $row[1];
37: $stmt->closeCursor();
38: }
39:
40: if (!preg_match('/Uptime/i', $info))
41: printf("[006] Can't find uptime in server info '%s'\n", $info);
42:
43: if (isset($uptime) && !preg_match(sprintf('/Uptime: %d/i', $uptime), $info))
44: printf("[007] SHOW STATUS and server info have reported a different uptime, please check. Server info: '%s', SHOW STATUS: '%s'\n", $info, $uptime);
45:
46: print "done!";
47: --EXPECTF--
48: done!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>