Skip to content

Commit 4e2f843

Browse files
committed
Optimized pdo_mysql tests
1 parent 500b0fe commit 4e2f843

File tree

161 files changed

+1295
-1578
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+1295
-1578
lines changed

ext/pdo/tests/pdo_017.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ try {
1919
}
2020

2121
if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
22-
require_once(__DIR__ . DIRECTORY_SEPARATOR . '../../pdo_mysql/tests/mysql_pdo_test.inc');
22+
require_once(__DIR__ . DIRECTORY_SEPARATOR . '../../pdo_mysql/tests/inc/mysql_pdo_test.inc');
2323
if (false === MySQLPDOTest::detect_transactional_mysql_engine($db)) {
2424
die('skip your mysql configuration does not support working transactions');
2525
}
@@ -32,7 +32,7 @@ require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
3232
$db = PDOTest::factory();
3333

3434
if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
35-
require_once(__DIR__ . DIRECTORY_SEPARATOR . '../../pdo_mysql/tests/mysql_pdo_test.inc');
35+
require_once(__DIR__ . DIRECTORY_SEPARATOR . '../../pdo_mysql/tests/inc/mysql_pdo_test.inc');
3636
$suf = ' ENGINE=' . MySQLPDOTest::detect_transactional_mysql_engine($db);
3737
} else {
3838
$suf = '';

ext/pdo_mysql/tests/bug41125.phpt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@ Bug #41125 (PDO mysql + quote() + prepare() can result in seg fault)
44
pdo_mysql
55
--SKIPIF--
66
<?php
7-
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
7+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
88
MySQLPDOTest::skip();
9-
109
?>
1110
--FILE--
1211
<?php
13-
14-
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
15-
16-
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
12+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
13+
$db = MySQLPDOTest::factory();
1714

1815
$search = "o'";
1916
$sql = "SELECT 1 FROM DUAL WHERE 'o''riley' LIKE " . $db->quote('%' . $search . '%');

ext/pdo_mysql/tests/bug44327.phpt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ Bug #44327 (PDORow::queryString property & numeric offsets / Crash)
44
pdo_mysql
55
--SKIPIF--
66
<?php
7-
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
7+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
88
MySQLPDOTest::skip();
9-
$db = MySQLPDOTest::factory();
109
?>
1110
--FILE--
1211
<?php
13-
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
12+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
1413
$db = MySQLPDOTest::factory();
1514
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
1615

@@ -38,11 +37,10 @@ $db = MySQLPDOTest::factory();
3837
@$stmt->execute();
3938
$row = $stmt->fetch();
4039
var_dump($row->queryString);
41-
4240
?>
4341
--CLEAN--
4442
<?php
45-
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
43+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
4644
$db = MySQLPDOTest::factory();
4745
$db->exec("DROP TABLE test_44327");
4846
?>

ext/pdo_mysql/tests/bug46292.phpt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ Bug #46292 (PDO::setFetchMode() shouldn't requires the 2nd arg when using FETCH_
44
pdo_mysql
55
--SKIPIF--
66
<?php
7-
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
7+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
88
MySQLPDOTest::skip();
99
?>
1010
--FILE--
1111
<?php
12-
13-
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
12+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
1413
$pdoDb = MySQLPDOTest::factory();
1514

16-
1715
class myclass {
1816
public $value;
1917

@@ -42,7 +40,7 @@ MySQLPDOTest::skip();
4240
?>
4341
--CLEAN--
4442
<?php
45-
require __DIR__ . '/mysql_pdo_test.inc';
43+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
4644
$db = MySQLPDOTest::factory();
4745
$db->exec('DROP TABLE IF EXISTS test_46292');
4846
?>

ext/pdo_mysql/tests/bug53551.phpt

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,30 @@ Bug #44327 (PDORow::queryString property & numeric offsets / Crash)
44
pdo_mysql
55
--SKIPIF--
66
<?php
7-
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
7+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
88
MySQLPDOTest::skip();
9-
$db = MySQLPDOTest::factory();
109
?>
1110
--FILE--
1211
<?php
13-
include __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
12+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
1413
$db = MySQLPDOTest::factory();
1514

1615
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
1716

1817
$createSql = "CREATE TABLE `bug53551` (
19-
`count` bigint(20) unsigned NOT NULL DEFAULT '0'
18+
`count` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'
2019
)";
2120

22-
$db->exec('drop table if exists bug53551');
21+
$db->exec('DROP TABLE IF EXISTS bug53551');
2322
$db->exec($createSql);
24-
$db->exec("insert into bug53551 set `count` = 1 ");
23+
$db->exec("INSERT INTO bug53551 SET `count` = 1 ");
2524
$db->exec("SET sql_mode = 'Traditional'");
2625
$sql = 'UPDATE bug53551 SET `count` = :count';
2726
$stmt = $db->prepare($sql);
2827

29-
$values = array (
30-
'count' => NULL,
31-
);
28+
$values = [
29+
'count' => null,
30+
];
3231

3332
echo "1\n";
3433
$stmt->execute($values);
@@ -39,11 +38,10 @@ $stmt->execute($values);
3938
var_dump($stmt->errorInfo());
4039

4140
echo "\ndone\n";
42-
4341
?>
4442
--CLEAN--
4543
<?php
46-
include __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
44+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
4745
$db = MySQLPDOTest::factory();
4846
$db->exec('DROP TABLE IF EXISTS bug53551');
4947
?>

ext/pdo_mysql/tests/bug53782.phpt

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
--TEST--
22
PDO MySQL Bug #53782 (foreach throws irrelevant exception)
33
--EXTENSIONS--
4-
pdo
54
pdo_mysql
65
--SKIPIF--
76
<?php
8-
require __DIR__ . '/config.inc';
9-
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
10-
PDOTest::skip();
7+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
8+
MySQLPDOTest::skip();
119
?>
1210
--FILE--
1311
<?php
14-
require __DIR__ . '/config.inc';
15-
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
16-
$conn = PDOTest::test_factory(__DIR__ . '/common.phpt');
12+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
13+
$conn = MySQLPDOTest::factory();
1714

1815
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
1916

@@ -31,11 +28,6 @@ foreach ($res as $k => $v) {
3128

3229
echo "DONE";
3330
?>
34-
--CLEAN--
35-
<?php
36-
require __DIR__ . '/mysql_pdo_test.inc';
37-
MySQLPDOTest::dropTestTable();
38-
?>
3931
--EXPECTF--
4032
Caught: SQLSTATE[42000]: %s
4133
Value: 0

ext/pdo_mysql/tests/bug54929.phpt

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,34 @@ Bug #54929 (Parse error with single quote in sql comment (pdo-mysql))
44
pdo_mysql
55
--SKIPIF--
66
<?php
7-
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
7+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
88
MySQLPDOTest::skip();
9-
109
?>
1110
--FILE--
1211
<?php
13-
14-
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
15-
16-
$pdodb = PDOTest::test_factory(__DIR__ . '/common.phpt');
17-
12+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
13+
$pdodb = MySQLPDOTest::factory();
1814

1915
function testQuery($query) {
2016
global $pdodb;
2117
$stmt = $pdodb->prepare($query);
2218

23-
if (!$stmt->execute(array("foo"))) {
19+
if (!$stmt->execute(["foo"])) {
2420
var_dump($stmt->errorInfo());
2521
} else{
2622
var_dump($stmt->fetch(PDO::FETCH_ASSOC));
2723
}
2824
}
2925

30-
testQuery("/* ' */ select ? as f1 /* ' */");
31-
testQuery("/* '-- */ select ? as f1 /* *' */");
32-
testQuery("/* ' */ select ? as f1 --';");
33-
testQuery("/* ' */ select ? as f1 -- 'a;");
34-
testQuery("/*'**/ select ? as f1 /* ' */");
35-
testQuery("/*'***/ select ? as f1 /* ' */");
26+
testQuery("/* ' */ SELECT ? AS f1 /* ' */");
27+
testQuery("/* '-- */ SELECT ? AS f1 /* *' */");
28+
testQuery("/* ' */ SELECT ? AS f1 --';");
29+
testQuery("/* ' */ SELECT ? AS f1 -- 'a;");
30+
testQuery("/*'**/ SELECT ? AS f1 /* ' */");
31+
testQuery("/*'***/ SELECT ? AS f1 /* ' */");
3632
testQuery("/*'**a ***b / ****
3733
******
38-
**/ select ? as f1 /* ' */");
34+
**/ SELECT ? AS f1 /* ' */");
3935

4036
?>
4137
--EXPECTF--

ext/pdo_mysql/tests/bug63176.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ Bug #63176 (Segmentation fault when instantiate 2 persistent PDO to the same db
44
pdo_mysql
55
--SKIPIF--
66
<?php
7-
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
7+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
88
MySQLPDOTest::skip();
99
?>
1010
--FILE--
1111
<?php
12-
require(__DIR__. DIRECTORY_SEPARATOR . 'config.inc');
12+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
13+
1314
class PDO2 extends PDO {
1415
protected $transLevel;
1516
}
@@ -18,15 +19,14 @@ class PDO3 extends PDO {
1819
protected $tomato;
1920
}
2021

21-
2222
class ModelA {
2323
public $db;
2424
public function __construct($h) {
2525
var_dump($h);
2626
if ($h) {
27-
$this->db = new PDO2(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, array(PDO::ATTR_PERSISTENT => true));
27+
$this->db = new PDO2(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, [PDO::ATTR_PERSISTENT => true]);
2828
} else {
29-
$this->db = new PDO3(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, array(PDO::ATTR_PERSISTENT => true));
29+
$this->db = new PDO3(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, [PDO::ATTR_PERSISTENT => true]);
3030
}
3131
$this->db->query('SELECT 1')->fetchAll();
3232
}

ext/pdo_mysql/tests/bug63185.phpt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
--TEST--
22
Bug #63185: nextRowset() ignores MySQL errors with native prepared statements
33
--EXTENSIONS--
4-
pdo
54
pdo_mysql
65
--SKIPIF--
76
<?php
8-
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
7+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
98
MySQLPDOTest::skip();
109
?>
1110
--FILE--
1211
<?php
13-
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
14-
12+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
1513
$pdo = MySQLPDOTest::factory();
14+
1615
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
1716

18-
$pdo->exec('DROP PROCEDURE IF EXISTS test_procedure_error_at_second');
19-
$pdo->exec('CREATE PROCEDURE test_procedure_error_at_second ()
17+
$procedure = 'test_procedure_error_at_second_63185';
18+
19+
$pdo->exec("DROP PROCEDURE IF EXISTS {$procedure}");
20+
$pdo->exec("CREATE PROCEDURE {$procedure} ()
2021
BEGIN
21-
SELECT "x" as foo;
22+
SELECT 'x' AS foo;
2223
SELECT * FROM no_such_table;
23-
END');
24+
END");
2425

2526
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
26-
$st = $pdo->query('CALL test_procedure_error_at_second()');
27+
$st = $pdo->query("CALL {$procedure}()");
2728
var_dump($st->fetchAll());
2829
try {
2930
var_dump($st->nextRowset());
@@ -33,21 +34,20 @@ try {
3334
unset($st);
3435

3536
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
36-
$st = $pdo->query('CALL test_procedure_error_at_second()');
37+
$st = $pdo->query("CALL {$procedure}()");
3738
var_dump($st->fetchAll());
3839
try {
3940
var_dump($st->nextRowset());
4041
} catch (PDOException $e) {
4142
echo $e->getMessage(), "\n";
4243
}
4344
var_dump($st->fetchAll());
44-
4545
?>
4646
--CLEAN--
4747
<?php
48-
require_once __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
48+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
4949
$pdo = MySQLPDOTest::factory();
50-
$pdo->query('DROP PROCEDURE IF EXISTS test_procedure_error_at_second');
50+
$pdo->query('DROP PROCEDURE IF EXISTS test_procedure_error_at_second_63185');
5151
?>
5252
--EXPECTF--
5353
array(1) {

ext/pdo_mysql/tests/bug66141.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ Bug #66141 (mysqlnd quote function is wrong with NO_BACKSLASH_ESCAPES after fail
44
pdo_mysql
55
--SKIPIF--
66
<?php
7-
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
7+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
88
MySQLPDOTest::skip();
99
?>
1010
--FILE--
1111
<?php
12-
include __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
12+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
1313
$db = MySQLPDOTest::factory();
1414

1515
$input = 'Something\', 1 as one, 2 as two FROM dual; -- f';

ext/pdo_mysql/tests/bug66528.phpt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
--TEST--
22
Bug #66528: No PDOException or errorCode if database becomes unavailable before PDO::commit
33
--EXTENSIONS--
4-
pdo
54
pdo_mysql
65
--SKIPIF--
76
<?php
8-
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
7+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
98
MySQLPDOTest::skip();
109
?>
1110
--FILE--
1211
<?php
13-
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
14-
12+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
1513
$dbh = MySQLPDOTest::factory();
14+
1615
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
1716
$dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
1817

19-
$dbh->exec('CREATE TABLE test_66528 (a int) engine=innodb');
18+
$dbh->exec('CREATE TABLE test_66528 (a INT) ENGINE=InnoDB');
2019
$dbh->beginTransaction();
2120
$dbh->exec('INSERT INTO test_66528 (a) VALUES (1), (2)');
2221
$stmt = $dbh->query('SELECT * FROM test_66528');
@@ -42,8 +41,9 @@ try {
4241
?>
4342
--CLEAN--
4443
<?php
45-
require __DIR__ . '/mysql_pdo_test.inc';
46-
MySQLPDOTest::dropTestTable(NULL, 'test_66528');
44+
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
45+
$pdo = MySQLPDOTest::factory();
46+
$db->exec('DROP TABLE IF EXISTS test_66528');
4747
?>
4848
--EXPECT--
4949
SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.

0 commit comments

Comments
 (0)