diff --git a/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php b/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php index de5503c144647..dff31a897e1ac 100644 --- a/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php +++ b/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php @@ -204,14 +204,14 @@ private function checkAbilityToSendCookie($name, $value) $sizeOfCookie = $this->sizeOfCookie($name, $value); - if ($numCookies > PhpCookieManager::MAX_NUM_COOKIES) { + if ($numCookies > static::MAX_NUM_COOKIES) { $this->logger->warning( new Phrase('Unable to send the cookie. Maximum number of cookies would be exceeded.'), array_merge($_COOKIE, ['user-agent' => $this->httpHeader->getHttpUserAgent()]) ); } - if ($sizeOfCookie > PhpCookieManager::MAX_COOKIE_SIZE) { + if ($sizeOfCookie > static::MAX_COOKIE_SIZE) { throw new CookieSizeLimitReachedException( new Phrase( 'Unable to send the cookie. Size of \'%name\' is %size bytes.', diff --git a/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PhpCookieManagerTest.php b/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PhpCookieManagerTest.php index 75b8eb2cec8d6..1ea942f5e9013 100644 --- a/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PhpCookieManagerTest.php +++ b/lib/internal/Magento/Framework/Stdlib/Test/Unit/Cookie/PhpCookieManagerTest.php @@ -47,8 +47,6 @@ class PhpCookieManagerTest extends \PHPUnit\Framework\TestCase const COOKIE_HTTP_ONLY = true; const COOKIE_NOT_HTTP_ONLY = false; const COOKIE_EXPIRE_END_OF_SESSION = 0; - const MAX_NUM_COOKIES = 50; - const MAX_COOKIE_SIZE = 4096; /** * Mapping from constant names to functions that handle the assertions. @@ -499,7 +497,9 @@ public function testSetCookieSizeTooLarge() ); $cookieValue = ''; - for ($i = 0; $i < self::MAX_COOKIE_SIZE + 1; $i++) { + + $cookieManager = $this->cookieManager; + for ($i = 0; $i < $cookieManager::MAX_COOKIE_SIZE + 1; $i++) { $cookieValue = $cookieValue . 'a'; } @@ -527,8 +527,9 @@ public function testSetTooManyCookies() $userAgent = 'some_user_agent'; - // Set self::MAX_NUM_COOKIES number of cookies in superglobal $_COOKIE. - for ($i = count($_COOKIE); $i < self::MAX_NUM_COOKIES; $i++) { + $cookieManager = $this->cookieManager; + // Set $cookieManager::MAX_NUM_COOKIES number of cookies in superglobal $_COOKIE. + for ($i = count($_COOKIE); $i < $cookieManager::MAX_NUM_COOKIES; $i++) { $_COOKIE['test_cookie_' . $i] = self::COOKIE_VALUE . '_' . $i; }