xref: /PHP-7.2/ext/pdo_pgsql/tests/bug73959.phpt (revision 21ac79e9)
1--TEST--
2Bug #73959 (lastInsertId fails to throw an exception)
3--SKIPIF--
4<?php
5if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
6require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
7require dirname(__FILE__) . '/config.inc';
8PDOTest::skip();
9?>
10--FILE--
11<?php
12require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
13require dirname(__FILE__) . '/config.inc';
14$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
15$db->setAttribute(PDO::ATTR_PERSISTENT, false);
16$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
17$db->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES, true);
18
19try {
20    $db->lastInsertId('nonexistent_seq');
21    echo "Error: No exception thrown";
22} catch (PDOException $e) {
23    echo "Success: Exception thrown";
24}
25?>
26--EXPECT--
27Success: Exception thrown
28