ソースを参照

Remove deprecated code in Http/Client.

Mark Story 8 年 前
コミット
41016a41bd

+ 0 - 118
src/Http/Client/CookieCollection.php

@@ -1,118 +0,0 @@
-<?php
-/**
- * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
- * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
- *
- * Licensed under The MIT License
- * Redistributions of files must retain the above copyright notice.
- *
- * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
- * @link          https://cakephp.org CakePHP(tm) Project
- * @since         3.0.0
- * @license       https://opensource.org/licenses/mit-license.php MIT License
- */
-namespace Cake\Http\Client;
-
-use Cake\Http\Cookie\CookieCollection as BaseCollection;
-use Cake\Http\Cookie\CookieInterface;
-
-/**
- * Container class for cookies used in Http\Client.
- *
- * Provides cookie jar like features for storing cookies between
- * requests, as well as appending cookies to new requests.
- *
- * @deprecated 3.5.0 Use Cake\Http\Cookie\CookieCollection instead.
- */
-class CookieCollection extends BaseCollection
-{
-
-    /**
-     * {@inheritDoc}
-     */
-    public function __construct(array $cookies = [])
-    {
-        parent::__construct($cookies);
-
-        deprecationWarning('Use Cake\Http\Cookie\CookieCollection instead.');
-    }
-
-    /**
-     * Store the cookies from a response.
-     *
-     * Store the cookies that haven't expired. If a cookie has been expired
-     * and is currently stored, it will be removed.
-     *
-     * @param Response $response The response to read cookies from
-     * @param string $url The request URL used for default host/path values.
-     * @return void
-     */
-    public function store(Response $response, $url)
-    {
-        $host = parse_url($url, PHP_URL_HOST);
-        $path = parse_url($url, PHP_URL_PATH);
-        $path = $path ?: '/';
-
-        $header = $response->getHeader('Set-Cookie');
-        $cookies = $this->parseSetCookieHeader($header);
-        $cookies = $this->setRequestDefaults($cookies, $host, $path);
-        foreach ($cookies as $cookie) {
-            $this->cookies[$cookie->getId()] = $cookie;
-        }
-        $this->removeExpiredCookies($host, $path);
-    }
-
-    /**
-     * Get stored cookies for a URL.
-     *
-     * Finds matching stored cookies and returns a simple array
-     * of name => value
-     *
-     * @param string $url The URL to find cookies for.
-     * @return array
-     */
-    public function get($url)
-    {
-        $path = parse_url($url, PHP_URL_PATH) ?: '/';
-        $host = parse_url($url, PHP_URL_HOST);
-        $scheme = parse_url($url, PHP_URL_SCHEME);
-
-        return $this->findMatchingCookies($scheme, $host, $path);
-    }
-
-    /**
-     * Get all the stored cookies as arrays.
-     *
-     * @return array
-     */
-    public function getAll()
-    {
-        $out = [];
-        foreach ($this->cookies as $cookie) {
-            $out[] = $this->convertCookieToArray($cookie);
-        }
-
-        return $out;
-    }
-
-    /**
-     * Convert the cookie into an array of its properties.
-     *
-     * Primarily useful where backwards compatibility is needed.
-     *
-     * @param \Cake\Http\Cookie\CookieInterface $cookie Cookie object.
-     * @return array
-     */
-    protected function convertCookieToArray(CookieInterface $cookie)
-    {
-        return [
-            'name' => $cookie->getName(),
-            'value' => $cookie->getValue(),
-            'path' => $cookie->getPath(),
-            'domain' => $cookie->getDomain(),
-            'secure' => $cookie->isSecure(),
-            'httponly' => $cookie->isHttpOnly(),
-            'expires' => $cookie->getExpiresTimestamp()
-        ];
-    }
-}

+ 0 - 16
src/Http/Client/Message.php

@@ -158,22 +158,6 @@ class Message
     protected $_body;
 
     /**
-     * Get all headers
-     *
-     * @return array
-     * @deprecated 3.3.0 Use getHeaders() instead.
-     */
-    public function headers()
-    {
-        deprecationWarning(
-            'Message::headers() is deprecated. ' .
-            'Use getHeaders() instead.'
-        );
-
-        return $this->headers;
-    }
-
-    /**
      * Get all cookies
      *
      * @return array

+ 0 - 187
src/Http/Client/Request.php

@@ -52,117 +52,6 @@ class Request extends Message implements RequestInterface
     }
 
     /**
-     * Get/Set the HTTP method.
-     *
-     * *Warning* This method mutates the request in-place for backwards
-     * compatibility reasons, and is not part of the PSR7 interface.
-     *
-     * @param string|null $method The method for the request.
-     * @return $this|string Either this or the current method.
-     * @throws \Cake\Core\Exception\Exception On invalid methods.
-     * @deprecated 3.3.0 Use getMethod() and withMethod() instead.
-     */
-    public function method($method = null)
-    {
-        deprecationWarning(
-            'Request::method() is deprecated. ' .
-            'Use getMethod() and withMethod() instead.'
-        );
-
-        if ($method === null) {
-            return $this->method;
-        }
-        $name = get_called_class() . '::METHOD_' . strtoupper($method);
-        if (!defined($name)) {
-            throw new Exception('Invalid method type');
-        }
-        $this->method = $method;
-
-        return $this;
-    }
-
-    /**
-     * Get/Set the url for the request.
-     *
-     * *Warning* This method mutates the request in-place for backwards
-     * compatibility reasons, and is not part of the PSR7 interface.
-     *
-     * @param string|null $url The url for the request. Leave null for get
-     * @return $this|string Either $this or the url value.
-     * @deprecated 3.3.0 Use getUri() and withUri() instead.
-     */
-    public function url($url = null)
-    {
-        deprecationWarning(
-            'Request::url() is deprecated. ' .
-            'Use getUri() and withUri() instead.'
-        );
-
-        if ($url === null) {
-            return '' . $this->getUri();
-        }
-        $this->uri = $this->createUri($url);
-
-        return $this;
-    }
-
-    /**
-     * Get/Set headers into the request.
-     *
-     * You can get the value of a header, or set one/many headers.
-     * Headers are set / fetched in a case insensitive way.
-     *
-     * ### Getting headers
-     *
-     * ```
-     * $request->header('Content-Type');
-     * ```
-     *
-     * ### Setting one header
-     *
-     * ```
-     * $request->header('Content-Type', 'application/json');
-     * ```
-     *
-     * ### Setting multiple headers
-     *
-     * ```
-     * $request->header(['Connection' => 'close', 'User-Agent' => 'CakePHP']);
-     * ```
-     *
-     * *Warning* This method mutates the request in-place for backwards
-     * compatibility reasons, and is not part of the PSR7 interface.
-     *
-     * @param string|array|null $name The name to get, or array of multiple values to set.
-     * @param string|null $value The value to set for the header.
-     * @return mixed Either $this when setting or header value when getting.
-     * @deprecated 3.3.0 Use withHeader() and getHeaderLine() instead.
-     */
-    public function header($name = null, $value = null)
-    {
-        deprecationWarning(
-            'Request::header() is deprecated. ' .
-            'Use withHeader() and getHeaderLine() instead.'
-        );
-
-        if ($value === null && is_string($name)) {
-            $val = $this->getHeaderLine($name);
-            if ($val === '') {
-                return null;
-            }
-
-            return $val;
-        }
-
-        if ($value !== null && !is_array($name)) {
-            $name = [$name => $value];
-        }
-        $this->addHeaders($name);
-
-        return $this;
-    }
-
-    /**
      * Add an array of headers to the request.
      *
      * @param array $headers The headers to add.
@@ -178,82 +67,6 @@ class Request extends Message implements RequestInterface
     }
 
     /**
-     * Get/Set cookie values.
-     *
-     * ### Getting a cookie
-     *
-     * ```
-     * $request->cookie('session');
-     * ```
-     *
-     * ### Setting one cookie
-     *
-     * ```
-     * $request->cookie('session', '123456');
-     * ```
-     *
-     * ### Setting multiple headers
-     *
-     * ```
-     * $request->cookie(['test' => 'value', 'split' => 'banana']);
-     * ```
-     *
-     * @param string $name The name of the cookie to get/set
-     * @param string|null $value Either the value or null when getting values.
-     * @return mixed Either $this or the cookie value.
-     * @deprecated 3.5.0 No longer used. CookieCollections now add `Cookie` header to the request
-     *   before sending. Use Cake\Http\Cookie\CookieCollection::addToRequest() to make adding cookies
-     *   to a request easier.
-     */
-    public function cookie($name, $value = null)
-    {
-        deprecationWarning(
-            'Request::cookie() is deprecated. ' .
-            'The Client internals now add the required `Cookie` header to the ' .
-            'request before sending. Use Cake\Http\Cookie\CookieCollection::addToRequest() ' .
-            'to make adding cookies to a request easier.'
-        );
-
-        if ($value === null && is_string($name)) {
-            return isset($this->_cookies[$name]) ? $this->_cookies[$name] : null;
-        }
-        if (is_string($name) && is_string($value)) {
-            $name = [$name => $value];
-        }
-        foreach ($name as $key => $val) {
-            $this->_cookies[$key] = $val;
-        }
-
-        return $this;
-    }
-
-    /**
-     * Get/Set HTTP version.
-     *
-     * *Warning* This method mutates the request in-place for backwards
-     * compatibility reasons, and is not part of the PSR7 interface.
-     *
-     * @param string|null $version The HTTP version.
-     * @return $this|string Either $this or the HTTP version.
-     * @deprecated 3.3.0 Use getProtocolVersion() and withProtocolVersion() instead.
-     */
-    public function version($version = null)
-    {
-        deprecationWarning(
-            'Request::version() is deprecated. ' .
-            'Use getProtocolVersion() and withProtocolVersion() instead.'
-        );
-
-        if ($version === null) {
-            return $this->protocol;
-        }
-
-        $this->protocol = $version;
-
-        return $this;
-    }
-
-    /**
      * Get/set the body/payload for the message.
      *
      * Array data will be serialized with Cake\Http\FormData,

+ 2 - 112
src/Http/Client/Response.php

@@ -13,9 +13,7 @@
  */
 namespace Cake\Http\Client;
 
-// This alias is necessary to avoid class name conflicts
-// with the deprecated class in this namespace.
-use Cake\Http\Cookie\CookieCollection as CookiesCollection;
+use Cake\Http\Cookie\CookieCollection;
 use Cake\Http\Cookie\CookieInterface;
 use Psr\Http\Message\ResponseInterface;
 use RuntimeException;
@@ -267,22 +265,6 @@ class Response extends Message implements ResponseInterface
     }
 
     /**
-     * Get the status code from the response
-     *
-     * @return int
-     * @deprecated 3.3.0 Use getStatusCode() instead.
-     */
-    public function statusCode()
-    {
-        deprecationWarning(
-            'Response::statusCode() is deprecated. ' .
-            'Use Response::getStatusCode() instead.'
-        );
-
-        return $this->code;
-    }
-
-    /**
      * {@inheritdoc}
      *
      * @return int The status code.
@@ -322,22 +304,6 @@ class Response extends Message implements ResponseInterface
      * Get the encoding if it was set.
      *
      * @return string|null
-     * @deprecated 3.3.0 Use getEncoding() instead.
-     */
-    public function encoding()
-    {
-        deprecationWarning(
-            'Response::encoding() is deprecated. ' .
-            'Use Response::getEncoding() instead.'
-        );
-
-        return $this->getEncoding();
-    }
-
-    /**
-     * Get the encoding if it was set.
-     *
-     * @return string|null
      */
     public function getEncoding()
     {
@@ -354,66 +320,6 @@ class Response extends Message implements ResponseInterface
     }
 
     /**
-     * Read single/multiple header value(s) out.
-     *
-     * @param string|null $name The name of the header you want. Leave
-     *   null to get all headers.
-     * @return mixed Null when the header doesn't exist. An array
-     *   will be returned when getting all headers or when getting
-     *   a header that had multiple values set. Otherwise a string
-     *   will be returned.
-     * @deprecated 3.3.0 Use getHeader() and getHeaderLine() instead.
-     */
-    public function header($name = null)
-    {
-        deprecationWarning(
-            'Response::header() is deprecated. ' .
-            'Use Response::getHeader() and getHeaderLine() instead.'
-        );
-
-        if ($name === null) {
-            return $this->_getHeaders();
-        }
-        $header = $this->getHeader($name);
-        if (count($header) === 1) {
-            return $header[0];
-        }
-
-        return $header;
-    }
-
-    /**
-     * Read single/multiple cookie values out.
-     *
-     * *Note* This method will only provide access to cookies that
-     * were added as part of the constructor. If cookies are added post
-     * construction they will not be accessible via this method.
-     *
-     * @param string|null $name The name of the cookie you want. Leave
-     *   null to get all cookies.
-     * @param bool $all Get all parts of the cookie. When false only
-     *   the value will be returned.
-     * @return mixed
-     * @deprecated 3.3.0 Use getCookie(), getCookieData() or getCookies() instead.
-     */
-    public function cookie($name = null, $all = false)
-    {
-        deprecationWarning(
-            'Response::cookie() is deprecated. ' .
-            'Use Response::getCookie(), getCookieData() or getCookies() instead.'
-        );
-
-        if ($name === null) {
-            return $this->getCookies();
-        }
-        if ($all) {
-            return $this->getCookieData($name);
-        }
-
-        return $this->getCookie($name);
-    }
-
-    /**
      * Get the all cookie data.
      *
      * @return array The cookie data
@@ -505,7 +411,7 @@ class Response extends Message implements ResponseInterface
         if ($this->cookies) {
             return;
         }
-        $this->cookies = CookiesCollection::createFromHeader($this->getHeader('Set-Cookie'));
+        $this->cookies = CookieCollection::createFromHeader($this->getHeader('Set-Cookie'));
     }
 
     /**
@@ -526,22 +432,6 @@ class Response extends Message implements ResponseInterface
     }
 
     /**
-     * Get the HTTP version used.
-     *
-     * @return string
-     * @deprecated 3.3.0 Use getProtocolVersion()
-     */
-    public function version()
-    {
-        deprecationWarning(
-            'Response::version() is deprecated. ' .
-            'Use Response::getProtocolVersion() instead.'
-        );
-
-        return $this->protocol;
-    }
-
-    /**
      * Get the response body.
      *
      * By passing in a $parser callable, you can get the decoded

+ 0 - 308
tests/TestCase/Http/Client/CookieCollectionTest.php

@@ -1,308 +0,0 @@
-<?php
-/**
- * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
- * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
- *
- * Licensed under The MIT License
- * Redistributions of files must retain the above copyright notice.
- *
- * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
- * @link          https://cakephp.org CakePHP(tm) Project
- * @since         3.0.0
- * @license       https://opensource.org/licenses/mit-license.php MIT License
- */
-namespace Cake\Test\TestCase\Http\Client;
-
-use Cake\Http\Client\CookieCollection;
-use Cake\Http\Client\Response;
-use Cake\TestSuite\TestCase;
-
-/**
- * HTTP cookies test.
- *
- * @group deprecated
- */
-class CookieCollectionTest extends TestCase
-{
-
-    /**
-     * setup
-     *
-     * @return void
-     */
-    public function setUp()
-    {
-        parent::setUp();
-        $this->deprecated(function () {
-            $this->cookies = new CookieCollection();
-        });
-    }
-
-    /**
-     * test store
-     *
-     * @return void
-     */
-    public function testStore()
-    {
-        $headers = [
-            'HTTP/1.0 200 Ok',
-            'Set-Cookie: first=1',
-            'Set-Cookie: second=2; Path=/; Domain=.foo.example.com',
-            'Set-Cookie: expiring=now; Expires=Wed, 09-Jun-1999 10:18:14 GMT',
-        ];
-        $response = new Response($headers, '');
-        $result = $this->cookies->store($response, 'http://example.com/some/path');
-        $this->assertNull($result);
-
-        $result = $this->cookies->getAll();
-        $this->assertCount(2, $result);
-        $expected = [
-            [
-                'name' => 'first',
-                'value' => '1',
-                'path' => '/some/path',
-                'domain' => 'example.com',
-                'secure' => false,
-                'httponly' => false,
-                'expires' => 0,
-            ],
-            [
-                'name' => 'second',
-                'value' => '2',
-                'path' => '/',
-                'domain' => '.foo.example.com',
-                'secure' => false,
-                'httponly' => false,
-                'expires' => 0,
-            ],
-        ];
-        $this->assertEquals($expected, $result);
-    }
-
-    /**
-     * test store secure.
-     *
-     * @return void
-     */
-    public function testStoreSecure()
-    {
-        $headers = [
-            'HTTP/1.0 200 Ok',
-            'Set-Cookie: first=1',
-            'Set-Cookie: second=2; Secure; HttpOnly',
-        ];
-        $response = new Response($headers, '');
-        $result = $this->cookies->store($response, 'http://example.com/some/path');
-        $this->assertNull($result);
-
-        $result = $this->cookies->getAll();
-        $this->assertCount(2, $result);
-        $expected = [
-            [
-                'name' => 'first',
-                'value' => '1',
-                'path' => '/some/path',
-                'domain' => 'example.com',
-                'secure' => false,
-                'httponly' => false,
-                'expires' => 0,
-            ],
-            [
-                'name' => 'second',
-                'value' => '2',
-                'path' => '/some/path',
-                'domain' => 'example.com',
-                'secure' => true,
-                'httponly' => true,
-                'expires' => 0,
-            ],
-        ];
-        $this->assertEquals($expected, $result);
-    }
-
-    /**
-     * test storing an expired cookie clears existing ones too.
-     *
-     * @return void
-     */
-    public function testStoreExpiring()
-    {
-        $headers = [
-            'HTTP/1.0 200 Ok',
-            'Set-Cookie: first=1',
-            'Set-Cookie: second=2; Path=/',
-        ];
-        $response = new Response($headers, '');
-        $this->cookies->store($response, 'http://example.com/some/path');
-
-        $result = $this->cookies->getAll();
-        $this->assertCount(2, $result);
-
-        $headers = [
-            'HTTP/1.0 200 Ok',
-            'Set-Cookie: first=1; Expires=Wed, 09-Jun-1999 10:18:14 GMT',
-        ];
-        $response = new Response($headers, '');
-        $this->cookies->store($response, 'http://example.com/');
-        $result = $this->cookies->getAll();
-        $this->assertCount(2, $result, 'Path does not match, no expiration');
-
-        // Use a more common date format that doesn't match
-        $headers = [
-            'HTTP/1.0 200 Ok',
-            'Set-Cookie: first=1; Domain=.foo.example.com; Expires=Wed, 09-Jun-1999 10:18:14 GMT',
-        ];
-        $response = new Response($headers, '');
-        $this->cookies->store($response, 'http://example.com/some/path');
-        $result = $this->cookies->getAll();
-        $this->assertCount(2, $result, 'Domain does not match, no expiration');
-
-        // Use an RFC1123 date
-        $headers = [
-            'HTTP/1.0 200 Ok',
-            'Set-Cookie: first=1; Expires=Wed, 09 Jun 1999 10:18:14 GMT',
-        ];
-        $response = new Response($headers, '');
-        $this->cookies->store($response, 'http://example.com/some/path');
-        $result = $this->cookies->getAll();
-        $this->assertCount(1, $result, 'Domain does not match, no expiration');
-
-        $expected = [
-            [
-                'name' => 'second',
-                'value' => '2',
-                'path' => '/',
-                'domain' => 'example.com',
-                'expires' => 0,
-                'secure' => false,
-                'httponly' => false,
-            ],
-        ];
-        $this->assertEquals($expected, $result);
-    }
-
-    /**
-     * test getting cookies with secure flags
-     *
-     * @return void
-     */
-    public function testGetMatchingSecure()
-    {
-        $headers = [
-            'HTTP/1.0 200 Ok',
-            'Set-Cookie: first=1',
-            'Set-Cookie: second=2; Secure; HttpOnly',
-        ];
-        $response = new Response($headers, '');
-        $this->cookies->store($response, 'https://example.com/');
-
-        $result = $this->cookies->get('https://example.com/test');
-        $expected = ['first' => '1', 'second' => '2'];
-        $this->assertEquals($expected, $result);
-
-        $result = $this->cookies->get('http://example.com/test');
-        $expected = ['first' => '1'];
-        $this->assertEquals($expected, $result);
-    }
-
-    /**
-     * test getting cookies with secure flags
-     *
-     * @return void
-     */
-    public function testGetMatchingPath()
-    {
-        $headers = [
-            'HTTP/1.0 200 Ok',
-            'Set-Cookie: first=1; Path=/foo',
-            'Set-Cookie: second=2; Path=/',
-        ];
-        $response = new Response($headers, '');
-        $this->cookies->store($response, 'http://example.com/foo');
-
-        $result = $this->cookies->get('http://example.com/foo');
-        $expected = ['first' => '1', 'second' => 2];
-        $this->assertEquals($expected, $result);
-
-        $result = $this->cookies->get('http://example.com/');
-        $expected = ['second' => 2];
-        $this->assertEquals($expected, $result);
-
-        $result = $this->cookies->get('http://example.com/test');
-        $expected = ['second' => 2];
-        $this->assertEquals($expected, $result);
-    }
-
-    /**
-     * Test getting cookies matching on paths exactly
-     *
-     * @return void
-     */
-    public function testGetMatchingDomain()
-    {
-        $headers = [
-            'HTTP/1.0 200 Ok',
-            'Set-Cookie: first=1; Domain=example.com',
-            'Set-Cookie: second=2;',
-        ];
-        $response = new Response($headers, '');
-        $this->cookies->store($response, 'http://foo.example.com/');
-
-        $result = $this->cookies->get('http://example.com');
-        $expected = ['first' => 1];
-        $this->assertEquals($expected, $result);
-
-        $result = $this->cookies->get('http://foo.example.com');
-        $expected = ['first' => 1, 'second' => '2'];
-        $this->assertEquals($expected, $result);
-
-        $result = $this->cookies->get('http://bar.foo.example.com');
-        $expected = ['first' => 1, 'second' => '2'];
-        $this->assertEquals($expected, $result);
-
-        $result = $this->cookies->get('http://api.example.com');
-        $expected = ['first' => 1];
-        $this->assertEquals($expected, $result);
-
-        $result = $this->cookies->get('http://google.com');
-        $expected = [];
-        $this->assertEquals($expected, $result);
-    }
-
-    /**
-     * Test getting cookies matching on paths exactly
-     *
-     * @return void
-     */
-    public function testGetMatchingDomainWithDot()
-    {
-        $headers = [
-            'HTTP/1.0 200 Ok',
-            'Set-Cookie: first=1; Domain=.example.com',
-            'Set-Cookie: second=2;',
-        ];
-        $response = new Response($headers, '');
-        $this->cookies->store($response, 'http://foo.example.com/');
-
-        $result = $this->cookies->get('http://example.com');
-        $expected = ['first' => 1];
-        $this->assertEquals($expected, $result);
-
-        $result = $this->cookies->get('http://foo.example.com');
-        $expected = ['first' => 1, 'second' => '2'];
-        $this->assertEquals($expected, $result);
-
-        $result = $this->cookies->get('http://bar.foo.example.com');
-        $expected = ['first' => 1, 'second' => '2'];
-        $this->assertEquals($expected, $result);
-
-        $result = $this->cookies->get('http://api.example.com');
-        $expected = ['first' => 1];
-        $this->assertEquals($expected, $result);
-
-        $result = $this->cookies->get('http://google.com');
-        $expected = [];
-        $this->assertEquals($expected, $result);
-    }
-}

+ 0 - 199
tests/TestCase/Http/Client/RequestTest.php

@@ -118,96 +118,6 @@ class RequestTest extends TestCase
     }
 
     /**
-     * test url method
-     *
-     * @group deprecated
-     * @return void
-     */
-    public function testUrl()
-    {
-        $this->deprecated(function () {
-            $request = new Request();
-            $this->assertSame($request, $request->url('http://example.com'));
-
-            $this->assertEquals('http://example.com', $request->url());
-        });
-    }
-
-    /**
-     * Test that url() modifies the PSR7 stream
-     *
-     * @group deprecated
-     * @return void
-     */
-    public function testUrlInteroperability()
-    {
-        $this->deprecated(function () {
-            $request = new Request();
-            $request->url('http://example.com');
-            $this->assertSame('http://example.com', $request->url());
-            $this->assertSame('http://example.com', $request->getUri()->__toString());
-
-            $uri = 'http://example.com/test';
-            $request = new Request();
-            $request = $request->withUri(new Uri($uri));
-            $this->assertSame($uri, $request->url());
-            $this->assertSame($uri, $request->getUri()->__toString());
-        });
-    }
-
-    /**
-     * test method method.
-     *
-     * @group deprecated
-     * @return void
-     */
-    public function testMethod()
-    {
-        $this->deprecated(function () {
-            $request = new Request();
-            $this->assertSame($request, $request->method(Request::METHOD_GET));
-
-            $this->assertEquals(Request::METHOD_GET, $request->method());
-        });
-    }
-
-    /**
-     * test method interoperability.
-     *
-     * @group deprecated
-     * @return void
-     */
-    public function testMethodInteroperability()
-    {
-        $this->deprecated(function () {
-            $request = new Request();
-            $this->assertSame($request, $request->method(Request::METHOD_GET));
-
-            $this->assertEquals(Request::METHOD_GET, $request->method());
-            $this->assertEquals(Request::METHOD_GET, $request->getMethod());
-
-            $request = $request->withMethod(Request::METHOD_GET);
-            $this->assertEquals(Request::METHOD_GET, $request->method());
-            $this->assertEquals(Request::METHOD_GET, $request->getMethod());
-        });
-    }
-
-    /**
-     * test invalid method.
-     *
-     * @group deprecated
-     * @return void
-     */
-    public function testMethodInvalid()
-    {
-        $this->expectException(\Cake\Core\Exception\Exception::class);
-        $this->deprecated(function () {
-            $request = new Request();
-            $request->method('set on fire');
-        });
-    }
-
-    /**
      * test body method.
      *
      * @return void
@@ -224,7 +134,6 @@ class RequestTest extends TestCase
     /**
      * test body method with array payload
      *
-     * @group deprecated
      * @return void
      */
     public function testBodyArray()
@@ -262,38 +171,6 @@ class RequestTest extends TestCase
     }
 
     /**
-     * test header method.
-     *
-     * @group deprecated
-     * @return void
-     */
-    public function testHeader()
-    {
-        $this->deprecated(function () {
-            $request = new Request();
-            $type = 'application/json';
-            $result = $request->header('Content-Type', $type);
-            $this->assertSame($result, $request, 'Should return self');
-
-            $result = $request->header('content-type');
-            $this->assertEquals($type, $result, 'lowercase does not work');
-
-            $result = $request->header('ConTent-typE');
-            $this->assertEquals($type, $result, 'Funny casing does not work');
-
-            $result = $request->header([
-                'Connection' => 'close',
-                'user-agent' => 'CakePHP'
-            ]);
-            $this->assertSame($result, $request, 'Should return self');
-
-            $this->assertEquals('close', $request->header('connection'));
-            $this->assertEquals('CakePHP', $request->header('USER-AGENT'));
-            $this->assertNull($request->header('not set'));
-        });
-    }
-
-    /**
      * Test the default headers
      *
      * @return void
@@ -304,80 +181,4 @@ class RequestTest extends TestCase
         $this->assertEquals('CakePHP', $request->getHeaderLine('User-Agent'));
         $this->assertEquals('close', $request->getHeaderLine('Connection'));
     }
-
-    /**
-     * Test that header() and PSR7 methods play nice.
-     *
-     * @group deprecated
-     * @return void
-     */
-    public function testHeaderMethodInteroperability()
-    {
-        $this->deprecated(function () {
-            $request = new Request();
-            $request->header('Content-Type', 'application/json');
-            $this->assertEquals('application/json', $request->header('Content-Type'), 'Old getter should work');
-
-            $this->assertEquals('application/json', $request->getHeaderLine('Content-Type'), 'getHeaderLine works');
-            $this->assertEquals('application/json', $request->getHeaderLine('content-type'), 'getHeaderLine works');
-            $this->assertEquals(['application/json'], $request->getHeader('Content-Type'), 'getHeader works');
-            $this->assertEquals(['application/json'], $request->getHeader('content-type'), 'getHeader works');
-        });
-    }
-
-    /**
-     * test cookie method.
-     *
-     * @group deprecated
-     * @return void
-     */
-    public function testCookie()
-    {
-        $this->deprecated(function () {
-            $request = new Request();
-            $result = $request->cookie('session', '123456');
-            $this->assertSame($result, $request, 'Should return self');
-
-            $this->assertNull($request->cookie('not set'));
-
-            $result = $request->cookie('session');
-            $this->assertEquals('123456', $result);
-        });
-    }
-
-    /**
-     * test version method.
-     *
-     * @group deprecated
-     * @return void
-     */
-    public function testVersion()
-    {
-        $this->deprecated(function () {
-            $request = new Request();
-            $result = $request->version('1.0');
-            $this->assertSame($request, $result, 'Should return self');
-
-            $this->assertSame('1.0', $request->version());
-        });
-    }
-
-    /**
-     * test version Interoperable.
-     *
-     * @group deprecated
-     * @return void
-     */
-    public function testVersionInteroperability()
-    {
-        $this->deprecated(function () {
-            $request = new Request();
-            $this->assertEquals('1.1', $request->version());
-            $this->assertEquals('1.1', $request->getProtocolVersion());
-
-            $request = $request->withProtocolVersion('1.0');
-            $this->assertEquals('1.0', $request->version());
-            $this->assertEquals('1.0', $request->getProtocolVersion());
-        });
-    }
 }

+ 0 - 98
tests/TestCase/Http/Client/ResponseTest.php

@@ -346,46 +346,6 @@ XML;
     }
 
     /**
-     * Test parsing / getting cookies.
-     *
-     * @group deprecated
-     * @return void
-     */
-    public function testCookie()
-    {
-        $this->deprecated(function () {
-            $headers = [
-                'HTTP/1.0 200 Ok',
-                'Set-Cookie: test=value',
-                'Set-Cookie: session=123abc',
-                'Set-Cookie: expiring=soon; Expires=Wed, 09-Jun-2021 10:18:14 GMT; Path=/; HttpOnly; Secure;',
-            ];
-            $response = new Response($headers, '');
-            $this->assertEquals('value', $response->cookie('test'));
-            $this->assertEquals('123abc', $response->cookie('session'));
-            $this->assertEquals('soon', $response->cookie('expiring'));
-
-            $result = $response->cookie('expiring', true);
-            $this->assertTrue($result['httponly']);
-            $this->assertTrue($result['secure']);
-            $this->assertEquals(
-                'Wed, 09-Jun-2021 10:18:14 GMT',
-                $result['expires']
-            );
-            $this->assertEquals('/', $result['path']);
-
-            $result = $response->header('set-cookie');
-            $this->assertCount(3, $result, 'Should be an array.');
-
-            $this->assertTrue(isset($response->cookies));
-            $this->assertEquals(
-                'soon',
-                $response->cookies['expiring']['value']
-            );
-        });
-    }
-
-    /**
      * Test accessing cookies through the PSR7-like methods
      *
      * @return void
@@ -463,26 +423,6 @@ XML;
     }
 
     /**
-     * Test statusCode()
-     *
-     * @group deprecated
-     * @return void
-     */
-    public function testStatusCode()
-    {
-        $this->deprecated(function () {
-            $headers = [
-                'HTTP/1.0 404 Not Found',
-                'Content-Type: text/html'
-            ];
-            $response = new Response($headers, '');
-            $this->assertSame(404, $response->statusCode());
-            $this->assertSame(404, $response->code);
-            $this->assertTrue(isset($response->code));
-        });
-    }
-
-    /**
      * Test reading the encoding out.
      *
      * @return void
@@ -518,44 +458,6 @@ XML;
     }
 
     /**
-     * Test reading the encoding out.
-     *
-     * @group deprecated
-     * @return void
-     */
-    public function testEncoding()
-    {
-        $this->deprecated(function () {
-            $headers = [
-                'HTTP/1.0 200 Ok',
-            ];
-            $response = new Response($headers, '');
-            $this->assertNull($response->encoding());
-
-            $headers = [
-                'HTTP/1.0 200 Ok',
-                'Content-Type: text/html'
-            ];
-            $response = new Response($headers, '');
-            $this->assertNull($response->encoding());
-
-            $headers = [
-                'HTTP/1.0 200 Ok',
-                'Content-Type: text/html; charset="UTF-8"'
-            ];
-            $response = new Response($headers, '');
-            $this->assertEquals('UTF-8', $response->encoding());
-
-            $headers = [
-                'HTTP/1.0 200 Ok',
-                "Content-Type: text/html; charset='ISO-8859-1'"
-            ];
-            $response = new Response($headers, '');
-            $this->assertEquals('ISO-8859-1', $response->encoding());
-        });
-    }
-
-    /**
      * Test that gzip responses are automatically decompressed.
      *
      * @return void