comparison vendor/symfony/var-dumper/Tests/Caster/PdoCasterTest.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 129ea1e6d783
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
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 use Symfony\Component\VarDumper\Test\VarDumperTestTrait;
18
19 /**
20 * @author Nicolas Grekas <p@tchwork.com>
21 */
22 class PdoCasterTest extends TestCase
23 {
24 use VarDumperTestTrait;
25
26 /**
27 * @requires extension pdo_sqlite
28 */
29 public function testCastPdo()
30 {
31 $pdo = new \PDO('sqlite::memory:');
32 $pdo->setAttribute(\PDO::ATTR_STATEMENT_CLASS, array('PDOStatement', array($pdo)));
33
34 $cast = PdoCaster::castPdo($pdo, array(), new Stub(), false);
35
36 $this->assertInstanceOf('Symfony\Component\VarDumper\Caster\EnumStub', $cast["\0~\0attributes"]);
37
38 $attr = $cast["\0~\0attributes"] = $cast["\0~\0attributes"]->value;
39 $this->assertInstanceOf('Symfony\Component\VarDumper\Caster\ConstStub', $attr['CASE']);
40 $this->assertSame('NATURAL', $attr['CASE']->class);
41 $this->assertSame('BOTH', $attr['DEFAULT_FETCH_MODE']->class);
42
43 $xDump = <<<'EODUMP'
44 array:2 [
45 "\x00~\x00inTransaction" => false
46 "\x00~\x00attributes" => array:9 [
47 "CASE" => NATURAL
48 "ERRMODE" => SILENT
49 "PERSISTENT" => false
50 "DRIVER_NAME" => "sqlite"
51 "ORACLE_NULLS" => NATURAL
52 "CLIENT_VERSION" => "%s"
53 "SERVER_VERSION" => "%s"
54 "STATEMENT_CLASS" => array:%d [
55 0 => "PDOStatement"%A
56 ]
57 "DEFAULT_FETCH_MODE" => BOTH
58 ]
59 ]
60 EODUMP;
61
62 $this->assertDumpMatchesFormat($xDump, $cast);
63 }
64 }