ResponseCookiesTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  5. * Licensed under The MIT License
  6. * Redistributions of files must retain the above copyright notice.
  7. *
  8. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  9. * @link http://cakephp.org CakePHP(tm) Project
  10. * @since 3.5.0
  11. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  12. */
  13. namespace Cake\Test\TestCase\Http\Cookie;
  14. use Cake\Http\Client\Response;
  15. use Cake\Http\Cookie\Cookie;
  16. use Cake\Http\Cookie\ResponseCookies;
  17. use Cake\TestSuite\TestCase;
  18. /**
  19. * Response Cookies Test
  20. */
  21. class ResponseCookiesTest extends TestCase
  22. {
  23. /**
  24. * testAddToResponse
  25. *
  26. * @return void
  27. */
  28. public function testAddToResponse()
  29. {
  30. $cookies = [
  31. new Cookie('one', 'one'),
  32. new Cookie('two', 'two')
  33. ];
  34. $responseCookies = new ResponseCookies($cookies);
  35. $response = new Response();
  36. $response = $responseCookies->addToResponse($response);
  37. $expected = [
  38. 'Set-Cookie' => [
  39. 'one=one',
  40. 'two=two'
  41. ]
  42. ];
  43. $this->assertEquals($expected, $response->getHeaders());
  44. }
  45. }