4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\VarDumper\Tests\Caster;
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;
20 * @author Nicolas Grekas <p@tchwork.com>
22 class PdoCasterTest extends TestCase
24 use VarDumperTestTrait;
27 * @requires extension pdo_sqlite
29 public function testCastPdo()
31 $pdo = new \PDO('sqlite::memory:');
32 $pdo->setAttribute(\PDO::ATTR_STATEMENT_CLASS, array('PDOStatement', array($pdo)));
34 $cast = PdoCaster::castPdo($pdo, array(), new Stub(), false);
36 $this->assertInstanceOf('Symfony\Component\VarDumper\Caster\EnumStub', $cast["\0~\0attributes"]);
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);
45 "\x00~\x00inTransaction" => false
46 "\x00~\x00attributes" => array:9 [
50 "DRIVER_NAME" => "sqlite"
51 "ORACLE_NULLS" => NATURAL
52 "CLIENT_VERSION" => "%s"
53 "SERVER_VERSION" => "%s"
54 "STATEMENT_CLASS" => array:%d [
57 "DEFAULT_FETCH_MODE" => BOTH
62 $this->assertDumpMatchesFormat($xDump, $cast);