mirror of
https://github.com/maximebf/php-debugbar.git
synced 2025-01-17 21:38:14 +01:00
35fa8abe90
Introduce a new HtmlVariableListWidget that is similar to VariableListWidget but for variables with HTML contents. Update the collectors that use the existing VariableListWidget to use DebugBarVarDumper to dump the variables using the VarDumper HtmlDumper. Because many debug bar users may not yet support inline static assets, default to use the old VariableListWidget for now. Updated collectors: * ConfigCollector * RequestDataCollector
57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace DebugBar\Tests\DataCollector;
|
|
|
|
use DebugBar\Tests\DebugBarTestCase;
|
|
use DebugBar\DebugBar;
|
|
use DebugBar\DataCollector\ConfigCollector;
|
|
|
|
class ConfigCollectorTest extends DebugBarTestCase
|
|
{
|
|
public function testCollect()
|
|
{
|
|
$c = new ConfigCollector(array('s' => 'bar', 'a' => array(), 'o' => new \stdClass()));
|
|
$data = $c->collect();
|
|
$this->assertArrayHasKey('s', $data);
|
|
$this->assertEquals('bar', $data['s']);
|
|
$this->assertArrayHasKey('a', $data);
|
|
$this->assertEquals("[]", $data['a']);
|
|
$this->assertArrayHasKey('o', $data);
|
|
}
|
|
|
|
public function testName()
|
|
{
|
|
$c = new ConfigCollector(array(), 'foo');
|
|
$this->assertEquals('foo', $c->getName());
|
|
$this->assertArrayHasKey('foo', $c->getWidgets());
|
|
}
|
|
|
|
public function testAssets()
|
|
{
|
|
$c = new ConfigCollector();
|
|
$this->assertEmpty($c->getAssets());
|
|
|
|
$c->useHtmlVarDumper();
|
|
$this->assertNotEmpty($c->getAssets());
|
|
}
|
|
|
|
public function testHtmlRendering()
|
|
{
|
|
$c = new ConfigCollector(array('k' => array('one', 'two')));
|
|
|
|
$this->assertFalse($c->isHtmlVarDumperUsed());
|
|
$data = $c->collect();
|
|
$this->assertEquals(array('k'), array_keys($data));
|
|
$this->assertContains('one', $data['k']);
|
|
$this->assertContains('two', $data['k']);
|
|
$this->assertNotContains('span', $data['k']);
|
|
|
|
$c->useHtmlVarDumper();
|
|
$data = $c->collect();
|
|
$this->assertEquals(array('k'), array_keys($data));
|
|
$this->assertContains('one', $data['k']);
|
|
$this->assertContains('two', $data['k']);
|
|
$this->assertContains('span', $data['k']);
|
|
}
|
|
}
|