php-src/ext/pdo_mysql/tests/pdo_mysql_attr_case.phpt
Peter Kokot d679f02295 Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:33:09 +02:00

224 lines
5.1 KiB
PHP

--TEST--
PDO::ATTR_CASE
--SKIPIF--
<?php
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
MySQLPDOTest::skip();
$db = MySQLPDOTest::factory();
?>
--FILE--
<?php
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
$db = MySQLPDOTest::factory();
MySQLPDOTest::createTestTable($db);
$default = $db->getAttribute(PDO::ATTR_CASE);
$known = array(
PDO::CASE_LOWER => 'PDO::CASE_LOWER',
PDO::CASE_UPPER => 'PDO::CASE_UPPER',
PDO::CASE_NATURAL => 'PDO::CASE_NATURAL'
);
if (!isset($known[$default]))
printf("[001] getAttribute(PDO::ATTR_CASE) returns unknown value '%s'\n",
var_export($default, true));
else
var_dump($known[$default]);
// lets see what the default is...
if (!is_object($stmt = $db->query("SELECT id, id AS 'ID_UPPER', label FROM test ORDER BY id ASC LIMIT 2")))
printf("[002] %s - %s\n",
var_export($db->errorInfo(), true), var_export($db->errorCode(), true));
var_dump($stmt->fetchAll(PDO::FETCH_BOTH));
if (true !== $db->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER))
printf("[003] Cannot set PDO::ATTR_CASE = PDO::CASE_LOWER, %s - %s\n",
var_export($db->errorInfo(), true), var_export($db->errorCode(), true));
if (($tmp = $db->getAttribute(PDO::ATTR_CASE)) !== PDO::CASE_LOWER)
printf("[004] getAttribute(PDO::ATTR_CASE) returns wrong value '%s'\n",
var_export($tmp, true));
if (true === $db->exec('ALTER TABLE test ADD MiXeD CHAR(1)'))
printf("[005] Cannot add column %s - %s\n",
var_export($db->errorInfo(), true), var_export($db->errorCode(), true));
if (false === $db->exec('ALTER TABLE test ADD MYUPPER CHAR(1)'))
printf("[006] Cannot add column %s - %s\n",
var_export($db->errorInfo(), true), var_export($db->errorCode(), true));
if (!is_object($stmt = $db->query("SELECT id, id AS 'ID_UPPER', label, MiXeD, MYUPPER FROM test ORDER BY id ASC LIMIT 2")))
printf("[007] %s - %s\n",
var_export($db->errorInfo(), true), var_export($db->errorCode(), true));
var_dump($stmt->fetchAll(PDO::FETCH_BOTH));
if (true !== $db->setAttribute(PDO::ATTR_CASE, PDO::CASE_UPPER))
printf("[008] Cannot set PDO::ATTR_CASE = PDO::CASE_UPPER %s - %s\n",
var_export($db->errorInfo(), true), var_export($db->errorCode(), true));
if (($tmp = $db->getAttribute(PDO::ATTR_CASE)) !== PDO::CASE_UPPER)
printf("[009] getAttribute(PDO::ATTR_CASE) returns wrong value '%s'\n",
var_export($tmp, true));
if (!is_object($stmt = $db->query("SELECT id, label, MiXeD, MYUPPER, MYUPPER AS 'lower' FROM test ORDER BY id ASC LIMIT 1")))
printf("[010] %s - %s\n",
var_export($db->errorInfo(), true), var_export($db->errorCode(), true));
var_dump($stmt->fetchAll(PDO::FETCH_BOTH));
if (true !== $db->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL))
printf("[011] Cannot set PDO::ATTR_CASE = PDO::CASE_NATURAL %s - %s\n",
var_export($db->errorInfo(), true), var_export($db->errorCode(), true));
if (($tmp = $db->getAttribute(PDO::ATTR_CASE)) !== PDO::CASE_NATURAL)
printf("[012] getAttribute(PDO::ATTR_CASE) returns wrong value '%s'\n",
var_export($tmp, true));
if (!is_object($stmt = $db->query("SELECT id, label, MiXeD, MYUPPER, id AS 'ID' FROM test ORDER BY id ASC LIMIT 1")))
printf("[013] %s - %s\n",
var_export($db->errorInfo(), true), var_export($db->errorCode(), true));
var_dump($stmt->fetchAll(PDO::FETCH_BOTH));
print "done!";
?>
--CLEAN--
<?php
require dirname(__FILE__) . '/mysql_pdo_test.inc';
MySQLPDOTest::dropTestTable();
?>
--EXPECT--
string(15) "PDO::CASE_LOWER"
array(2) {
[0]=>
array(6) {
["id"]=>
string(1) "1"
[0]=>
string(1) "1"
["id_upper"]=>
string(1) "1"
[1]=>
string(1) "1"
["label"]=>
string(1) "a"
[2]=>
string(1) "a"
}
[1]=>
array(6) {
["id"]=>
string(1) "2"
[0]=>
string(1) "2"
["id_upper"]=>
string(1) "2"
[1]=>
string(1) "2"
["label"]=>
string(1) "b"
[2]=>
string(1) "b"
}
}
array(2) {
[0]=>
array(10) {
["id"]=>
string(1) "1"
[0]=>
string(1) "1"
["id_upper"]=>
string(1) "1"
[1]=>
string(1) "1"
["label"]=>
string(1) "a"
[2]=>
string(1) "a"
["mixed"]=>
NULL
[3]=>
NULL
["myupper"]=>
NULL
[4]=>
NULL
}
[1]=>
array(10) {
["id"]=>
string(1) "2"
[0]=>
string(1) "2"
["id_upper"]=>
string(1) "2"
[1]=>
string(1) "2"
["label"]=>
string(1) "b"
[2]=>
string(1) "b"
["mixed"]=>
NULL
[3]=>
NULL
["myupper"]=>
NULL
[4]=>
NULL
}
}
array(1) {
[0]=>
array(10) {
["ID"]=>
string(1) "1"
[0]=>
string(1) "1"
["LABEL"]=>
string(1) "a"
[1]=>
string(1) "a"
["MIXED"]=>
NULL
[2]=>
NULL
["MYUPPER"]=>
NULL
[3]=>
NULL
["LOWER"]=>
NULL
[4]=>
NULL
}
}
array(1) {
[0]=>
array(10) {
["id"]=>
string(1) "1"
[0]=>
string(1) "1"
["label"]=>
string(1) "a"
[1]=>
string(1) "a"
["MiXeD"]=>
NULL
[2]=>
NULL
["MYUPPER"]=>
NULL
[3]=>
NULL
["ID"]=>
string(1) "1"
[4]=>
string(1) "1"
}
}
done!