Skip to content

Commit 94fd8d7

Browse files
arkadiychOlexii Korshenko
authored andcommitted
MAGETWO-39392: Merge and Fix Builds
- fixes for tests
1 parent 9c9d648 commit 94fd8d7

File tree

5 files changed

+51
-55
lines changed

5 files changed

+51
-55
lines changed

app/code/Magento/CurrencySymbol/Model/Observer.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
* Copyright © 2015 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
7-
/**
8-
* Currency Symbol Observer
9-
*/
106
namespace Magento\CurrencySymbol\Model;
117

128
use Magento\Framework\Locale\Currency;
139

10+
/**
11+
* Currency Symbol Observer
12+
*/
1413
class Observer
1514
{
1615
/**
@@ -19,7 +18,7 @@ class Observer
1918
protected $symbolFactory;
2019

2120
/**
22-
* @param \Magento\CurrencySymbol\Model\System\CurrencysymbolFactory
21+
* @param \Magento\CurrencySymbol\Model\System\CurrencysymbolFactory $symbolFactory
2322
*/
2423
public function __construct(\Magento\CurrencySymbol\Model\System\CurrencysymbolFactory $symbolFactory)
2524
{

app/code/Magento/CurrencySymbol/Test/Unit/Model/ObserverTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@
33
* Copyright © 2015 Magento. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
namespace Magento\CurrencySymbol\Test\Unit\Model;
7+
8+
use \Magento\CurrencySymbol\Model\System\CurrencysymbolFactory;
69

710
/**
811
* Test for \Magento\CurrencySymbol\Model\Observer
912
*/
10-
class ObserverTest extends PHPUnit_Framework_TestCase
13+
class ObserverTest extends \PHPUnit_Framework_TestCase
1114
{
1215
/**
1316
* @var \Magento\CurrencySymbol\Model\Observer
1417
*/
1518
private $observer;
1619

1720
/**
18-
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\CurrencySymbol\Model\System\CurrencysymbolFactory $mockSymbolFactory
21+
* @var \PHPUnit_Framework_MockObject_MockObject|CurrencysymbolFactory $mockSymbolFactory
1922
*/
2023
private $mockSymbolFactory;
2124

@@ -71,7 +74,7 @@ public function setUp()
7174
$this->mockEventObserver->expects($this->any())->method('getEvent')->willReturn($this->mockEvent);
7275
$this->mockSymbolFactory->expects($this->any())->method('create')->willReturn($this->mockSymbol);
7376

74-
$this->observer = new Magento\CurrencySymbol\Model\Observer($this->mockSymbolFactory);
77+
$this->observer = new \Magento\CurrencySymbol\Model\Observer($this->mockSymbolFactory);
7578
}
7679

7780
public function testCurrencyDisplayOptionsEmpty()

app/code/Magento/CurrencySymbol/Test/Unit/Model/System/CurrencysymbolTest.php

Lines changed: 41 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,11 @@ class CurrencysymbolTest extends \PHPUnit_Framework_TestCase
3535
*/
3636
protected $systemStoreMock;
3737

38-
/**
39-
* @var \Magento\Store\Model\Website|\PHPUnit_Framework_MockObject_MockObject
40-
*/
41-
protected $websiteMock;
42-
43-
/**
44-
* @var \Magento\Store\Model\Group|\PHPUnit_Framework_MockObject_MockObject
45-
*/
46-
protected $groupMock;
47-
48-
/**
49-
* @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject
50-
*/
51-
protected $storeMock;
52-
5338
/**
5439
* @var \Magento\Config\Model\Config\Factory|\PHPUnit_Framework_MockObject_MockObject
5540
*/
5641
protected $configFactoryMock;
5742

58-
/**
59-
* @var \Magento\Config\Model\Config|\PHPUnit_Framework_MockObject_MockObject
60-
*/
61-
protected $configMock;
62-
6343
/**
6444
* @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
6545
*/
@@ -153,17 +133,6 @@ protected function setUp()
153133
'',
154134
false
155135
);
156-
$this->configMock = $this->getMock(
157-
'Magento\Config\Model\Config',
158-
['setSection', 'setWebsite', 'setStore', 'setGroups', 'save'],
159-
[],
160-
'',
161-
false
162-
);
163-
$this->websiteMock = $this->getMock('Magento\Store\Model\Website', ['getId', 'getConfig'], [], '', false);
164-
$this->groupMock = $this->getMock('Magento\Store\Model\Group', ['getId', 'getWebsiteId'], [], '', false);
165-
$this->storeMock = $this->getMock('Magento\Store\Model\Store', ['getGroupId'], [], '', false);
166-
167136

168137
$this->model = $this->objectManagerHelper->getObject(
169138
'Magento\CurrencySymbol\Model\System\Currencysymbol',
@@ -219,14 +188,25 @@ public function testSetCurrencySymbolData()
219188

220189
$this->prepareMocksForGetCurrencySymbolsData($websiteId, $groupId, $currencies);
221190

222-
$this->configFactoryMock->expects($this->any())->method('create')->willReturn($this->configMock);
223-
$this->configMock->expects($this->any())
191+
/**
192+
* @var \Magento\Config\Model\Config|\PHPUnit_Framework_MockObject_MockObject
193+
*/
194+
$configMock = $this->getMock(
195+
'Magento\Config\Model\Config',
196+
['setSection', 'setWebsite', 'setStore', 'setGroups', 'save'],
197+
[],
198+
'',
199+
false
200+
);
201+
202+
$this->configFactoryMock->expects($this->any())->method('create')->willReturn($configMock);
203+
$configMock->expects($this->any())
224204
->method('setSection')
225205
->with(Currencysymbol::CONFIG_SECTION)
226206
->willReturnSelf();
227-
$this->configMock->expects($this->any())->method('setWebsite')->with(null)->willReturnSelf();
228-
$this->configMock->expects($this->any())->method('setStore')->with(null)->willReturnSelf();
229-
$this->configMock->expects($this->any())->method('setGroups')->with($value)->willReturnSelf();
207+
$configMock->expects($this->any())->method('setWebsite')->with(null)->willReturnSelf();
208+
$configMock->expects($this->any())->method('setStore')->with(null)->willReturnSelf();
209+
$configMock->expects($this->any())->method('setGroups')->with($value)->willReturnSelf();
230210

231211
$this->coreConfigMock->expects($this->once())->method('reinit');
232212
$this->storeManagerMock->expects($this->once())->method('reinitStores');
@@ -292,15 +272,30 @@ public function getCurrencySymbolDataProvider()
292272
*/
293273
protected function prepareMocksForGetCurrencySymbolsData($websiteId, $groupId, $currencies)
294274
{
275+
/**
276+
* @var \Magento\Store\Model\Website|\PHPUnit_Framework_MockObject_MockObject
277+
*/
278+
$websiteMock = $this->getMock('Magento\Store\Model\Website', ['getId', 'getConfig'], [], '', false);
279+
280+
/**
281+
* @var \Magento\Store\Model\Group|\PHPUnit_Framework_MockObject_MockObject
282+
*/
283+
$groupMock = $this->getMock('Magento\Store\Model\Group', ['getId', 'getWebsiteId'], [], '', false);
284+
285+
/**
286+
* @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject
287+
*/
288+
$storeMock = $this->getMock('Magento\Store\Model\Store', ['getGroupId'], [], '', false);
289+
295290
$this->systemStoreMock->expects($this->once())
296291
->method('getWebsiteCollection')
297-
->willReturn([$this->websiteMock]);
298-
$this->systemStoreMock->expects($this->once())->method('getGroupCollection')->willReturn([$this->groupMock]);
299-
$this->systemStoreMock->expects($this->once())->method('getStoreCollection')->willReturn([$this->storeMock]);
300-
$this->websiteMock->expects($this->any())->method('getId')->willReturn($websiteId);
301-
$this->groupMock->expects($this->any())->method('getWebsiteId')->willReturn($websiteId);
302-
$this->groupMock->expects($this->any())->method('getId')->willReturn($groupId);
303-
$this->storeMock->expects($this->any())->method('getGroupId')->willReturn($groupId);
292+
->willReturn([$websiteMock]);
293+
$this->systemStoreMock->expects($this->once())->method('getGroupCollection')->willReturn([$groupMock]);
294+
$this->systemStoreMock->expects($this->once())->method('getStoreCollection')->willReturn([$storeMock]);
295+
$websiteMock->expects($this->any())->method('getId')->willReturn($websiteId);
296+
$groupMock->expects($this->any())->method('getWebsiteId')->willReturn($websiteId);
297+
$groupMock->expects($this->any())->method('getId')->willReturn($groupId);
298+
$storeMock->expects($this->any())->method('getGroupId')->willReturn($groupId);
304299

305300
$this->scopeConfigMock->expects($this->any())
306301
->method('getValue')
@@ -310,24 +305,23 @@ protected function prepareMocksForGetCurrencySymbolsData($websiteId, $groupId, $
310305
[
311306
CurrencySymbol::XML_PATH_ALLOWED_CURRENCIES,
312307
ScopeInterface::SCOPE_STORE,
313-
$this->storeMock,
308+
$storeMock,
314309
$currencies
315310
],
316311
[CurrencySymbol::XML_PATH_ALLOWED_CURRENCIES, ScopeInterface::SCOPE_STORE, null, $currencies],
317312
[
318313
CurrencySymbol::XML_PATH_ALLOWED_CURRENCIES,
319314
ScopeInterface::SCOPE_STORE,
320-
$this->storeMock,
315+
$storeMock,
321316
$currencies
322317
]
323318
]
324319
);
325320

326-
$this->websiteMock->expects($this->any())
321+
$websiteMock->expects($this->any())
327322
->method('getConfig')
328323
->with(CurrencySymbol::XML_PATH_ALLOWED_CURRENCIES)
329324
->willReturn($currencies);
330325
$this->localeResolverMock->expects($this->any())->method('getLocale')->willReturn('en');
331326
}
332-
333327
}

0 commit comments

Comments
 (0)