Skip to content

Commit 325b7b4

Browse files
author
He, Joan(johe)
committed
Merge pull request #129 from magento-extensibility/MAGETWO-28383-merge
[Extensibility] Sprint 47 CE
2 parents 20314b9 + d8f1bb0 commit 325b7b4

File tree

4,570 files changed

+218853
-217870
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,570 files changed

+218853
-217870
lines changed

dev/tests/unit/testsuite/Magento/AdminNotification/Block/ToolbarEntryTest.php renamed to app/code/Magento/AdminNotification/Test/Unit/Block/ToolbarEntryTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/**
1010
* Test class for \Magento\AdminNotification\Block\ToolbarEntry
1111
*/
12-
namespace Magento\AdminNotification\Block;
12+
namespace Magento\AdminNotification\Test\Unit\Block;
1313

1414
class ToolbarEntryTest extends \PHPUnit_Framework_TestCase
1515
{
@@ -21,7 +21,7 @@ class ToolbarEntryTest extends \PHPUnit_Framework_TestCase
2121
*/
2222
protected function _getBlockInstance($unreadNotifications)
2323
{
24-
$objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this);
24+
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
2525
// mock collection of unread notifications
2626
$notificationList = $this->getMock(
2727
'Magento\AdminNotification\Model\Resource\Inbox\Collection\Unread',
@@ -49,7 +49,7 @@ public function testGetUnreadNotificationCount()
4949

5050
public function testGetLatestUnreadNotifications()
5151
{
52-
$helper = new \Magento\TestFramework\Helper\ObjectManager($this);
52+
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
5353

5454
// 1. Create mocks
5555
$notificationList = $this->getMockBuilder('Magento\AdminNotification\Model\Resource\Inbox\Collection\Unread')

dev/tests/unit/testsuite/Magento/AdminNotification/Model/FeedTest.php renamed to app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\AdminNotification\Model;
7+
namespace Magento\AdminNotification\Test\Unit\Model;
88

9-
use Magento\TestFramework\Helper\ObjectManager as ObjectManagerHelper;
9+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
1010

1111
/**
1212
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)

dev/tests/unit/testsuite/Magento/AdminNotification/Model/NotificationServiceTest.php renamed to app/code/Magento/AdminNotification/Test/Unit/Model/NotificationServiceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* Test class for \Magento\AdminNotification\Model\NotificationService
99
*/
10-
namespace Magento\AdminNotification\Model;
10+
namespace Magento\AdminNotification\Test\Unit\Model;
1111

1212
class NotificationServiceTest extends \PHPUnit_Framework_TestCase
1313
{
Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\AdminNotification\Test\Unit\Model\System\Message;
7+
8+
use Magento\Store\Model\Store;
9+
10+
class BaseurlTest extends \PHPUnit_Framework_TestCase
11+
{
12+
/**
13+
* @var \Magento\AdminNotification\Model\System\Message\Baseurl
14+
*/
15+
protected $_model;
16+
17+
/**
18+
* @var \PHPUnit_Framework_MockObject_MockObject
19+
*/
20+
protected $_configMock;
21+
22+
/**
23+
* @var \PHPUnit_Framework_MockObject_MockObject
24+
*/
25+
protected $_urlBuilderMock;
26+
27+
/**
28+
* @var \PHPUnit_Framework_MockObject_MockObject
29+
*/
30+
protected $_dataCollectionMock;
31+
32+
/**
33+
* @var \PHPUnit_Framework_MockObject_MockObject
34+
*/
35+
protected $_configDataMock;
36+
37+
/**
38+
* @var \PHPUnit_Framework_MockObject_MockObject
39+
*/
40+
protected $_iteratorMock;
41+
42+
/**
43+
* @var \PHPUnit_Framework_MockObject_MockObject
44+
*/
45+
protected $_storeManagerMock;
46+
47+
protected function setUp()
48+
{
49+
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
50+
$this->_configMock = $this->getMock('Magento\Framework\App\Config', [], [], '', false);
51+
$this->_urlBuilderMock = $this->getMock('Magento\Framework\UrlInterface');
52+
53+
$this->_storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface');
54+
$configFactoryMock = $this->getMock(
55+
'Magento\Framework\App\Config\ValueFactory',
56+
['create'],
57+
[],
58+
'',
59+
false
60+
);
61+
$this->_configDataMock = $this->getMock(
62+
'Magento\Framework\App\Config\Value',
63+
['getScope', 'getScopeId', 'getCollection', '__sleep', '__wakeup'],
64+
[],
65+
'',
66+
false
67+
);
68+
$this->_dataCollectionMock = $this->getMock(
69+
'Magento\Config\Model\Resource\Config\Data\Collection',
70+
[],
71+
[],
72+
'',
73+
false
74+
);
75+
76+
$this->_iteratorMock = $this->getMock('Iterator');
77+
$this->_dataCollectionMock->expects(
78+
$this->any()
79+
)->method(
80+
'getIterator'
81+
)->will(
82+
$this->returnValue($this->_iteratorMock)
83+
);
84+
85+
$configFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->_configDataMock));
86+
$this->_configDataMock->expects(
87+
$this->any()
88+
)->method(
89+
'getCollection'
90+
)->will(
91+
$this->returnValue($this->_dataCollectionMock)
92+
);
93+
94+
$arguments = [
95+
'config' => $this->_configMock,
96+
'urlBuilder' => $this->_urlBuilderMock,
97+
'configValueFactory' => $configFactoryMock,
98+
'storeManager' => $this->_storeManagerMock,
99+
];
100+
$this->_model = $helper->getObject('Magento\AdminNotification\Model\System\Message\Baseurl', $arguments);
101+
}
102+
103+
public function testGetSeverity()
104+
{
105+
$this->assertEquals(
106+
\Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL,
107+
$this->_model->getSeverity(),
108+
'Invalid message severity type'
109+
);
110+
}
111+
112+
public function testgetValueUrlWithDefaultUnsecureAndSecureBaseUrl()
113+
{
114+
$map = [
115+
[
116+
Store::XML_PATH_UNSECURE_BASE_URL,
117+
'default',
118+
null,
119+
\Magento\Store\Model\Store::BASE_URL_PLACEHOLDER,
120+
],
121+
[
122+
Store::XML_PATH_SECURE_BASE_URL,
123+
'default',
124+
null,
125+
\Magento\Store\Model\Store::BASE_URL_PLACEHOLDER
126+
],
127+
];
128+
$this->_configMock->expects($this->exactly(2))->method('getValue')->will($this->returnValueMap($map));
129+
$this->_urlBuilderMock->expects(
130+
$this->once()
131+
)->method(
132+
'getUrl'
133+
)->with(
134+
'adminhtml/system_config/edit',
135+
['section' => 'web']
136+
)->will(
137+
$this->returnValue('http://some_url')
138+
);
139+
140+
$this->assertContains('http://some_url', (string)$this->_model->getText());
141+
}
142+
143+
public function testgetValueUrlWithoutSavedData()
144+
{
145+
$this->_configMock->expects($this->any())->method('getNode')->will($this->returnValue(null));
146+
$this->_urlBuilderMock->expects($this->never())->method('getUrl');
147+
}
148+
149+
/**
150+
* @dataProvider getValueUrlWithSavedDataForStoreScopeDataProvider
151+
*/
152+
public function testgetValueUrlWithSavedDataForScopes($scope, $urlParam, $storeMethod)
153+
{
154+
$this->_configMock->expects($this->any())->method('getNode')->will($this->returnValue(null));
155+
$this->_iteratorMock->expects($this->once())->method('valid')->will($this->returnValue(true));
156+
$this->_iteratorMock->expects(
157+
$this->once()
158+
)->method(
159+
'current'
160+
)->will(
161+
$this->returnValue($this->_configDataMock)
162+
);
163+
164+
$this->_configDataMock->expects($this->once())->method('getScopeId')->will($this->returnValue(1));
165+
166+
$storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false);
167+
$this->_storeManagerMock->expects(
168+
$this->once()
169+
)->method(
170+
$storeMethod
171+
)->with(
172+
1
173+
)->will(
174+
$this->returnValue($storeMock)
175+
);
176+
$storeMock->expects($this->once())->method('getCode')->will($this->returnValue('some_code'));
177+
178+
$this->_configDataMock->expects($this->any())->method('getScope')->will($this->returnValue($scope));
179+
$this->_urlBuilderMock->expects(
180+
$this->once()
181+
)->method(
182+
'getUrl'
183+
)->with(
184+
'adminhtml/system_config/edit',
185+
['section' => 'web', $urlParam => 'some_code']
186+
)->will(
187+
$this->returnValue('http://some_url')
188+
);
189+
190+
$this->assertContains('http://some_url', (string)$this->_model->getText());
191+
}
192+
193+
public function getValueUrlWithSavedDataForStoreScopeDataProvider()
194+
{
195+
return [
196+
'storeScope' => ['stores', 'store', 'getStore'],
197+
'websiteScope' => ['websites', 'website', 'getWebsite']
198+
];
199+
}
200+
201+
public function testIsDisplayedWithEmptyConfigUrl()
202+
{
203+
$this->_configMock->expects(
204+
$this->any()
205+
)->method(
206+
'getValue'
207+
)->will(
208+
$this->returnValue(\Magento\Store\Model\Store::BASE_URL_PLACEHOLDER)
209+
);
210+
$this->_urlBuilderMock->expects($this->once())->method('getUrl')->will($this->returnValue(''));
211+
$this->assertFalse($this->_model->isDisplayed());
212+
}
213+
214+
public function testIsDisplayedWithNotEmptyConfigUrl()
215+
{
216+
$this->_configMock->expects(
217+
$this->any()
218+
)->method(
219+
'getValue'
220+
)->will(
221+
$this->returnValue(\Magento\Store\Model\Store::BASE_URL_PLACEHOLDER)
222+
);
223+
$this->_urlBuilderMock->expects($this->once())->method('getUrl')->will($this->returnValue('http://some_url'));
224+
$this->assertTrue($this->_model->isDisplayed());
225+
}
226+
227+
public function testGetIdentity()
228+
{
229+
$this->_configMock->expects(
230+
$this->any()
231+
)->method(
232+
'getValue'
233+
)->will(
234+
$this->returnValue(\Magento\Store\Model\Store::BASE_URL_PLACEHOLDER)
235+
);
236+
$this->_urlBuilderMock->expects($this->once())->method('getUrl')->will($this->returnValue('some_url'));
237+
$this->assertEquals(md5('BASE_URLsome_url'), $this->_model->getIdentity());
238+
}
239+
240+
public function testGetText()
241+
{
242+
$expected = '{{base_url}} is not recommended to use in a production environment';
243+
$this->assertContains($expected, (string)$this->_model->getText());
244+
}
245+
}

dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/CacheOutdatedTest.php renamed to app/code/Magento/AdminNotification/Test/Unit/Model/System/Message/CacheOutdatedTest.php

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

88
class CacheOutdatedTest extends \PHPUnit_Framework_TestCase
99
{
@@ -33,7 +33,7 @@ protected function setUp()
3333
$this->_urlInterfaceMock = $this->getMock('Magento\Framework\UrlInterface');
3434
$this->_cacheTypeListMock = $this->getMock('Magento\Framework\App\Cache\TypeListInterface');
3535

36-
$objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this);
36+
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
3737
$arguments = [
3838
'authorization' => $this->_authorizationMock,
3939
'urlBuilder' => $this->_urlInterfaceMock,

0 commit comments

Comments
 (0)