File: ServerRequestTest.php

package info (click to toggle)
php-http-psr7-integration-tests 1.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 452 kB
  • sloc: php: 1,593; makefile: 19
file content (40 lines) | stat: -rw-r--r-- 1,703 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php

namespace Http\Psr7Test\Tests\Guzzle;

use GuzzleHttp\Psr7\ServerRequest;
use Http\Psr7Test\ServerRequestIntegrationTest;

class ServerRequestTest extends ServerRequestIntegrationTest
{
    /**
     * Guzzle accepts more types for parsed body.
     *
     * ServerRequestInterface::withParsedBody says
     * > The data IS NOT REQUIRED to come from $_POST, but MUST be the results of
     * > deserializing the request body content. Deserialization/parsing returns
     * > structured data, and, as such, this method ONLY accepts arrays or objects,
     * > or a null value if nothing was available to parse.
     * > As an example, if content negotiation determines that the request data
     * > is a JSON payload, this method could be used to create a request
     * > instance with the deserialized parameters.
     *
     * A JSON body payload can also be a json string, a json int etc. So withParsedBody would also need to accept that as well. Those two sentences contradict each other.
     * According to a slack discussion, this was based on rfc4627
     * > A JSON text is a serialized object or array.
     *
     * But that is outdated since since rfc7158 in 2013 which does not limit it to array or object anymore. See current https://tools.ietf.org/html/rfc8259
     *
     * > A JSON text is a serialized value. Note that certain previous
     * > specifications of JSON constrained a JSON text to be an object or an
     * > array.
     */
    protected $skippedTests = [
        'testGetParsedBodyInvalid' => 'more types are accepted per rfc7158',
    ];

    public function createSubject()
    {
        return new ServerRequest('GET', '/', [], null, '1.1', $_SERVER);
    }
}