Skip to content

Commit

Permalink
unit test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ibelar committed Jun 13, 2024
1 parent 38295ed commit 7bdeeab
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/Service/Ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ public static function serverRequest(): ServerRequestInterface
}

public static function getQueryParamValue(string $param): ?string
{
return static::service()->returnQueryParamValue($param);
}

protected function returnQueryParamValue(string $param): ?string
{
$params = [];
parse_str(static::service()->serverRequest()->getUri()->getQuery(), $params);
Expand Down
3 changes: 2 additions & 1 deletion tests/Callback/CallbackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
use Fohn\Ui\HtmlTemplate;
use Fohn\Ui\Js\Js;
use Fohn\Ui\Service\Ui;
use Fohn\Ui\Tests\UiTestService;
use Fohn\Ui\View;

class CallbackTest extends \PHPUnit\Framework\TestCase
{
protected function setUp(): void
{
$ui = Ui::service();
$ui = UiTestService::service();
$ui->setApp(new MockApp(['registerShutdown' => false]));
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Callback/init-test-callback-ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
Data::setDb($config['db']);

$ui->environment = $config['env'];
$ui->displayformat = $config['format'];
$ui->setDisplayFormat($config['format']);
$ui->timezone($config['timezone']);

$ui->setApp($app);
Expand Down
18 changes: 18 additions & 0 deletions tests/UiTestService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);
/**
* Ui Service setup for testing purpose.
*/

namespace Fohn\Ui\Tests;

use Fohn\Ui\Service\Ui;

class UiTestService extends Ui
{
protected function returnQueryParamValue(string $param): ?string
{
return $_GET[$param] ?? null;
}
}

0 comments on commit 7bdeeab

Please sign in to comment.