Ejemplo n.º 1
0
 public function testConstructWithSuccess()
 {
     $mockFile = Mockery::mock(UploadedFileInterface::class);
     $mockUri = Mockery::mock(UriInterface::class);
     $mockUri->shouldReceive('getPath')->andReturn('/abc/def');
     $mockUri->shouldReceive('getQuery')->andReturn('hello=world');
     $request = new ServerRequest(['SERVER_SOFTWARE' => 'PHP 5.6.8 Development Server', 'SERVER_PROTOCOL' => 'HTTP/1.1', 'SERVER_NAME' => '0.0.0.0', 'SERVER_PORT' => '8002', 'REQUEST_URI' => '/', 'REQUEST_METHOD' => 'POST', 'PHP_SELF' => '/index.php', 'HTTP_HOST' => 'localhost:8002', 'HTTP_CONNECTION' => 'keep-alive', 'HTTP_CONTENT_LENGTH' => '56854', 'HTTP_PRAGMA' => 'no-cache', 'HTTP_CACHE_CONTROL' => 'no-cache', 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'HTTP_ORIGIN' => 'http://localhost:8002', 'HTTP_USER_AGENT' => 'Mozilla/5.0', 'HTTP_COOKIE' => 'PHPSESSID=32eo4tk9dcaacb2f3hqg0s6s54', 'REQUEST_TIME_FLOAT' => 1431675149.316002, 'REQUEST_TIME' => 1431675149], ['page' => 1, 'order' => false], ['id' => 'wan2land'], ['PHPSESSID' => '32eo4tk9dcaacb2f3hqg0s6s54'], ['profileImage' => $mockFile], ['status' => 'join'], 'GET', $mockUri, null, ['host' => ['localhost:8002'], 'connection' => ['keep-alive'], 'user-agent' => ['Mozilla/5.0'], 'cookie' => ['PHPSESSID=32eo4tk9dcaacb2f3hqg0s6s54']], '2.0');
     static::assertEquals(['PHPSESSID' => '32eo4tk9dcaacb2f3hqg0s6s54'], $request->getCookieParams());
     static::assertEquals(['page' => 1, 'order' => false], $request->getQueryParams());
     static::assertEquals(['profileImage' => $mockFile], $request->getUploadedFiles());
     static::assertEquals(['id' => 'wan2land'], $request->getParsedBody());
     static::assertEquals(['status' => 'join'], $request->getAttributes());
     // message
     static::assertEquals('2.0', $request->getProtocolVersion());
     static::assertEquals(['host' => ['localhost:8002'], 'connection' => ['keep-alive'], 'user-agent' => ['Mozilla/5.0'], 'cookie' => ['PHPSESSID=32eo4tk9dcaacb2f3hqg0s6s54']], $request->getHeaders());
 }