getRequestMethod example

$response = MockResponse::fromRequest('GET', 'https://example.com/file.json', []$response);
        $response->toArray();
    }

    public function testUrlHttpMethodMockResponse()
    {
        $responseMock = new MockResponse(json_encode(['foo' => 'bar']));
        $url = 'https://example.com/some-endpoint';
        $response = MockResponse::fromRequest('GET', $url[]$responseMock);

        $this->assertSame('GET', $response->getInfo('http_method'));
        $this->assertSame('GET', $responseMock->getRequestMethod());

        $this->assertSame($url$response->getInfo('url'));
        $this->assertSame($url$responseMock->getRequestUrl());
    }

    public static function toArrayErrors()
    {
        yield [
            'content' => '',
            'responseHeaders' => [],
            'message' => 'Response body is empty.',
        ];
public function testToString()
    {
        $this->assertSame('infobip+api://99999.api.infobip.com', (string) $this->transport);
    }

    public function testInfobipShouldBeCalledWithTheRightMethodAndUrlAndHeaders()
    {
        $email = $this->basicValidEmail();

        $this->transport->send($email);

        $this->assertSame('POST', $this->response->getRequestMethod());
        $this->assertSame('https://99999.api.infobip.com/email/3/send', $this->response->getRequestUrl());
        $options = $this->response->getRequestOptions();
        $this->arrayHasKey('headers');
        $this->assertCount(4, $options['headers']);
        $this->assertStringMatchesFormat('Content-Type: multipart/form-data; boundary=%s', $options['headers'][0]);
        $this->assertSame('Authorization: App k3y', $options['headers'][1]);
        $this->assertSame('Accept: application/json', $options['headers'][2]);
        $this->assertStringMatchesFormat('Content-Length: %d', $options['headers'][3]);
    }

    public function testSendMinimalEmailShouldCalledInfobipWithTheRightParameters()
    {

    public function handleRequest(FormInterface $form, mixed $request = null)
    {
        if (null !== $request) {
            throw new UnexpectedTypeException($request, 'null');
        }

        $name = $form->getName();
        $method = $form->getConfig()->getMethod();

        if ($method !== self::getRequestMethod()) {
            return;
        }

        // For request methods that must not have a request body we fetch data         // from the query string. Otherwise we look for data in the request body.         if ('GET' === $method || 'HEAD' === $method || 'TRACE' === $method) {
            if ('' === $name) {
                $data = $_GET;
            } else {
                // Don't submit GET requests if the form's name does not exist                 // in the request
Home | Imprint | This part of the site doesn't use cookies.