-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
82 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/http-server/test/testing/Controller/HeaderController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php declare(strict_types=1); | ||
|
||
|
||
namespace SwoftTest\Http\Server\Testing\Controller; | ||
|
||
use Swoft\Http\Message\Request; | ||
use Swoft\Http\Server\Annotation\Mapping\Controller; | ||
use Swoft\Http\Server\Annotation\Mapping\RequestMapping; | ||
|
||
/** | ||
* Class HeaderController | ||
* | ||
* @since 2.0 | ||
* | ||
* @Controller("testHeader") | ||
*/ | ||
class HeaderController | ||
{ | ||
/** | ||
* @RequestMapping() | ||
* | ||
* @param Request $request | ||
* | ||
* @return array | ||
*/ | ||
public function headerLines(Request $request): array | ||
{ | ||
return $request->getHeaderLines(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php declare(strict_types=1); | ||
|
||
|
||
namespace SwoftTest\Http\Server\Unit; | ||
|
||
use ReflectionException; | ||
use Swoft\Bean\Exception\ContainerException; | ||
|
||
/** | ||
* Class HeaderTest | ||
* | ||
* @since 2.0 | ||
*/ | ||
class HeaderTest extends TestCase | ||
{ | ||
/** | ||
* @throws ReflectionException | ||
* @throws ContainerException | ||
*/ | ||
public function testHeaderLines(): void | ||
{ | ||
$headers = [ | ||
'user-agent' => 'curl/7.29.0', | ||
'host' => '127.0.0.1:18306', | ||
'content-type' => 'application/json', | ||
'accept' => '*/*', | ||
'id' => 1024, | ||
'id2' => 2048 | ||
]; | ||
|
||
$response = $this->mockServer->request('POST', '/testHeader/headerLines', [], $headers); | ||
$response->assertEqualJson($headers); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters