PublicCookieMetadataTest.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Stdlib\Test\Unit\Cookie;
  7. use Magento\Framework\Stdlib\Cookie\PublicCookieMetadata;
  8. use Magento\Framework\Stdlib\StringUtils;
  9. use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
  10. /**
  11. * Test PublicCookieMetadata
  12. *
  13. */
  14. class PublicCookieMetadataTest extends \PHPUnit\Framework\TestCase
  15. {
  16. /** @var PublicCookieMetadata */
  17. private $publicCookieMetadata;
  18. protected function setUp()
  19. {
  20. $objectManager = new ObjectManager($this);
  21. $this->publicCookieMetadata = $objectManager->getObject(
  22. \Magento\Framework\Stdlib\Cookie\PublicCookieMetadata::class
  23. );
  24. }
  25. /**
  26. * @param StringUtils $setMethodName
  27. * @param StringUtils $getMethodName
  28. * @param StringUtils $expectedValue
  29. * @dataProvider getMethodData
  30. */
  31. public function testGetters($setMethodName, $getMethodName, $expectedValue)
  32. {
  33. $this->publicCookieMetadata->$setMethodName($expectedValue);
  34. $this->assertSame($expectedValue, $this->publicCookieMetadata->$getMethodName());
  35. }
  36. /**
  37. * @return array
  38. */
  39. public function getMethodData()
  40. {
  41. return [
  42. "getDomain" => ["setDomain", 'getDomain', "example.com"],
  43. "getPath" => ["setPath", 'getPath', "path"],
  44. "getDuration" => ["setDuration", 'getDuration', 125],
  45. "getHttpOnly" => ["setHttpOnly", 'getHttpOnly', true],
  46. "getSecure" => ["setSecure", 'getSecure', true],
  47. "getDurationOneYear" => ["setDurationOneYear", 'getDuration', (3600*24*365)],
  48. ];
  49. }
  50. }