db backup prior to drupal security update
[yaffs-website] / vendor / symfony / var-dumper / Tests / Caster / PdoCasterTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\VarDumper\Tests\Caster;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\VarDumper\Caster\PdoCaster;
16 use Symfony\Component\VarDumper\Cloner\Stub;
17
18 /**
19  * @author Nicolas Grekas <p@tchwork.com>
20  */
21 class PdoCasterTest extends TestCase
22 {
23     /**
24      * @requires extension pdo_sqlite
25      */
26     public function testCastPdo()
27     {
28         $pdo = new \PDO('sqlite::memory:');
29         $pdo->setAttribute(\PDO::ATTR_STATEMENT_CLASS, array('PDOStatement', array($pdo)));
30
31         $cast = PdoCaster::castPdo($pdo, array(), new Stub(), false);
32
33         $this->assertInstanceOf('Symfony\Component\VarDumper\Caster\EnumStub', $cast["\0~\0attributes"]);
34
35         $attr = $cast["\0~\0attributes"] = $cast["\0~\0attributes"]->value;
36         $this->assertInstanceOf('Symfony\Component\VarDumper\Caster\ConstStub', $attr['CASE']);
37         $this->assertSame('NATURAL', $attr['CASE']->class);
38         $this->assertSame('BOTH', $attr['DEFAULT_FETCH_MODE']->class);
39
40         $xCast = array(
41             "\0~\0inTransaction" => $pdo->inTransaction(),
42             "\0~\0attributes" => array(
43                 'CASE' => $attr['CASE'],
44                 'ERRMODE' => $attr['ERRMODE'],
45                 'PERSISTENT' => false,
46                 'DRIVER_NAME' => 'sqlite',
47                 'ORACLE_NULLS' => $attr['ORACLE_NULLS'],
48                 'CLIENT_VERSION' => $pdo->getAttribute(\PDO::ATTR_CLIENT_VERSION),
49                 'SERVER_VERSION' => $pdo->getAttribute(\PDO::ATTR_SERVER_VERSION),
50                 'STATEMENT_CLASS' => array('PDOStatement'),
51                 'DEFAULT_FETCH_MODE' => $attr['DEFAULT_FETCH_MODE'],
52             ),
53         );
54         unset($cast["\0~\0attributes"]['STATEMENT_CLASS'][1]);
55
56         $this->assertSame($xCast, $cast);
57     }
58 }