SessionTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Authorizenet\Test\Unit\Model\Directpost;
  7. use Magento\Authorizenet\Model\Directpost\Session;
  8. use Magento\Framework\Session\StorageInterface;
  9. use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
  10. class SessionTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @var ObjectManager
  14. */
  15. protected $objectManager;
  16. /**
  17. * @var Session
  18. */
  19. protected $session;
  20. /**
  21. * @var StorageInterface|\PHPUnit_Framework_MockObject_MockObject
  22. */
  23. protected $storageMock;
  24. protected function setUp()
  25. {
  26. $this->storageMock = $this
  27. ->getMockBuilder(\Magento\Framework\Session\StorageInterface::class)
  28. ->setMethods(['setQuoteId'])
  29. ->getMockForAbstractClass();
  30. $this->objectManager = new ObjectManager($this);
  31. $this->session = $this->objectManager->getObject(
  32. \Magento\Authorizenet\Model\Directpost\Session::class,
  33. [
  34. 'storage' => $this->storageMock,
  35. ]
  36. );
  37. }
  38. public function testSetQuoteId()
  39. {
  40. $quoteId = 1;
  41. $this->storageMock->expects($this->once())
  42. ->method('setQuoteId')
  43. ->with($quoteId);
  44. $this->assertInstanceOf(
  45. \Magento\Authorizenet\Model\Directpost\Session::class,
  46. $this->session->setQuoteId($quoteId)
  47. );
  48. }
  49. }