2013-06-13 18:48:23 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace DebugBar\Tests;
|
|
|
|
|
2013-08-14 22:12:33 +10:00
|
|
|
use DebugBar\DebugBar;
|
|
|
|
use DebugBar\RandomRequestIdGenerator;
|
|
|
|
|
2013-06-13 18:48:23 +08:00
|
|
|
abstract class DebugBarTestCase extends \PHPUnit_Framework_TestCase
|
|
|
|
{
|
2013-08-14 22:12:33 +10:00
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
$this->debugbar = new DebugBar();
|
2013-09-19 16:31:00 -04:00
|
|
|
$this->debugbar->setHttpDriver($http = new MockHttpDriver());
|
2013-08-14 22:12:33 +10:00
|
|
|
}
|
2013-08-14 22:22:07 +10:00
|
|
|
|
|
|
|
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]);
|
|
|
|
}
|
2013-06-13 18:48:23 +08:00
|
|
|
}
|