-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pdo_oci: Register new attr constants and add tests
- Loading branch information
Showing
4 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--TEST-- | ||
PDO_OCI: Attribute: Setting session action | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('pdo') || !extension_loaded('pdo_oci')) die('skip not loaded'); | ||
require(dirname(__FILE__).'/../../pdo/tests/pdo_test.inc'); | ||
PDOTest::skip(); | ||
?> | ||
--FILE-- | ||
<?php | ||
|
||
require(dirname(__FILE__) . '/../../pdo/tests/pdo_test.inc'); | ||
|
||
$query = 'select action from v$session where sid = (select distinct sid from v$mystat)'; | ||
|
||
$dbh = PDOTest::factory(); | ||
|
||
$stmt = $dbh->query($query); | ||
$row = $stmt->fetch(); | ||
echo 'ACTION NOT SET: '; | ||
var_dump($row['action']); | ||
|
||
$dbh->setAttribute(PDO::OCI_ATTR_ACTION, "some action"); | ||
|
||
$stmt = $dbh->query($query); | ||
$row = $stmt->fetch(); | ||
echo 'ACTION SET: '; | ||
var_dump($row['action']); | ||
|
||
$dbh->setAttribute(PDO::OCI_ATTR_ACTION, "something else!"); | ||
|
||
$stmt = $dbh->query($query); | ||
$row = $stmt->fetch(); | ||
echo 'ACTION RESET: '; | ||
var_dump($row['action']); | ||
|
||
$dbh->setAttribute(PDO::OCI_ATTR_ACTION, null); | ||
|
||
$stmt = $dbh->query($query); | ||
$row = $stmt->fetch(); | ||
echo 'ACTION NULLED: '; | ||
var_dump($row['action']); | ||
|
||
echo "Done\n"; | ||
|
||
?> | ||
--EXPECT-- | ||
ACTION NOT SET: NULL | ||
ACTION SET: string(11) "some action" | ||
ACTION RESET: string(15) "something else!" | ||
ACTION NULLED: NULL | ||
Done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--TEST-- | ||
PDO_OCI: Attribute: Setting session client info | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('pdo') || !extension_loaded('pdo_oci')) die('skip not loaded'); | ||
require(dirname(__FILE__).'/../../pdo/tests/pdo_test.inc'); | ||
PDOTest::skip(); | ||
?> | ||
--FILE-- | ||
<?php | ||
|
||
require(dirname(__FILE__) . '/../../pdo/tests/pdo_test.inc'); | ||
|
||
$query = 'select client_info from v$session where sid = (select distinct sid from v$mystat)'; | ||
|
||
$dbh = PDOTest::factory(); | ||
|
||
$stmt = $dbh->query($query); | ||
$row = $stmt->fetch(); | ||
echo 'CLIENT_INFO NOT SET: '; | ||
var_dump($row['client_info']); | ||
|
||
$dbh->setAttribute(PDO::OCI_ATTR_CLIENT_INFO, "some client info"); | ||
|
||
$stmt = $dbh->query($query); | ||
$row = $stmt->fetch(); | ||
echo 'CLIENT_INFO SET: '; | ||
var_dump($row['client_info']); | ||
|
||
$dbh->setAttribute(PDO::OCI_ATTR_CLIENT_INFO, "something else!"); | ||
|
||
$stmt = $dbh->query($query); | ||
$row = $stmt->fetch(); | ||
echo 'CLIENT_INFO RESET: '; | ||
var_dump($row['client_info']); | ||
|
||
$dbh->setAttribute(PDO::OCI_ATTR_CLIENT_INFO, null); | ||
|
||
$stmt = $dbh->query($query); | ||
$row = $stmt->fetch(); | ||
echo 'CLIENT_INFO NULLED: '; | ||
var_dump($row['client_info']); | ||
|
||
echo "Done\n"; | ||
|
||
?> | ||
--EXPECT-- | ||
CLIENT_INFO NOT SET: NULL | ||
CLIENT_INFO SET: string(16) "some client info" | ||
CLIENT_INFO RESET: string(15) "something else!" | ||
CLIENT_INFO NULLED: NULL | ||
Done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--TEST-- | ||
PDO OCI specific class constants | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('pdo') || !extension_loaded('pdo_oci')) die('skip not loaded'); | ||
require(dirname(__FILE__).'/../../pdo/tests/pdo_test.inc'); | ||
PDOTest::skip(); | ||
?> | ||
--FILE-- | ||
<?php | ||
|
||
require(dirname(__FILE__) . '/../../pdo/tests/pdo_test.inc'); | ||
|
||
$expected = [ | ||
'OCI_ATTR_CLIENT_INFO' => true, | ||
'OCI_ATTR_ACTION' => true, | ||
]; | ||
|
||
$ref = new ReflectionClass('PDO'); | ||
$constants = $ref->getConstants(); | ||
$values = []; | ||
|
||
foreach ($constants as $name => $value) { | ||
if (substr($name, 0, 8) == 'OCI_ATTR') { | ||
if (!isset($values[$value])) { | ||
$values[$value] = [$name]; | ||
} else { | ||
$values[$value][] = $name; | ||
} | ||
|
||
if (isset($expected[$name])) { | ||
unset($expected[$name]); | ||
unset($constants[$name]); | ||
} | ||
|
||
} else { | ||
unset($constants[$name]); | ||
} | ||
} | ||
|
||
if (!empty($constants)) { | ||
printf("[001] Dumping list of unexpected constants\n"); | ||
var_dump($constants); | ||
} | ||
|
||
if (!empty($expected)) { | ||
printf("[002] Dumping list of missing constants\n"); | ||
var_dump($expected); | ||
} | ||
|
||
if (!empty($values)) { | ||
foreach ($values as $value => $constants) { | ||
if (count($constants) > 1) { | ||
printf("[003] Several constants share the same value '%s'\n", $value); | ||
var_dump($constants); | ||
} | ||
} | ||
} | ||
|
||
print "done!"; | ||
--EXPECT-- | ||
done! |