2014-04-05 20:31:16 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the Symfony package.
|
|
|
|
*
|
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Symfony\Component\VarDumper\Tests;
|
|
|
|
|
2014-10-06 07:45:07 +01:00
|
|
|
use Symfony\Component\VarDumper\Cloner\VarCloner;
|
2014-04-05 20:31:16 +01:00
|
|
|
use Symfony\Component\VarDumper\Dumper\CliDumper;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Nicolas Grekas <p@tchwork.com>
|
|
|
|
*/
|
|
|
|
class CliDumperTest extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
public function testGet()
|
|
|
|
{
|
|
|
|
require __DIR__.'/Fixtures/dumb-var.php';
|
|
|
|
|
|
|
|
$dumper = new CliDumper('php://output');
|
|
|
|
$dumper->setColors(false);
|
2014-10-06 07:45:07 +01:00
|
|
|
$cloner = new VarCloner();
|
2014-09-17 09:28:09 +01:00
|
|
|
$cloner->addCasters(array(
|
|
|
|
':stream' => function ($res, $a) {
|
|
|
|
unset($a['uri']);
|
|
|
|
|
|
|
|
return $a;
|
2014-10-06 07:45:07 +01:00
|
|
|
},
|
2014-09-17 09:28:09 +01:00
|
|
|
));
|
2014-04-05 20:31:16 +01:00
|
|
|
$data = $cloner->cloneVar($var);
|
|
|
|
|
|
|
|
ob_start();
|
|
|
|
$dumper->dump($data);
|
|
|
|
$out = ob_get_clean();
|
|
|
|
$closureLabel = PHP_VERSION_ID >= 50400 ? 'public method' : 'function';
|
|
|
|
$out = preg_replace('/[ \t]+$/m', '', $out);
|
2014-09-26 08:07:47 +01:00
|
|
|
$intMax = PHP_INT_MAX;
|
2014-10-10 16:31:59 +01:00
|
|
|
$res1 = (int) $var['res'];
|
|
|
|
$res2 = (int) $var[8];
|
2014-04-05 20:31:16 +01:00
|
|
|
|
2014-10-10 16:31:59 +01:00
|
|
|
$this->assertStringMatchesFormat(
|
2014-04-05 20:31:16 +01:00
|
|
|
<<<EOTXT
|
|
|
|
array:25 [
|
|
|
|
"number" => 1
|
2014-10-10 16:31:59 +01:00
|
|
|
0 => &1 null
|
2014-04-05 20:31:16 +01:00
|
|
|
"const" => 1.1
|
|
|
|
1 => true
|
|
|
|
2 => false
|
|
|
|
3 => NAN
|
|
|
|
4 => INF
|
|
|
|
5 => -INF
|
2014-09-26 08:07:47 +01:00
|
|
|
6 => {$intMax}
|
2014-04-05 20:31:16 +01:00
|
|
|
"str" => "déjà"
|
2014-10-22 07:47:25 +01:00
|
|
|
7 => b"é@"
|
2014-04-05 20:31:16 +01:00
|
|
|
"[]" => []
|
2014-10-10 16:31:59 +01:00
|
|
|
"res" => :stream {@{$res1}
|
2014-04-05 20:31:16 +01:00
|
|
|
wrapper_type: "plainfile"
|
2014-09-17 09:28:09 +01:00
|
|
|
stream_type: "STDIO"
|
2014-04-05 20:31:16 +01:00
|
|
|
mode: "r"
|
|
|
|
unread_bytes: 0
|
|
|
|
seekable: true
|
|
|
|
timed_out: false
|
|
|
|
blocked: true
|
|
|
|
eof: false
|
|
|
|
options: []
|
|
|
|
}
|
2014-10-10 16:31:59 +01:00
|
|
|
8 => :Unknown {@{$res2}}
|
|
|
|
"obj" => Symfony\Component\VarDumper\Tests\Fixture\DumbFoo {#%d
|
2014-10-31 18:55:04 +00:00
|
|
|
+foo: "foo"
|
|
|
|
+"bar": "bar"
|
2014-04-05 20:31:16 +01:00
|
|
|
}
|
2014-10-10 16:31:59 +01:00
|
|
|
"closure" => Closure {#%d
|
2014-04-05 20:31:16 +01:00
|
|
|
reflection: """
|
|
|
|
Closure [ <user> {$closureLabel} Symfony\Component\VarDumper\Tests\Fixture\{closure} ] {
|
|
|
|
@@ {$var['file']} {$var['line']} - {$var['line']}
|
|
|
|
|
|
|
|
- Parameters [2] {
|
|
|
|
Parameter #0 [ <required> \$a ]
|
|
|
|
Parameter #1 [ <optional> PDO or NULL &\$b = NULL ]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
"line" => {$var['line']}
|
|
|
|
"nobj" => array:1 [
|
2014-10-10 16:31:59 +01:00
|
|
|
0 => &3 {#%d}
|
2014-04-05 20:31:16 +01:00
|
|
|
]
|
2014-10-10 16:31:59 +01:00
|
|
|
"recurs" => &4 array:1 [
|
|
|
|
0 => &4 array:1 [&4]
|
2014-04-05 20:31:16 +01:00
|
|
|
]
|
2014-09-08 19:39:52 +01:00
|
|
|
9 => &1 null
|
2014-10-10 16:31:59 +01:00
|
|
|
"sobj" => Symfony\Component\VarDumper\Tests\Fixture\DumbFoo {#%d}
|
|
|
|
"snobj" => &3 {#%d}
|
|
|
|
"snobj2" => {#%d}
|
2014-04-05 20:31:16 +01:00
|
|
|
"file" => "{$var['file']}"
|
|
|
|
b"bin-key-é" => ""
|
|
|
|
]
|
|
|
|
|
|
|
|
EOTXT
|
|
|
|
,
|
|
|
|
|
|
|
|
$out
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|