1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-01-17 13:28:35 +01:00
php-debugbar/tests/DebugBar/Tests/DataCollector/ConfigCollectorTest.php
Witold Wasiczko 9544e0bf2a
Test on PHP 8 (#456)
* Test on PHP 8

* Fix tests
2020-12-07 11:39:43 +01:00

57 lines
1.8 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->assertStringContainsString('one', $data['k']);
$this->assertStringContainsString('two', $data['k']);
$this->assertStringNotContainsString('span', $data['k']);
$c->useHtmlVarDumper();
$data = $c->collect();
$this->assertEquals(array('k'), array_keys($data));
$this->assertStringContainsString('one', $data['k']);
$this->assertStringContainsString('two', $data['k']);
$this->assertStringContainsString('span', $data['k']);
}
}