Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractGridTest.php
Go to the documentation of this file.
1 <?php
8 
10 
14 class AbstractGridTest extends \PHPUnit\Framework\TestCase
15 {
19  private $model;
20 
24  private $storeManagerMock;
25 
26  protected function setUp()
27  {
28  $objectManager = new ObjectManager($this);
29 
30  $this->storeManagerMock = $this->getMockForAbstractClass(
31  \Magento\Store\Model\StoreManagerInterface::class,
32  [],
33  '',
34  true,
35  true,
36  true,
37  ['getStore']
38  );
39 
40  $this->model = $objectManager->getObject(
41  \Magento\Reports\Block\Adminhtml\Grid\AbstractGrid::class,
42  ['_storeManager' => $this->storeManagerMock]
43  );
44  }
45 
51  public function testGetCurrentCurrencyCode($storeIds)
52  {
53  $storeMock = $this->getMockForAbstractClass(
54  \Magento\Store\Api\Data\StoreInterface::class,
55  [],
56  '',
57  true,
58  true,
59  true,
60  ['getBaseCurrencyCode', 'getCurrentCurrencyCode']
61  );
62 
63  $this->storeManagerMock->expects($this->once())->method('getStore')->willReturn($storeMock);
64 
65  $this->model->setStoreIds($storeIds);
66 
67  if ($storeIds) {
68  $storeMock->expects($this->once())->method('getCurrentCurrencyCode')->willReturn('EUR');
69  $expectedCurrencyCode = 'EUR';
70  } else {
71  $storeMock->expects($this->once())->method('getBaseCurrencyCode')->willReturn('USD');
72  $expectedCurrencyCode = 'USD';
73  }
74 
75  $currencyCode = $this->model->getCurrentCurrencyCode();
76  $this->assertEquals($expectedCurrencyCode, $currencyCode);
77  }
78 
85  {
86  return [
87  [[]],
88  [[2]],
89  ];
90  }
91 }
$objectManager
Definition: bootstrap.php:17