summaryrefslogtreecommitdiff
path: root/ext/pdo_sqlite/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pdo_sqlite/tests')
-rw-r--r--ext/pdo_sqlite/tests/bug33841.phpt1
-rw-r--r--ext/pdo_sqlite/tests/bug35336.phpt6
-rw-r--r--ext/pdo_sqlite/tests/bug43831.phpt24
-rw-r--r--ext/pdo_sqlite/tests/bug48773.phpt16
-rw-r--r--ext/pdo_sqlite/tests/bug50728.phpt4
-rw-r--r--ext/pdo_sqlite/tests/bug52487.phpt2
-rw-r--r--ext/pdo_sqlite/tests/bug66033.phpt24
-rw-r--r--ext/pdo_sqlite/tests/bug70862.phpt8
-rw-r--r--ext/pdo_sqlite/tests/bug78192.phpt1
-rw-r--r--ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt75
-rw-r--r--ext/pdo_sqlite/tests/pdo_sqlite_createaggregate.phpt2
-rw-r--r--ext/pdo_sqlite/tests/pdo_sqlite_createaggregate_002.phpt19
-rw-r--r--ext/pdo_sqlite/tests/pdo_sqlite_createcollation.phpt2
-rw-r--r--ext/pdo_sqlite/tests/pdo_sqlite_createfunction.phpt2
-rw-r--r--ext/pdo_sqlite/tests/pdo_sqlite_createfunction_002.phpt10
-rw-r--r--ext/pdo_sqlite/tests/pdo_sqlite_createfunction_with_flags.phpt2
-rw-r--r--ext/pdo_sqlite/tests/pdo_sqlite_extendederror_attr.phpt2
-rw-r--r--ext/pdo_sqlite/tests/pdo_sqlite_transaction.phpt5
18 files changed, 119 insertions, 86 deletions
diff --git a/ext/pdo_sqlite/tests/bug33841.phpt b/ext/pdo_sqlite/tests/bug33841.phpt
index 1c9fe201f4..2fc6d955b6 100644
--- a/ext/pdo_sqlite/tests/bug33841.phpt
+++ b/ext/pdo_sqlite/tests/bug33841.phpt
@@ -20,6 +20,7 @@ $stmt = $db->prepare("UPDATE test SET text = :text ");
$stmt->bindParam(':text', $name);
$name = 'test2';
var_dump($stmt->execute(), $stmt->rowCount());
+?>
--EXPECT--
bool(true)
int(1)
diff --git a/ext/pdo_sqlite/tests/bug35336.phpt b/ext/pdo_sqlite/tests/bug35336.phpt
index 201429bc4e..52a425b62f 100644
--- a/ext/pdo_sqlite/tests/bug35336.phpt
+++ b/ext/pdo_sqlite/tests/bug35336.phpt
@@ -7,9 +7,9 @@ if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
--FILE--
<?php
class EEE {
- function __set ($field, $value) {
- echo "hello world\n";
- }
+ function __set ($field, $value) {
+ echo "hello world\n";
+ }
}
$a = new PDO("sqlite::memory:");// pool ("sqlite::memory:");
diff --git a/ext/pdo_sqlite/tests/bug43831.phpt b/ext/pdo_sqlite/tests/bug43831.phpt
index 4620559da4..bcb09c95a7 100644
--- a/ext/pdo_sqlite/tests/bug43831.phpt
+++ b/ext/pdo_sqlite/tests/bug43831.phpt
@@ -6,23 +6,23 @@ Bug #43831 ($this gets mangled when extending PDO with persistent connection)
<?php
class Foo extends PDO {
- function __construct($dsn) {
- parent::__construct($dsn, null, null, array(PDO::ATTR_PERSISTENT => true));
- }
+ function __construct($dsn) {
+ parent::__construct($dsn, null, null, array(PDO::ATTR_PERSISTENT => true));
+ }
}
class Baz extends PDO {
- function __construct($dsn) {
- parent::__construct($dsn, null, null, array(PDO::ATTR_PERSISTENT => true));
- }
+ function __construct($dsn) {
+ parent::__construct($dsn, null, null, array(PDO::ATTR_PERSISTENT => true));
+ }
}
class Bar extends Baz {
- function quux() {
- echo get_class($this), "\n";
- $foo = new Foo("sqlite::memory:");
- echo get_class($this), "\n";
- }
+ function quux() {
+ echo get_class($this), "\n";
+ $foo = new Foo("sqlite::memory:");
+ echo get_class($this), "\n";
+ }
}
$bar = new Bar("sqlite::memory:");
@@ -49,5 +49,5 @@ object(PDO)#%d (0) {
object(MyPDO)#%d (0) {
}
-Notice: Undefined variable: bar in %s on line %d
+Warning: Undefined variable $bar in %s on line %d
NULL
diff --git a/ext/pdo_sqlite/tests/bug48773.phpt b/ext/pdo_sqlite/tests/bug48773.phpt
index c9a2f64bef..a5f43cdd92 100644
--- a/ext/pdo_sqlite/tests/bug48773.phpt
+++ b/ext/pdo_sqlite/tests/bug48773.phpt
@@ -8,18 +8,18 @@ if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
<?php
class bar extends PDOStatement {
- private function __construct() {
- }
+ private function __construct() {
+ }
}
class foo extends PDO {
- public $statementClass = 'bar';
- function __construct($dsn, $username, $password, $driver_options = array()) {
- $driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
- parent::__construct($dsn, $username, $password, $driver_options);
+ public $statementClass = 'bar';
+ function __construct($dsn, $username, $password, $driver_options = array()) {
+ $driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
+ parent::__construct($dsn, $username, $password, $driver_options);
- $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array($this->statementClass, array($this)));
- }
+ $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array($this->statementClass, array($this)));
+ }
}
$db = new foo('sqlite::memory:', '', '');
diff --git a/ext/pdo_sqlite/tests/bug50728.phpt b/ext/pdo_sqlite/tests/bug50728.phpt
index b00ea50cf0..98f8907f48 100644
--- a/ext/pdo_sqlite/tests/bug50728.phpt
+++ b/ext/pdo_sqlite/tests/bug50728.phpt
@@ -7,9 +7,9 @@ if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
--FILE--
<?php
try {
- $a = new PDO("sqlite:/this/path/should/not/exist.db");
+ $a = new PDO("sqlite:/this/path/should/not/exist.db");
} catch (PDOException $e) {
- var_dump($e->getCode());
+ var_dump($e->getCode());
}
?>
--EXPECT--
diff --git a/ext/pdo_sqlite/tests/bug52487.phpt b/ext/pdo_sqlite/tests/bug52487.phpt
index ff586d2f64..17a581296a 100644
--- a/ext/pdo_sqlite/tests/bug52487.phpt
+++ b/ext/pdo_sqlite/tests/bug52487.phpt
@@ -11,7 +11,7 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$stmt = $db->prepare("select 1 as attr");
for ($i = 0; $i < 10; $i++) {
- $stmt->setFetchMode(PDO::FETCH_INTO, new stdClass);
+ $stmt->setFetchMode(PDO::FETCH_INTO, new stdClass);
}
print "ok\n";
diff --git a/ext/pdo_sqlite/tests/bug66033.phpt b/ext/pdo_sqlite/tests/bug66033.phpt
index ebd519171a..c48ebe41ec 100644
--- a/ext/pdo_sqlite/tests/bug66033.phpt
+++ b/ext/pdo_sqlite/tests/bug66033.phpt
@@ -7,26 +7,26 @@ if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
--FILE--
<?php
class DBStatement extends PDOStatement {
- public $dbh;
- protected function __construct($dbh) {
- $this->dbh = $dbh;
- throw new Exception("Blah");
- }
+ public $dbh;
+ protected function __construct($dbh) {
+ $this->dbh = $dbh;
+ throw new Exception("Blah");
+ }
}
$pdo = new PDO('sqlite::memory:', null, null);
$pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('DBStatement',
- array($pdo)));
+ array($pdo)));
$pdo->exec("CREATE TABLE IF NOT EXISTS messages (
- id INTEGER PRIMARY KEY,
- title TEXT,
- message TEXT,
- time INTEGER)");
+ id INTEGER PRIMARY KEY,
+ title TEXT,
+ message TEXT,
+ time INTEGER)");
try {
- $pdoStatement = $pdo->query("select * from messages");
+ $pdoStatement = $pdo->query("select * from messages");
} catch (Exception $e) {
- var_dump($e->getMessage());
+ var_dump($e->getMessage());
}
?>
--EXPECT--
diff --git a/ext/pdo_sqlite/tests/bug70862.phpt b/ext/pdo_sqlite/tests/bug70862.phpt
index d66bb6262f..f676d66387 100644
--- a/ext/pdo_sqlite/tests/bug70862.phpt
+++ b/ext/pdo_sqlite/tests/bug70862.phpt
@@ -14,10 +14,10 @@ $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
class HelloWrapper {
- public function stream_open() { return true; }
- public function stream_eof() { return true; }
- public function stream_read() { return NULL; }
- public function stream_stat() { return array(); }
+ public function stream_open() { return true; }
+ public function stream_eof() { return true; }
+ public function stream_read() { return NULL; }
+ public function stream_stat() { return array(); }
}
stream_wrapper_register("hello", "HelloWrapper");
diff --git a/ext/pdo_sqlite/tests/bug78192.phpt b/ext/pdo_sqlite/tests/bug78192.phpt
index dcf4b749be..defdafb681 100644
--- a/ext/pdo_sqlite/tests/bug78192.phpt
+++ b/ext/pdo_sqlite/tests/bug78192.phpt
@@ -23,6 +23,7 @@ var_dump($stmt->fetchAll(\PDO::FETCH_ASSOC));
$connection->query('ALTER TABLE user ADD new_col VARCHAR(255)');
$stmt->execute(['id' => 10]);
var_dump($stmt->fetchAll(\PDO::FETCH_ASSOC));
+?>
--EXPECT--
array(1) {
[0]=>
diff --git a/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt b/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt
index c452d4c34f..2d0dfc3e5d 100644
--- a/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt
+++ b/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt
@@ -8,6 +8,8 @@ if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
<?php
$db = new PDO('sqlite::memory:');
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+
$db->exec('CREATE TABLE testing (id INTEGER , name VARCHAR)');
$db->exec('INSERT INTO testing VALUES(1, "php")');
$db->exec('INSERT INTO testing VALUES(2, "")');
@@ -34,27 +36,27 @@ $st = $db->query('SELECT * FROM testing');
var_dump($st->fetchAll(PDO::FETCH_FUNC, array('self', 'foo')));
class foo {
- public function method($x) {
- return "--- $x ---";
- }
+ public function method($x) {
+ return "--- $x ---";
+ }
}
class bar extends foo {
- public function __construct($db) {
- $st = $db->query('SELECT * FROM testing');
- var_dump($st->fetchAll(PDO::FETCH_FUNC, array($this, 'parent::method')));
- }
-
- static public function test($x, $y) {
- return $x .'---'. $y;
- }
-
- private function test2($x, $y) {
- return $x;
- }
-
- public function test3($x, $y) {
- return $x .'==='. $y;
- }
+ public function __construct($db) {
+ $st = $db->query('SELECT * FROM testing');
+ var_dump($st->fetchAll(PDO::FETCH_FUNC, array($this, 'parent::method')));
+ }
+
+ static public function test($x, $y) {
+ return $x .'---'. $y;
+ }
+
+ private function test2($x, $y) {
+ return $x;
+ }
+
+ public function test3($x, $y) {
+ return $x .'==='. $y;
+ }
}
new bar($db);
@@ -90,19 +92,29 @@ array(2) {
string(0) ""
}
-Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: function 'nothing' not found or invalid function name in %s on line %d
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: function "nothing" not found or invalid function name in %s on line %d
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in %s on line %d
bool(false)
-Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: function '' not found or invalid function name in %s on line %d
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: function "" not found or invalid function name in %s on line %d
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in %s on line %d
bool(false)
Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: no array or string given in %s on line %d
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in %s on line %d
bool(false)
Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: no array or string given in %s on line %d
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in %s on line %d
bool(false)
-Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: class 'PDOStatement' does not have a method 'foo' in %s on line %d
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: class PDOStatement does not have a method "foo" in %s on line %d
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in %s on line %d
bool(false)
array(2) {
[0]=>
@@ -117,14 +129,17 @@ array(2) {
string(4) "2---"
}
-Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: cannot access private method bar::test2() in %s on line %d
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: non-static method bar::test2() cannot be called statically in %s on line %d
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in %s on line %d
bool(false)
-array(2) {
- [0]=>
- string(7) "1===php"
- [1]=>
- string(4) "2==="
-}
-Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: class 'bar' does not have a method 'inexistent' in %s on line %d
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: non-static method bar::test3() cannot be called statically in %s on line %d
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in %s on line %d
+bool(false)
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: class bar does not have a method "inexistent" in %s on line %d
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in %s on line %d
bool(false)
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate.phpt
index c9157d1b05..b21620bee7 100644
--- a/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate.phpt
@@ -16,7 +16,7 @@ $db->sqliteCreateAggregate('testing', function(&$a, $b) { $a .= $b; return $a; }
foreach ($db->query('SELECT testing(name) FROM foobar') as $row) {
- var_dump($row);
+ var_dump($row);
}
$db->query('DROP TABLE foobar');
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate_002.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate_002.phpt
index 671e4b3454..5660288af3 100644
--- a/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate_002.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate_002.phpt
@@ -7,11 +7,18 @@ PDO_sqlite: Testing invalid callback for sqliteCreateAggregate()
$pdo = new PDO('sqlite::memory:');
-$pdo->sqliteCreateAggregate('foo', 'a', '');
-$pdo->sqliteCreateAggregate('foo', 'strlen', '');
+try {
+ $pdo->sqliteCreateAggregate('foo', 'a', '');
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+try {
+ $pdo->sqliteCreateAggregate('foo', 'strlen', '');
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
?>
---EXPECTF--
-Warning: PDO::sqliteCreateAggregate(): function 'a' is not callable in %s on line %d
-
-Warning: PDO::sqliteCreateAggregate(): function '' is not callable in %s on line %d
+--EXPECT--
+PDO::sqliteCreateAggregate(): Argument #2 ($step_func) must be a valid callback, function "a" not found or invalid function name
+PDO::sqliteCreateAggregate(): Argument #3 ($finalize_func) must be a valid callback, function "" not found or invalid function name
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_createcollation.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_createcollation.phpt
index fcfc344896..0742d20e84 100644
--- a/ext/pdo_sqlite/tests/pdo_sqlite_createcollation.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_createcollation.phpt
@@ -18,7 +18,7 @@ $db->sqliteCreateCollation('MYCOLLATE', function($a, $b) { return strnatcmp($a,
$result = $db->query('SELECT name FROM foobar ORDER BY name COLLATE MYCOLLATE');
foreach ($result as $row) {
- echo $row['name'] . "\n";
+ echo $row['name'] . "\n";
}
$result = $db->query('SELECT name FROM foobar ORDER BY name');
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_createfunction.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction.phpt
index 1e753f3799..45075e9748 100644
--- a/ext/pdo_sqlite/tests/pdo_sqlite_createfunction.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction.phpt
@@ -17,7 +17,7 @@ $db->sqliteCreateFunction('testing', function($v) { return strtolower($v); });
foreach ($db->query('SELECT testing(name) FROM foobar') as $row) {
- var_dump($row);
+ var_dump($row);
}
$db->query('DROP TABLE foobar');
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_002.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_002.phpt
index a1d890ac1b..958ea0c484 100644
--- a/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_002.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_002.phpt
@@ -10,8 +10,12 @@ Chris MacPherson chris@kombine.co.uk
$db = new PDO( 'sqlite::memory:');
-$db->sqliteCreateFunction('bar-alias', 'bar');
+try {
+ $db->sqliteCreateFunction('bar-alias', 'bar');
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
?>
---EXPECTF--
-Warning: PDO::sqliteCreateFunction(): function 'bar' is not callable in %s on line %d
+--EXPECT--
+PDO::sqliteCreateFunction(): Argument #2 ($callback) must be a valid callback, function "bar" not found or invalid function name
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_with_flags.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_with_flags.phpt
index 5a329a1d97..9cb6ecc02d 100644
--- a/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_with_flags.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_with_flags.phpt
@@ -20,7 +20,7 @@ $db->sqliteCreateFunction('testing', function($v) { return strtolower($v); }, 1,
foreach ($db->query('SELECT testing(name) FROM foobar') as $row) {
- var_dump($row);
+ var_dump($row);
}
$db->query('DROP TABLE foobar');
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_extendederror_attr.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_extendederror_attr.phpt
index 50b939b6eb..5ea4a2def1 100644
--- a/ext/pdo_sqlite/tests/pdo_sqlite_extendederror_attr.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_extendederror_attr.phpt
@@ -7,6 +7,7 @@ PDO_sqlite: Testing PDO_SQLITE_ATTR_EXTENDED_RESULT_CODES
echo "Creating new PDO" . PHP_EOL;
$db = new PDO('sqlite::memory:');
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
$db->exec("CREATE TABLE dog ( id INTEGER PRIMARY KEY, name TEXT, annoying INTEGER )");
@@ -23,6 +24,7 @@ echo sprintf("Second Error Info: SQLSTATE Error Code: (%s), Driver Specific Erro
echo "Creating new PDO with Extended Result Codes turned on" . PHP_EOL;
$db = new PDO('sqlite::memory:', '', '', [PDO::SQLITE_ATTR_EXTENDED_RESULT_CODES => TRUE]);
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
$db->exec("CREATE TABLE dog ( id INTEGER PRIMARY KEY, name TEXT, annoying INTEGER )");
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_transaction.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_transaction.phpt
index 493fff78d8..478121e721 100644
--- a/ext/pdo_sqlite/tests/pdo_sqlite_transaction.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_transaction.phpt
@@ -6,6 +6,7 @@ PDO_sqlite: Testing transaction
<?php
$db = new PDO('sqlite::memory:');
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$db->beginTransaction();
@@ -24,5 +25,7 @@ var_dump($r->rowCount());
$db->query('DROP TABLE foobar');
?>
---EXPECT--
+--EXPECTF--
int(0)
+
+Warning: PDO::query(): SQLSTATE[HY000]: General error: 6 database table is locked in %s on line %d