DispatchTest.php 923 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace think\tests;
  3. use GuzzleHttp\Psr7\Response;
  4. use Mockery;
  5. use PHPUnit\Framework\TestCase;
  6. use think\Request;
  7. use think\route\Dispatch;
  8. use think\route\Rule;
  9. class DispatchTest extends TestCase
  10. {
  11. public function testPsr7Response()
  12. {
  13. $request = Mockery::mock(Request::class);
  14. $rule = Mockery::mock(Rule::class);
  15. $dispatch = new class($request, $rule, '') extends Dispatch {
  16. public function exec()
  17. {
  18. return new Response(200, ['framework' => ['tp', 'thinkphp'], 'psr' => 'psr-7'], '123');
  19. }
  20. };
  21. $response = $dispatch->run();
  22. $this->assertInstanceOf(\think\Response::class, $response);
  23. $this->assertEquals('123', $response->getContent());
  24. $this->assertEquals('tp, thinkphp', $response->getHeader('framework'));
  25. $this->assertEquals('psr-7', $response->getHeader('psr'));
  26. }
  27. }