Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigValueHandlerTest.php
Go to the documentation of this file.
1 <?php
7 
10 
14 class ConfigValueHandlerTest extends \PHPUnit\Framework\TestCase
15 {
17  protected $model;
18 
22  protected $configMock;
23 
24  protected function setUp()
25  {
26  $this->configMock = $this->getMockBuilder(\Magento\Payment\Gateway\ConfigInterface::class)
27  ->getMockForAbstractClass();
28  $this->model = new ConfigValueHandler($this->configMock);
29  }
30 
31  public function testHandle()
32  {
33  $field = 'field';
34  $storeId = 1;
35  $expected = 'some value';
36 
37  $this->configMock->expects($this->once())
38  ->method('getValue')
39  ->with($field, $storeId)
40  ->willReturn($expected);
41 
42  $this->assertEquals($expected, $this->model->handle(['field' => $field], $storeId));
43  }
44 
45  public function testHandleWithoutStoreId()
46  {
47  $field = 'field';
48  $expected = 'some value';
49 
50  $this->configMock->expects($this->once())
51  ->method('getValue')
52  ->with($field, null)
53  ->willReturn($expected);
54 
55  $this->assertEquals($expected, $this->model->handle(['field' => $field]));
56  }
57 }