Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
PhpCookieManagerTest Class Reference
Inheritance diagram for PhpCookieManagerTest:

Public Member Functions

 testGetCookie ()
 
 testSetSensitiveCookie ()
 
 testSetPublicCookie ()
 
 testDeleteCookie ()
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $cookieManager
 

Detailed Description

Test PhpCookieManager

Definition at line 14 of file PhpCookieManagerTest.php.

Member Function Documentation

◆ setUp()

setUp ( )
protected

Definition at line 30 of file PhpCookieManagerTest.php.

31  {
32  $this->objectManager = Bootstrap::getObjectManager();
33  $this->cookieManager = $this->objectManager->create(\Magento\Framework\Stdlib\Cookie\PhpCookieManager::class);
34  }

◆ testDeleteCookie()

testDeleteCookie ( )

It is not possible to write integration tests for CookieManager::deleteCookie(). PHPUnit the following error when calling the function:

PHPUnit\Framework\Error_Warning : Cannot modify header information - headers already sent

Definition at line 79 of file PhpCookieManagerTest.php.

80  {
81  }

◆ testGetCookie()

testGetCookie ( )

Definition at line 36 of file PhpCookieManagerTest.php.

37  {
38  $preTestCookies = $_COOKIE;
39  $cookieName = 'cookie name';
40  $cookieValue = 'cookie value';
41  $defaultCookieValue = 'default';
42  $_COOKIE[$cookieName] = $cookieValue;
43  $this->assertEquals(
44  $defaultCookieValue,
45  $this->cookieManager->getCookie('unknown cookieName', $defaultCookieValue)
46  );
47  $this->assertEquals($cookieValue, $this->cookieManager->getCookie($cookieName, $defaultCookieValue));
48  $this->assertEquals($defaultCookieValue, $this->cookieManager->getCookie(null, $defaultCookieValue));
49  $this->assertNull($this->cookieManager->getCookie(null));
50  $_COOKIE = $preTestCookies;
51  }

◆ testSetPublicCookie()

testSetPublicCookie ( )

It is not possible to write integration tests for CookieManager::setSensitiveCookie(). PHPUnit the following error when calling the function:

PHPUnit\Framework\Error_Warning : Cannot modify header information - headers already sent

Definition at line 69 of file PhpCookieManagerTest.php.

70  {
71  }

◆ testSetSensitiveCookie()

testSetSensitiveCookie ( )

It is not possible to write integration tests for CookieManager::setSensitiveCookie(). PHPUnit the following error when calling the function:

PHPUnit\Framework\Error_Warning : Cannot modify header information - headers already sent

Definition at line 59 of file PhpCookieManagerTest.php.

60  {
61  }

Field Documentation

◆ $cookieManager

$cookieManager
protected

Definition at line 28 of file PhpCookieManagerTest.php.


The documentation for this class was generated from the following file: