EncodedContextTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Analytics\Test\Unit\Model;
  7. use Magento\Analytics\Model\EncodedContext;
  8. use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
  9. class EncodedContextTest extends \PHPUnit\Framework\TestCase
  10. {
  11. /**
  12. * @var ObjectManagerHelper
  13. */
  14. private $objectManagerHelper;
  15. /**
  16. * @return void
  17. */
  18. protected function setUp()
  19. {
  20. $this->objectManagerHelper = new ObjectManagerHelper($this);
  21. }
  22. /**
  23. * @param string $content
  24. * @param string|null $initializationVector
  25. * @return void
  26. * @dataProvider constructDataProvider
  27. */
  28. public function testConstruct($content, $initializationVector)
  29. {
  30. $constructorArguments = [
  31. 'content' => $content,
  32. 'initializationVector' => $initializationVector,
  33. ];
  34. /** @var EncodedContext $encodedContext */
  35. $encodedContext = $this->objectManagerHelper->getObject(
  36. EncodedContext::class,
  37. array_filter($constructorArguments)
  38. );
  39. $this->assertSame($content, $encodedContext->getContent());
  40. $this->assertSame($initializationVector ?: '', $encodedContext->getInitializationVector());
  41. }
  42. /**
  43. * @return array
  44. */
  45. public function constructDataProvider()
  46. {
  47. return [
  48. 'Without Initialization Vector' => ['content text', null],
  49. 'With Initialization Vector' => ['content text', 'c51sd3c4sd68c5sd'],
  50. ];
  51. }
  52. }