Skip to content

Commit

Permalink
ServerRequestTest - Fix for php < 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bkdotcom committed Jan 25, 2024
1 parent 90dd623 commit b7270a8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/HttpMessage/ServerRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use bdk\PhpUnitPolyfill\ExpectExceptionTrait;
use PHPUnit\Framework\TestCase;
use ReflectionObject;
use RuntimeException;

/**
* @covers \bdk\HttpMessage\AssertionTrait
Expand All @@ -21,6 +22,32 @@ class ServerRequestTest extends TestCase
use DataProviderTrait;
use FactoryTrait;

static $errorHandler;

/**
* setUp is executed before each test
*
* @return void
*/
public function setUp(): void
{
// for PHP < 7.0
// convert PHP Recoverable Error: Argument 1 passed to bdk\HttpMessage\ServerRequest::withQueryParams() must be of the type array, object given
self::$errorHandler = \set_error_handler(function ($type, $msg) {
throw new RuntimeException($msg);
});
}

/**
* tearDown is executed after each test
*
* @return void
*/
public function tearDown(): void
{
set_error_handler(self::$errorHandler);
}

public function testConstruct()
{
$serverRequest = $this->createServerRequest();
Expand Down

0 comments on commit b7270a8

Please sign in to comment.