FormTest.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\AuthorizenetAcceptjs\Test\Unit\Block;
  8. use Magento\AuthorizenetAcceptjs\Block\Form;
  9. use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
  10. use PHPUnit\Framework\MockObject\MockObject;
  11. use PHPUnit\Framework\TestCase;
  12. use Magento\AuthorizenetAcceptjs\Gateway\Config;
  13. use Magento\Backend\Model\Session\Quote;
  14. use Magento\Framework\View\Element\Template\Context;
  15. use Magento\Payment\Model\Config as PaymentConfig;
  16. class FormTest extends TestCase
  17. {
  18. /**
  19. * @var Form
  20. */
  21. private $block;
  22. /**
  23. * @var Config|MockObject|InvocationMocker
  24. */
  25. private $configMock;
  26. protected function setUp()
  27. {
  28. $contextMock = $this->createMock(Context::class);
  29. $this->configMock = $this->createMock(Config::class);
  30. $quoteMock = $this->getMockBuilder(Quote::class)
  31. ->disableOriginalConstructor()
  32. ->setMethods(['getStoreId'])
  33. ->getMock();
  34. $quoteMock->method('getStoreId')
  35. ->willReturn('123');
  36. $paymentConfig = $this->createMock(PaymentConfig::class);
  37. $this->block = new Form(
  38. $contextMock,
  39. $paymentConfig,
  40. $this->configMock,
  41. $quoteMock
  42. );
  43. }
  44. public function testIsCvvEnabled()
  45. {
  46. $this->configMock->method('isCvvEnabled')
  47. ->with('123')
  48. ->willReturn(true);
  49. $this->assertTrue($this->block->isCvvEnabled());
  50. }
  51. }