From 463d048bb00a3345b88e535beca46057bb3dd99c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=AD=E6=98=95?= <715557344@qq.com> Date: Tue, 16 Jun 2020 15:58:06 +0800 Subject: [PATCH] Added test case. --- CHANGELOG.md | 4 ++++ src/http-message/tests/MessageTraitTest.php | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 638691bd4..8b961e4de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # v1.1.33 - TBD +## Fixed + +- [#1917](https://github.com/hyperf/hyperf/pull/1917) Fixed bug that `Request::isXmlHttpRequest` does not work. + ## Optimized - [#1793](https://github.com/hyperf/hyperf/pull/1793) Socket.io server now only dispatch connect/disconnect events in onOpen and onClose. Also upgrade some class members from private to protected, so users can hack them. diff --git a/src/http-message/tests/MessageTraitTest.php b/src/http-message/tests/MessageTraitTest.php index badb45493..426a1e680 100644 --- a/src/http-message/tests/MessageTraitTest.php +++ b/src/http-message/tests/MessageTraitTest.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace HyperfTest\HttpMessage; use Hyperf\HttpMessage\Base\Request; +use Hyperf\HttpMessage\Server\Request as ServerRequest; use PHPUnit\Framework\TestCase; /** @@ -38,4 +39,13 @@ class MessageTraitTest extends TestCase $this->assertSame('1000', $request->getHeaderLine('1000')); $this->assertSame('XMLHttpRequest', $request->getHeaderLine('X-Requested-With')); } + + public function testIsXmlHttpRequest() + { + $request = new ServerRequest('GET', '/', [ + 'X-Requested-With' => 'XMLHttpRequest', + ]); + + $this->assertTrue($request->isXmlHttpRequest()); + } }