SignifydOrderSessionIdTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Signifyd\Test\Unit\Model;
  7. use Magento\Checkout\Model\Session as CheckoutSession;
  8. use Magento\Framework\DataObject\IdentityGeneratorInterface;
  9. use Magento\Signifyd\Model\SignifydOrderSessionId;
  10. use PHPUnit_Framework_MockObject_MockObject as MockObject;
  11. /**
  12. * Class SignifydOrderSessionIdTest tests that SignifydOrderSessionId class dependencies
  13. * follow the contracts.
  14. */
  15. class SignifydOrderSessionIdTest extends \PHPUnit\Framework\TestCase
  16. {
  17. /**
  18. * @var SignifydOrderSessionId
  19. */
  20. private $signifydOrderSessionId;
  21. /**
  22. * @var IdentityGeneratorInterface|MockObject
  23. */
  24. private $identityGenerator;
  25. /**
  26. * Sets up testing class and dependency mocks.
  27. */
  28. protected function setUp()
  29. {
  30. $this->identityGenerator = $this->getMockBuilder(IdentityGeneratorInterface::class)
  31. ->getMockForAbstractClass();
  32. $this->signifydOrderSessionId = new SignifydOrderSessionId($this->identityGenerator);
  33. }
  34. /**
  35. * Tests method by passing quoteId parameter
  36. *
  37. * @covers \Magento\Signifyd\Model\SignifydOrderSessionId::get
  38. */
  39. public function testGetByQuoteId()
  40. {
  41. $quoteId = 1;
  42. $signifydOrderSessionId = 'asdfzxcv';
  43. $this->identityGenerator->expects(self::once())
  44. ->method('generateIdForData')
  45. ->with($quoteId)
  46. ->willReturn($signifydOrderSessionId);
  47. $this->assertEquals(
  48. $signifydOrderSessionId,
  49. $this->signifydOrderSessionId->get($quoteId)
  50. );
  51. }
  52. }