Skip to content

Commit 127b7ab

Browse files
author
Maksym Savich
committed
MAGETWO-31354: Magento Version Tag shows in RSS Feed
- Unit test has been modified to test the new functionality
1 parent 962d59e commit 127b7ab

File tree

1 file changed

+34
-4
lines changed
  • dev/tests/unit/testsuite/Magento/AdminNotification/Model

1 file changed

+34
-4
lines changed

dev/tests/unit/testsuite/Magento/AdminNotification/Model/FeedTest.php

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,18 @@ class FeedTest extends \PHPUnit_Framework_TestCase
4040
/** @var \Magento\Framework\App\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject */
4141
protected $deploymentConfig;
4242

43+
/** @var \Magento\Framework\App\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject */
44+
protected $productMetadata;
45+
46+
/** @var \Magento\Framework\App\DeploymentConfig|\PHPUnit_Framework_MockObject_MockObject */
47+
protected $urlBuilder;
48+
4349
protected function setUp()
4450
{
4551
$this->inboxFactory = $this->getMock('Magento\AdminNotification\Model\InboxFactory', ['create'], [], '', false);
4652
$this->curlFactory = $this->getMock('\Magento\Framework\HTTP\Adapter\CurlFactory', ['create'], [], '', false);
47-
$this->curl = $this->getMock('\Magento\Framework\HTTP\Adapter\Curl', ['read']);
53+
$this->curl = $this->getMockBuilder('\Magento\Framework\HTTP\Adapter\Curl')
54+
->disableOriginalConstructor()->getMock();
4855
$this->appState = $this->getMock('\Magento\Framework\App\State', ['getInstallDate'], [], '', false);
4956
$this->inboxModel = $this->getMock(
5057
'\Magento\AdminNotification\Model\Inbox',
@@ -78,6 +85,10 @@ protected function setUp()
7885
$this->deploymentConfig = $this->getMockBuilder('\Magento\Framework\App\DeploymentConfig')
7986
->disableOriginalConstructor()->getMock();
8087
$this->objectManagerHelper = new ObjectManagerHelper($this);
88+
89+
$this->productMetadata = $this->getMock('Magento\Framework\App\ProductMetadata');
90+
$this->urlBuilder = $this->getMock('Magento\Framework\Url', [], [], '', false);
91+
8192
$this->feed = $this->objectManagerHelper->getObject(
8293
'Magento\AdminNotification\Model\Feed',
8394
[
@@ -87,6 +98,8 @@ protected function setUp()
8798
'appState' => $this->appState,
8899
'curlFactory' => $this->curlFactory,
89100
'deploymentConfig' => $this->deploymentConfig,
101+
'productMetadata' => $this->productMetadata,
102+
'urlBuilder' => $this->urlBuilder
90103
]
91104
);
92105
}
@@ -98,14 +111,31 @@ protected function setUp()
98111
*/
99112
public function testCheckUpdate($callInbox, $curlRequest)
100113
{
101-
$lastUpdate = 1410121748;
114+
$mockName = 'Test Product Name';
115+
$mockVersion = '0.42.0-beta7';
116+
$mockEdition = 'Test Edition';
117+
$mockUrl = 'http://test-url';
118+
119+
$this->productMetadata->expects($this->once())->method('getName')->willReturn($mockName);
120+
$this->productMetadata->expects($this->once())->method('getVersion')->willReturn($mockVersion);
121+
$this->productMetadata->expects($this->once())->method('getEdition')->willReturn($mockEdition);
122+
$this->urlBuilder->expects($this->once())->method('getUrl')->with('*/*/*')->willReturn($mockUrl);
123+
124+
$configValues = [
125+
'timeout' => 2,
126+
'useragent' => $mockName . '/' . $mockVersion . ' (' . $mockEdition . ')',
127+
'referer' => $mockUrl
128+
];
129+
130+
$lastUpdate = 0;
131+
$this->cacheManager->expects($this->once())->method('load')->will(($this->returnValue($lastUpdate)));
102132
$this->curlFactory->expects($this->at(0))->method('create')->will($this->returnValue($this->curl));
103-
$this->curl->expects($this->any())->method('read')->will($this->returnValue($curlRequest));
133+
$this->curl->expects($this->once())->method('setConfig')->with($configValues)->willReturnSelf();
134+
$this->curl->expects($this->once())->method('read')->will($this->returnValue($curlRequest));
104135
$this->backendConfig->expects($this->at(0))->method('getValue')->will($this->returnValue('1'));
105136
$this->backendConfig->expects($this->once())->method('isSetFlag')->will($this->returnValue(false));
106137
$this->backendConfig->expects($this->at(1))->method('getValue')
107138
->will($this->returnValue('http://feed.magento.com'));
108-
$this->cacheManager->expects($this->once())->method('load')->will(($this->returnValue($lastUpdate)));
109139
$this->deploymentConfig->expects($this->once())->method('get')
110140
->with('install/date')->will($this->returnValue('Sat, 6 Sep 2014 16:46:11 UTC'));
111141
if ($callInbox) {

0 commit comments

Comments
 (0)