mirror of
https://github.com/maximebf/php-debugbar.git
synced 2025-01-17 13:28:35 +01:00
9544e0bf2a
* Test on PHP 8 * Fix tests
48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace DebugBar\Tests;
|
|
|
|
use DebugBar\DebugBar;
|
|
use DebugBar\RandomRequestIdGenerator;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
abstract class DebugBarTestCase extends TestCase
|
|
{
|
|
public function setUp(): void
|
|
{
|
|
$this->debugbar = new DebugBar();
|
|
$this->debugbar->setHttpDriver($http = new MockHttpDriver());
|
|
}
|
|
|
|
public function assertJsonIsArray($json)
|
|
{
|
|
$data = json_decode($json);
|
|
$this->assertTrue(is_array($data));
|
|
}
|
|
|
|
public function assertJsonIsObject($json)
|
|
{
|
|
$data = json_decode($json);
|
|
$this->assertTrue(is_object($data));
|
|
}
|
|
|
|
public function assertJsonArrayNotEmpty($json)
|
|
{
|
|
$data = json_decode($json, true);
|
|
$this->assertTrue(is_array($data) && !empty($data));
|
|
}
|
|
|
|
public function assertJsonHasProperty($json, $property)
|
|
{
|
|
$data = json_decode($json, true);
|
|
$this->assertTrue(array_key_exists($property, $data));
|
|
}
|
|
|
|
public function assertJsonPropertyEquals($json, $property, $expected)
|
|
{
|
|
$data = json_decode($json, true);
|
|
$this->assertTrue(array_key_exists($property, $data));
|
|
$this->assertEquals($expected, $data[$property]);
|
|
}
|
|
}
|