ConfigValueHandlerTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Payment\Test\Unit\Gateway\Config;
  7. use Magento\Payment\Gateway\ConfigInterface;
  8. use Magento\Payment\Gateway\Config\ConfigValueHandler;
  9. /**
  10. * Class ConfigValueHandlerTest
  11. */
  12. class ConfigValueHandlerTest extends \PHPUnit\Framework\TestCase
  13. {
  14. /** @var ConfigValueHandler */
  15. protected $model;
  16. /**
  17. * @var ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
  18. */
  19. protected $configMock;
  20. protected function setUp()
  21. {
  22. $this->configMock = $this->getMockBuilder(\Magento\Payment\Gateway\ConfigInterface::class)
  23. ->getMockForAbstractClass();
  24. $this->model = new ConfigValueHandler($this->configMock);
  25. }
  26. public function testHandle()
  27. {
  28. $field = 'field';
  29. $storeId = 1;
  30. $expected = 'some value';
  31. $this->configMock->expects($this->once())
  32. ->method('getValue')
  33. ->with($field, $storeId)
  34. ->willReturn($expected);
  35. $this->assertEquals($expected, $this->model->handle(['field' => $field], $storeId));
  36. }
  37. public function testHandleWithoutStoreId()
  38. {
  39. $field = 'field';
  40. $expected = 'some value';
  41. $this->configMock->expects($this->once())
  42. ->method('getValue')
  43. ->with($field, null)
  44. ->willReturn($expected);
  45. $this->assertEquals($expected, $this->model->handle(['field' => $field]));
  46. }
  47. }