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_firebird/tests/pdo_018.phpt ('FIREBIRD 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:
$db->exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, classtype int NULL, val VARCHAR(255) NULL)');
63:
64:
$db->setAttribute(PDO::ATTR_ERRMODEPDO::ERRMODE_EXCEPTION);
65:
66:
var_dump($db->query('SELECT COUNT(*) FROM classtypes')->fetchColumn());
67:
var_dump($db->query('SELECT id, name FROM classtypes ORDER by id')->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_UNIQUE));
68:
69:
$objs = array();
70:
$objs[0] = new stdClass;
71:
$objs[1] = new TestBase;
72:
$objs[2] = new TestDerived;
73:
$objs[3] = new TestLeaf;
74:
75:
$stmt $db->prepare('SELECT id FROM classtypes WHERE name=:cname');
76:
$stmt->bindParam(':cname'$cname);
77:
78:
$ctypes = array();
79:
80: foreach(
$objs as $obj)
81: {
82:     
$cname get_class($obj);
83:     
$ctype NULL/* set default for non stored class name */
84:     
$stmt->execute();
85:     
$stmt->bindColumn('id'$ctype);
86:     
$stmt->fetch(PDO::FETCH_BOUND);
87:     
$ctypes[$cname] = $ctype;
88: }
89:
90: echo 
"===TYPES===\n";
91:
var_dump($ctypes);
92:
93: unset(
$stmt);
94:
95: echo 
"===INSERT===\n";
96:
$stmt $db->prepare('INSERT INTO test VALUES(:id, :classtype, :val)');
97:
$stmt->bindParam(':id'$idx);
98:
$stmt->bindParam(':classtype'$ctype);
99:
$stmt->bindParam(':val'$val);
100:
101: foreach(
$objs as $idx => $obj)
102: {
103:     
$ctype $ctypes[get_class($obj)];
104:     if (
method_exists($obj'serialize'))
105:     {
106:         
$val $obj->serialize();
107:     }
108:     else
109:     {
110:         
$val '';
111:     }
112:     
$stmt->execute();    
113: }
114:
115: unset(
$stmt);
116:
117: echo 
"===DATA===\n";
118:
$res $db->query('SELECT test.val FROM test')->fetchAll(PDO::FETCH_COLUMN);
119:
120: switch (
$db->getAttribute(PDO::ATTR_DRIVER_NAME)) {
121:     case 
'dblib':
122:         
// map whitespace (from early TDS versions) to empty string so the test doesn't diff
123:         
if ($res[0] === ' ') {
124:             
$res[0] = '';
125:         }
126:         break;
127:
128:     case 
'oci':
129:         
// map NULL to empty string so the test doesn't diff
130:         
if ($res[0] === null) {
131:             
$res[0] = '';
132:         }
133:         break;
134: }
135:
var_dump($res);
136:
137: echo 
"===FAILURE===\n";
138: try
139: {
140:     
$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());
141: }
142: catch (
PDOException $e)
143: {
144:     echo 
'Exception:';
145:     echo 
$e->getMessage()."\n";
146: }
147:
148: echo 
"===COUNT===\n";
149:
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());
150:
151: echo 
"===DATABASE===\n";
152:
$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)');
153:
154:
$stmt->execute();
155:
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
156:
157: echo 
"===FETCHCLASS===\n";
158:
$stmt->execute();
159:
var_dump($stmt->fetchAll(PDO::FETCH_CLASS|PDO::FETCH_CLASSTYPE|PDO::FETCH_SERIALIZE'TestLeaf'));
160:
161:
162:
?>
163:

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

Warning: PDO::exec(): SQLSTATE[HY000]: General error: -104 Dynamic SQL Error SQL error code = -104 Token unknown - line 1, column 62 NULL  in /var/php_gcov/PHP_HEAD/ext/pdo_firebird/tests/pdo_018.php on line 62
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===

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: -204 Dynamic SQL Error SQL error code = -204 Table unknown TEST At line 1, column 13  in /var/php_gcov/PHP_HEAD/ext/pdo_firebird/tests/pdo_018.php:96
Stack trace:
#0 /var/php_gcov/PHP_HEAD/ext/pdo_firebird/tests/pdo_018.php(96): PDO->prepare('INSERT INTO tes...')
#1 {main}
  thrown in /var/php_gcov/PHP_HEAD/ext/pdo_firebird/tests/pdo_018.php on line 96

Diff

# original source file: ext/pdo/tests/pdo_018.phpt
001+ Warning: PDO::exec(): SQLSTATE[HY000]: General error: -104 Dynamic SQL Error SQL error code = -104 Token unknown - line 1, column 62 NULL  in /var/php_gcov/PHP_HEAD/ext/pdo_firebird/tests/pdo_018.php on line 62
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===
023+ 
024+ Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: -204 Dynamic SQL Error SQL error code = -204 Table unknown TEST At line 1, column 13  in /var/php_gcov/PHP_HEAD/ext/pdo_firebird/tests/pdo_018.php:96
025+ Stack trace:
026+ #0 /var/php_gcov/PHP_HEAD/ext/pdo_firebird/tests/pdo_018.php(96): PDO->prepare('INSERT INTO tes...')
027+ #1 {main}
028+   thrown in /var/php_gcov/PHP_HEAD/ext/pdo_firebird/tests/pdo_018.php on line 96
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 Sun, 04 Dec 2016 08:48:57 +0000 (6 days ago)

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