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/OpenHandlerTest.php
Stefan Schramm dff80cdb1c
Fix PHP 8.2 deprecations (#531)
* Fix deprecation: Use of "parent" in callables is deprecated

* Fix deprecations in tests

Creation of dynamic properties is deprecated since php 8.2
2023-08-18 19:36:53 +02:00

51 lines
1.4 KiB
PHP

<?php
namespace DebugBar\Tests;
use DebugBar\DebugBar;
use DebugBar\DebugBarException;
use DebugBar\OpenHandler;
use DebugBar\Tests\Storage\MockStorage;
class OpenHandlerTest extends DebugBarTestCase
{
private $openHandler;
public function setUp(): void
{
parent::setUp();
$this->debugbar->setStorage(new MockStorage(array('foo' => array('__meta' => array('id' => 'foo')))));
$this->openHandler = new OpenHandler($this->debugbar);
}
public function testFind()
{
$request = array();
$result = $this->openHandler->handle($request, false, false);
$this->assertJsonArrayNotEmpty($result);
}
public function testGet()
{
$request = array('op' => 'get', 'id' => 'foo');
$result = $this->openHandler->handle($request, false, false);
$this->assertJsonIsObject($result);
$this->assertJsonHasProperty($result, '__meta');
$data = json_decode($result, true);
$this->assertEquals('foo', $data['__meta']['id']);
}
public function testGetMissingId()
{
$this->expectException(DebugBarException::class);
$this->openHandler->handle(array('op' => 'get'), false, false);
}
public function testClear()
{
$result = $this->openHandler->handle(array('op' => 'clear'), false, false);
$this->assertJsonPropertyEquals($result, 'success', true);
}
}