PHP  
 PHP_HEAD
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Test Failure Report for ext/pdo_oci/tests/pdo_018.phpt ('OCI PDO Common: serializing')

Script

1: <?php
2:
if (getenv('REDIR_TEST_DIR') === falseputenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
3: require_once 
getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
4:
$db PDOTest::factory();
5:
6: class 
TestBase implements Serializable
7:
{
8:     public    
$BasePub 'Public';
9:     protected 
$BasePro 'Protected';
10:     private   
$BasePri 'Private';
11:
12:     function 
serialize()
13:     {
14:         
$serialized = array();
15:         foreach(
$this as $prop => $val) {
16:             
$serialized[$prop] = $val;
17:         }
18:         
$serialized serialize($serialized);
19:         echo 
__METHOD__ "() = '$serialized'\n";
20:         return 
$serialized;
21:     }
22:
23:     function 
unserialize($serialized)
24:     {
25:         echo 
__METHOD__ "($serialized)\n";
26:         foreach(
unserialize($serialized) as $prop => $val) {
27:             
$this->$prop '#'.$val;
28:         }
29:         return 
true;
30:     }
31: }
32:
33: class 
TestDerived extends TestBase
34:
{
35:     public    
$BasePub    'DerivedPublic';
36:     protected 
$BasePro    'DerivdeProtected';
37:     public    
$DerivedPub 'Public';
38:     protected 
$DerivedPro 'Protected';
39:     private   
$DerivedPri 'Private';
40:
41:     function 
serialize()
42:     {
43:         echo 
__METHOD__ "()\n";
44:         return 
TestBase::serialize();
45:     }
46:
47:     function 
unserialize($serialized)
48:     {
49:         echo 
__METHOD__ "()\n";
50:         return 
TestBase::unserialize($serialized);
51:     }
52: }
53:
54: class 
TestLeaf extends TestDerived
55:
{
56: }
57:
58:
$db->exec('CREATE TABLE classtypes(id int NOT NULL PRIMARY KEY, name VARCHAR(20) NOT NULL UNIQUE)');
59:
$db->exec('INSERT INTO classtypes VALUES(0, \'stdClass\')');
60:
$db->exec('INSERT INTO classtypes VALUES(1, \'TestBase\')');
61:
$db->exec('INSERT INTO classtypes VALUES(2, \'TestDerived\')');
62:
63: switch (
$db->getAttribute(PDO::ATTR_DRIVER_NAME)) {
64:   case 
'dblib':
65:     
// environment settings can influence how the table is created if specifics are missing
66:     // https://msdn.microsoft.com/en-us/library/ms174979.aspx#Nullability Rules Within a Table Definition
67:     
$sql 'CREATE TABLE test(id int NOT NULL PRIMARY KEY, classtype int NULL, val VARCHAR(255) NULL)';
68:     break;
69:   default:
70:     
$sql 'CREATE TABLE test(id int NOT NULL PRIMARY KEY, classtype int, val VARCHAR(255))';
71:     break;
72: }
73:
$db->exec($sql);
74:
75:
$db->setAttribute(PDO::ATTR_ERRMODEPDO::ERRMODE_EXCEPTION);
76:
77:
var_dump($db->query('SELECT COUNT(*) FROM classtypes')->fetchColumn());
78:
var_dump($db->query('SELECT id, name FROM classtypes ORDER by id')->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE));
79:
80:
$objs = array();
81:
$objs[0] = new stdClass;
82:
$objs[1] = new TestBase;
83:
$objs[2] = new TestDerived;
84:
$objs[3] = new TestLeaf;
85:
86:
$stmt $db->prepare('SELECT id FROM classtypes WHERE name=:cname');
87:
$stmt->bindParam(':cname'$cname);
88:
89:
$ctypes = array();
90:
91: foreach(
$objs as $obj)
92: {
93:     
$cname get_class($obj);
94:     
$ctype NULL/* set default for non stored class name */
95:     
$stmt->execute();
96:     
$stmt->bindColumn('id'$ctype);
97:     
$stmt->fetch(PDO::FETCH_BOUND);
98:     
$ctypes[$cname] = $ctype;
99: }
100:
101: echo 
"===TYPES===\n";
102:
var_dump($ctypes);
103:
104: unset(
$stmt);
105:
106: echo 
"===INSERT===\n";
107:
$stmt $db->prepare('INSERT INTO test VALUES(:id, :classtype, :val)');
108:
$stmt->bindParam(':id'$idx);
109:
$stmt->bindParam(':classtype'$ctype);
110:
$stmt->bindParam(':val'$val);
111:
112: foreach(
$objs as $idx => $obj)
113: {
114:     
$ctype $ctypes[get_class($obj)];
115:     if (
method_exists($obj'serialize'))
116:     {
117:         
$val $obj->serialize();
118:     }
119:     else
120:     {
121:         
$val '';
122:     }
123:     
$stmt->execute();
124: }
125:
126: unset(
$stmt);
127:
128: echo 
"===DATA===\n";
129:
$res $db->query('SELECT test.val FROM test')->fetchAll(PDO::FETCH_COLUMN);
130:
131: switch (
$db->getAttribute(PDO::ATTR_DRIVER_NAME)) {
132:     case 
'dblib':
133:         
// map whitespace (from early TDS versions) to empty string so the test doesn't diff
134:         
if ($res[0] === ' ') {
135:             
$res[0] = '';
136:         }
137:         break;
138:
139:     case 
'oci':
140:         
// map NULL to empty string so the test doesn't diff
141:         
if ($res[0] === null) {
142:             
$res[0] = '';
143:         }
144:         break;
145: }
146:
var_dump($res);
147:
148: echo 
"===FAILURE===\n";
149: try
150: {
151:     
$db->query('SELECT classtypes.name AS name, test.val AS val FROM test LEFT JOIN classtypes ON test.classtype=classtypes.id')->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_CLASSTYPE|PDO::FETCH_SERIALIZE'TestLeaf', array());
152: }
153: catch (
PDOException $e)
154: {
155:     echo 
'Exception:';
156:     echo 
$e->getMessage()."\n";
157: }
158:
159: echo 
"===COUNT===\n";
160:
var_dump($db->query('SELECT COUNT(*) FROM test LEFT JOIN classtypes ON test.classtype=classtypes.id WHERE (classtypes.id IS NULL OR classtypes.id > 0)')->fetchColumn());
161:
162: echo 
"===DATABASE===\n";
163:
$stmt $db->prepare('SELECT classtypes.name AS name, test.val AS val FROM test LEFT JOIN classtypes ON test.classtype=classtypes.id WHERE (classtypes.id IS NULL OR classtypes.id > 0)');
164:
165:
$stmt->execute();
166:
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
167:
168: echo 
"===FETCHCLASS===\n";
169:
$stmt->execute();
170:
var_dump($stmt->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_CLASSTYPE|PDO::FETCH_SERIALIZE'TestLeaf'));
171:
172:
173:
?>
174:

Expected

string(1) "3"
array(3) {
  [0]=>
  string(8) "stdClass"
  [1]=>
  string(8) "TestBase"
  [2]=>
  string(11) "TestDerived"
}
===TYPES===
array(4) {
  ["stdClass"]=>
  string(1) "0"
  ["TestBase"]=>
  string(1) "1"
  ["TestDerived"]=>
  string(1) "2"
  ["TestLeaf"]=>
  NULL
}
===INSERT===
TestBase::serialize() = 'a:3:{s:7:"BasePub";s:6:"Public";s:7:"BasePro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}'
TestDerived::serialize()
TestBase::serialize() = 'a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}'
TestDerived::serialize()
TestBase::serialize() = 'a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}'
===DATA===
array(4) {
  [0]=>
  string(0) ""
  [1]=>
  string(91) "a:3:{s:7:"BasePub";s:6:"Public";s:7:"BasePro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}"
  [2]=>
  string(172) "a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}"
  [3]=>
  string(172) "a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}"
}
===FAILURE===
Exception:SQLSTATE[HY000]: General error: cannot unserialize class
===COUNT===
string(1) "3"
===DATABASE===
array(3) {
  [0]=>
  array(2) {
    ["name"]=>
    string(8) "TestBase"
    ["val"]=>
    string(91) "a:3:{s:7:"BasePub";s:6:"Public";s:7:"BasePro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}"
  }
  [1]=>
  array(2) {
    ["name"]=>
    string(11) "TestDerived"
    ["val"]=>
    string(172) "a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}"
  }
  [2]=>
  array(2) {
    ["name"]=>
    NULL
    ["val"]=>
    string(172) "a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}"
  }
}
===FETCHCLASS===
TestBase::unserialize(a:3:{s:7:"BasePub";s:6:"Public";s:7:"BasePro";s:9:"Protected";s:7:"BasePri";s:7:"Private";})
TestDerived::unserialize()
TestBase::unserialize(a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";})
TestDerived::unserialize()
TestBase::unserialize(a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";})
array(3) {
  [0]=>
  object(TestBase)#%d (3) {
    ["BasePub"]=>
    string(7) "#Public"
    ["BasePro":protected]=>
    string(10) "#Protected"
    ["BasePri":"TestBase":private]=>
    string(8) "#Private"
  }
  [1]=>
  object(TestDerived)#%d (6) {
    ["BasePub"]=>
    string(14) "#DerivedPublic"
    ["BasePro":protected]=>
    string(17) "#DerivdeProtected"
    ["DerivedPub"]=>
    string(7) "#Public"
    ["DerivedPro":protected]=>
    string(10) "#Protected"
    ["DerivedPri":"TestDerived":private]=>
    string(7) "Private"
    ["BasePri":"TestBase":private]=>
    string(8) "#Private"
  }
  [2]=>
  object(TestLeaf)#%d (6) {
    ["BasePub"]=>
    string(14) "#DerivedPublic"
    ["BasePro":protected]=>
    string(17) "#DerivdeProtected"
    ["DerivedPub"]=>
    string(7) "#Public"
    ["DerivedPro":protected]=>
    string(10) "#Protected"
    ["DerivedPri":"TestDerived":private]=>
    string(7) "Private"
    ["BasePri":"TestBase":private]=>
    string(8) "#Private"
  }
}

Output

***********************************************************************
Fatal NI connect error 12541, connecting to:
 (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=XE)(CID=(PROGRAM=php)(HOST=nex2.php.net)(USER=nlopess)))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))

  VERSION INFORMATION:
	TNS for Linux: Version 11.2.0.2.0 - Beta
	TCP/IP NT Protocol Adapter for Linux: Version 11.2.0.2.0 - Beta
  Time: 17-JUN-2018 09:45:14
  Tracing not turned on.
  Tns error struct:
    ns main err code: 12541
    TNS-12541: TNS:no listener
    ns secondary err code: 12560
    nt main err code: 511
    TNS-00511: No listener

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-12541: TNS:no listener
 (/var/php_gcov/PHP_HEAD/ext/pdo_oci/oci_driver.c:634) in /var/php_gcov/PHP_HEAD/ext/pdo/tests/pdo_test.inc:35
Stack trace:
#0 /var/php_gcov/PHP_HEAD/ext/pdo/tests/pdo_test.inc(35): PDO->__construct('oci:dbname=//lo...', 'system', 'oracle', NULL)
#1 /var/php_gcov/PHP_HEAD/ext/pdo_oci/tests/pdo_018.php(4): PDOTest::factory()
#2 {main}
  thrown in /var/php_gcov/PHP_HEAD/ext/pdo/tests/pdo_test.inc on line 35
    nt secondary err code: 111
    nt OS err code: 0

Diff

# original source file: ext/pdo/tests/pdo_018.phpt
001+ ***********************************************************************
002+ Fatal NI connect error 12541, connecting to:
003+  (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=XE)(CID=(PROGRAM=php)(HOST=nex2.php.net)(USER=nlopess)))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))
004+ 
005+   VERSION INFORMATION:
006+ 	TNS for Linux: Version 11.2.0.2.0 - Beta
007+ 	TCP/IP NT Protocol Adapter for Linux: Version 11.2.0.2.0 - Beta
008+   Time: 17-JUN-2018 09:45:14
009+   Tracing not turned on.
010+   Tns error struct:
011+     ns main err code: 12541
012+     TNS-12541: TNS:no listener
013+     ns secondary err code: 12560
014+     nt main err code: 511
015+     TNS-00511: No listener
016+ 
017+ Fatal error: Uncaught PDOException: SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-12541: TNS:no listener
018+  (/var/php_gcov/PHP_HEAD/ext/pdo_oci/oci_driver.c:634) in /var/php_gcov/PHP_HEAD/ext/pdo/tests/pdo_test.inc:35
019+ Stack trace:
020+ #0 /var/php_gcov/PHP_HEAD/ext/pdo/tests/pdo_test.inc(35): PDO->__construct('oci:dbname=//lo...', 'system', 'oracle', NULL)
021+ #1 /var/php_gcov/PHP_HEAD/ext/pdo_oci/tests/pdo_018.php(4): PDOTest::factory()
022+ #2 {main}
023+   thrown in /var/php_gcov/PHP_HEAD/ext/pdo/tests/pdo_test.inc on line 35
024+     nt secondary err code: 111
025+     nt OS err code: 0
001- string(1) "3"
002- array(3) {
003-   [0]=>
004-   string(8) "stdClass"
005-   [1]=>
006-   string(8) "TestBase"
007-   [2]=>
008-   string(11) "TestDerived"
009- }
010- ===TYPES===
011- array(4) {
012-   ["stdClass"]=>
013-   string(1) "0"
014-   ["TestBase"]=>
015-   string(1) "1"
016-   ["TestDerived"]=>
017-   string(1) "2"
018-   ["TestLeaf"]=>
019-   NULL
020- }
021- ===INSERT===
022- TestBase::serialize() = 'a:3:{s:7:"BasePub";s:6:"Public";s:7:"BasePro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}'
023- TestDerived::serialize()
024- TestBase::serialize() = 'a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}'
025- TestDerived::serialize()
026- TestBase::serialize() = 'a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}'
027- ===DATA===
028- array(4) {
029-   [0]=>
030-   string(0) ""
031-   [1]=>
032-   string(91) "a:3:{s:7:"BasePub";s:6:"Public";s:7:"BasePro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}"
033-   [2]=>
034-   string(172) "a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}"
035-   [3]=>
036-   string(172) "a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}"
037- }
038- ===FAILURE===
039- Exception:SQLSTATE[HY000]: General error: cannot unserialize class
040- ===COUNT===
041- string(1) "3"
042- ===DATABASE===
043- array(3) {
044-   [0]=>
045-   array(2) {
046-     ["name"]=>
047-     string(8) "TestBase"
048-     ["val"]=>
049-     string(91) "a:3:{s:7:"BasePub";s:6:"Public";s:7:"BasePro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}"
050-   }
051-   [1]=>
052-   array(2) {
053-     ["name"]=>
054-     string(11) "TestDerived"
055-     ["val"]=>
056-     string(172) "a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}"
057-   }
058-   [2]=>
059-   array(2) {
060-     ["name"]=>
061-     NULL
062-     ["val"]=>
063-     string(172) "a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}"
064-   }
065- }
066- ===FETCHCLASS===
067- TestBase::unserialize(a:3:{s:7:"BasePub";s:6:"Public";s:7:"BasePro";s:9:"Protected";s:7:"BasePri";s:7:"Private";})
068- TestDerived::unserialize()
069- TestBase::unserialize(a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";})
070- TestDerived::unserialize()
071- TestBase::unserialize(a:5:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";s:7:"BasePri";s:7:"Private";})
072- array(3) {
073-   [0]=>
074-   object(TestBase)#%d (3) {
075-     ["BasePub"]=>
076-     string(7) "#Public"
077-     ["BasePro":protected]=>
078-     string(10) "#Protected"
079-     ["BasePri":"TestBase":private]=>
080-     string(8) "#Private"
081-   }
082-   [1]=>
083-   object(TestDerived)#%d (6) {
084-     ["BasePub"]=>
085-     string(14) "#DerivedPublic"
086-     ["BasePro":protected]=>
087-     string(17) "#DerivdeProtected"
088-     ["DerivedPub"]=>
089-     string(7) "#Public"
090-     ["DerivedPro":protected]=>
091-     string(10) "#Protected"
092-     ["DerivedPri":"TestDerived":private]=>
093-     string(7) "Private"
094-     ["BasePri":"TestBase":private]=>
095-     string(8) "#Private"
096-   }
097-   [2]=>
098-   object(TestLeaf)#%d (6) {
099-     ["BasePub"]=>
100-     string(14) "#DerivedPublic"
101-     ["BasePro":protected]=>
102-     string(17) "#DerivdeProtected"
103-     ["DerivedPub"]=>
104-     string(7) "#Public"
105-     ["DerivedPro":protected]=>
106-     string(10) "#Protected"
107-     ["DerivedPri":"TestDerived":private]=>
108-     string(7) "Private"
109-     ["BasePri":"TestBase":private]=>
110-     string(8) "#Private"
111-   }
112- }

 

Generated at Mon, 18 Jun 2018 17:33:50 +0000 (2 days ago)

Copyright © 2005-2018 The PHP Group
All rights reserved.