* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\VarDumper\Tests; use Symfony\Component\VarDumper\Cloner\PhpCloner; use Symfony\Component\VarDumper\Dumper\HtmlDumper; /** * @author Nicolas Grekas
*/
class HtmlDumperTest extends \PHPUnit_Framework_TestCase
{
public function testGet()
{
require __DIR__.'/Fixtures/dumb-var.php';
$dumper = new HtmlDumper('php://output');
$dumper->setColors(false);
$cloner = new PhpCloner();
$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);
$var['file'] = htmlspecialchars($var['file'], ENT_QUOTES, 'UTF-8');
$this->assertSame(
<<array:25 [
"1
=> null #1
" " => 1.1
=> true
=> false
=> NAN
=> INF
=> -INF
=> 9223372036854775807
" " => "déjà"
=> b"é"
" " => []
" " => resource:stream {
plainfile"
: "dir"
: "r"
: 0
: true
: false
: true
: false
: []
}
: " => resource:Unknown {}
" " => Symfony\Component\VarDumper\Tests\Fixture\DumbFoo { #2
foo: "foo"
"bar": "bar"
}
" " => Closure {
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 ]
}
}
"""
}
" : """
" => {$var['line']}
" " => array:1 [
#3
]
" => {} " => array:1 [ #4
&4 array:1 [@4]
]
=> => &1 null
" " => Symfony\Component\VarDumper\Tests\Fixture\DumbFoo {@2}
" " => &3 {@3}
" " => {@3}
" " => "{$var['file']}"
b" " => ""
]
" =>
EOTXT
,
$out
);
}
}