Skip to content

Commit d391b29

Browse files
author
He, Joan(johe)
committed
Merge pull request #238 from magento-extensibility/develop
[Extensibility] Sprint 60 pull request
2 parents c334bf2 + d5b833a commit d391b29

File tree

14 files changed

+283
-28
lines changed

14 files changed

+283
-28
lines changed

app/code/Magento/AdminNotification/Test/Unit/Model/FeedTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,12 @@ protected function setUp()
8888

8989
$this->deploymentConfig = $this->getMockBuilder('Magento\Framework\App\DeploymentConfig')
9090
->disableOriginalConstructor()->getMock();
91+
9192
$this->objectManagerHelper = new ObjectManagerHelper($this);
9293

93-
$this->productMetadata = $this->getMock('Magento\Framework\App\ProductMetadata');
94+
$this->productMetadata = $this->getMockBuilder('Magento\Framework\App\ProductMetadata')
95+
->disableOriginalConstructor()->getMock();
96+
9497
$this->urlBuilder = $this->getMock('Magento\Framework\UrlInterface');
9598

9699
$this->feed = $this->objectManagerHelper->getObject(

app/code/Magento/Backend/Block/Dashboard/Graph.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,7 @@ public function getChartUrl($directUrl = true)
200200
$this->setAxisLabels($axis, $this->getRowsData($attr, true));
201201
}
202202

203-
$timezoneLocal = $this->_scopeConfig->getValue(
204-
$this->_localeDate->getDefaultTimezonePath(),
205-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
206-
);
203+
$timezoneLocal = $this->_localeDate->getConfigTimezone();
207204

208205
/** @var \DateTime $dateStart */
209206
/** @var \DateTime $dateEnd */
@@ -214,10 +211,14 @@ public function getChartUrl($directUrl = true)
214211
true
215212
);
216213

214+
$dateStart->setTimezone(new \DateTimeZone($timezoneLocal));
215+
$dateEnd->setTimezone(new \DateTimeZone($timezoneLocal));
216+
217217
if ($this->getDataHelper()->getParam('period') == '24h') {
218-
$dateStart->setTimezone(new \DateTimeZone($timezoneLocal));
219-
$dateEnd->setTimezone(new \DateTimeZone($timezoneLocal));
220218
$dateEnd->modify('-1 hour');
219+
} else {
220+
$dateEnd->setTime(23, 59, 59);
221+
$dateStart->setTime(0, 0, 0);
221222
}
222223

223224
$dates = [];

app/code/Magento/Backend/Block/Page/Footer.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,40 @@ class Footer extends \Magento\Backend\Block\Template
1717
*/
1818
protected $_template = 'page/footer.phtml';
1919

20+
/**
21+
* @var \Magento\Framework\App\ProductMetadataInterface
22+
*/
23+
protected $productMetadata;
24+
25+
/**
26+
* @param \Magento\Backend\Block\Template\Context $context
27+
* @param \Magento\Framework\App\ProductMetadataInterface $productMetadata
28+
* @param array $data
29+
*/
30+
public function __construct(
31+
\Magento\Backend\Block\Template\Context $context,
32+
\Magento\Framework\App\ProductMetadataInterface $productMetadata,
33+
array $data = []
34+
) {
35+
$this->productMetadata = $productMetadata;
36+
parent::__construct($context, $data);
37+
}
38+
2039
/**
2140
* @return void
2241
*/
2342
protected function _construct()
2443
{
2544
$this->setShowProfiler(true);
2645
}
46+
47+
/**
48+
* Get product version
49+
*
50+
* @return string
51+
*/
52+
public function getMagentoVersion()
53+
{
54+
return $this->productMetadata->getVersion();
55+
}
2756
}

app/code/Magento/Backend/view/adminhtml/templates/page/footer.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
?>
1010
<p class="magento-version">
1111
<strong><?php /* @escapeNotVerified */ echo __('Magento'); ?></strong>
12-
<?php /* @escapeNotVerified */ echo __('ver. %1', \Magento\Framework\AppInterface::VERSION) ?>
12+
<?php /* @escapeNotVerified */ echo __('ver. %1', $block->getMagentoVersion()) ?>
1313
</p>

bin/magento

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
* Copyright © 2015 Magento. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7+
use \Magento\Framework\App\ProductMetadata;
8+
use \Magento\Framework\Composer\ComposerJsonFinder;
9+
use Magento\Framework\App\Filesystem\DirectoryList;
710

8-
use Magento\Framework\AppInterface;
911
if (PHP_SAPI !== 'cli') {
1012
echo 'bin/magento must be run as a CLI application';
1113
exit(1);
@@ -20,8 +22,8 @@ try {
2022
try {
2123
$handler = new \Magento\Framework\App\ErrorHandler();
2224
set_error_handler([$handler, 'handler']);
23-
24-
$application = new Magento\Framework\Console\Cli('Magento CLI', AppInterface::VERSION);
25+
$productMetadata = new ProductMetadata(new ComposerJsonFinder(new DirectoryList(BP)));
26+
$application = new Magento\Framework\Console\Cli('Magento CLI', $productMetadata->getVersion());
2527
$application->run();
2628
} catch (\Exception $e) {
2729
while ($e) {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Backend\Block\Page;
7+
8+
/**
9+
* Test \Magento\Backend\Block\Page\Footer
10+
* @magentoAppArea adminhtml
11+
*/
12+
class FooterTest extends \PHPUnit_Framework_TestCase
13+
{
14+
/**
15+
* Test Product Version Value
16+
*/
17+
const TEST_PRODUCT_VERSION = '222.333.444';
18+
19+
/**
20+
* @var \Magento\Backend\Block\Page\Footer
21+
*/
22+
protected $block;
23+
24+
protected function setUp()
25+
{
26+
parent::setUp();
27+
$productMetadataMock = $this->getMockBuilder('Magento\Framework\App\ProductMetadata')
28+
->setMethods(['getVersion'])
29+
->disableOriginalConstructor()
30+
->getMock();
31+
$productMetadataMock->expects($this->once())
32+
->method('getVersion')
33+
->willReturn($this::TEST_PRODUCT_VERSION);
34+
$this->block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
35+
'Magento\Framework\View\LayoutInterface'
36+
)->createBlock(
37+
'Magento\Backend\Block\Page\Footer',
38+
'',
39+
['productMetadata' => $productMetadataMock]
40+
);
41+
}
42+
43+
public function testToHtml()
44+
{
45+
$footerContent = $this->block->toHtml();
46+
$this->assertContains('ver. ' . $this::TEST_PRODUCT_VERSION, $footerContent, 'No or wrong product version.');
47+
}
48+
}

lib/internal/Magento/Framework/App/ProductMetadata.php

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,56 @@
77
*/
88
namespace Magento\Framework\App;
99

10-
use Magento\Framework\AppInterface;
11-
1210
class ProductMetadata implements ProductMetadataInterface
1311
{
1412
const EDITION_NAME = 'Community';
1513
const PRODUCT_NAME = 'Magento';
1614

15+
/**
16+
* Product version
17+
*
18+
* @var string
19+
*/
20+
protected $version;
21+
22+
/**
23+
* @var \Magento\Framework\Composer\ComposerJsonFinder
24+
*/
25+
protected $composerJsonFinder;
26+
27+
/**
28+
* @param \Magento\Framework\Composer\ComposerJsonFinder $composerJsonFinder
29+
*/
30+
public function __construct(\Magento\Framework\Composer\ComposerJsonFinder $composerJsonFinder)
31+
{
32+
$this->composerJsonFinder = $composerJsonFinder;
33+
}
34+
1735
/**
1836
* Get Product version
1937
*
2038
* @return string
39+
* @throws \Exception
2140
*/
2241
public function getVersion()
2342
{
24-
return AppInterface::VERSION;
43+
if (!$this->version) {
44+
$composerJsonFile = $this->composerJsonFinder->findComposerJson();
45+
46+
$composerContent = file_get_contents($composerJsonFile);
47+
if ($composerContent === false) {
48+
throw new \Exception('Composer file content is empty');
49+
}
50+
$composerContent = json_decode($composerContent, true);
51+
if (!$composerContent
52+
|| !is_array($composerContent)
53+
|| !array_key_exists('version', $composerContent)
54+
) {
55+
throw new \Exception('Unable to decode Composer file');
56+
}
57+
$this->version = $composerContent['version'];
58+
}
59+
return $this->version;
2560
}
2661

2762
/**

lib/internal/Magento/Framework/App/Test/Unit/ProductMetadataTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,16 @@ class ProductMetadataTest extends \PHPUnit_Framework_TestCase
1616

1717
protected function setUp()
1818
{
19+
$composerJsonFinder = $this->getMockBuilder('Magento\Framework\Composer\ComposerJsonFinder')
20+
->disableOriginalConstructor()->setMethods(['findComposerJson'])->getMock();
21+
$composerJsonFinder->expects($this->any())->method('findComposerJson')
22+
->willReturn(realpath(__DIR__ . '/_files/test.composer.json'));
23+
1924
$objectManager = new ObjectManager($this);
20-
$this->productMetadata = $objectManager->getObject('Magento\Framework\App\ProductMetadata');
25+
$this->productMetadata = $objectManager->getObject(
26+
'Magento\Framework\App\ProductMetadata',
27+
['composerJsonFinder' => $composerJsonFinder]
28+
);
2129
}
2230

2331
public function testGetVersion()
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"name": "magento/magento2ce",
3+
"description": "Magento 2 (Test Edition)",
4+
"type": "project",
5+
"version": "222.333.444",
6+
"license": [
7+
"OSL-3.0",
8+
"AFL-3.0"
9+
],
10+
"repositories": [
11+
{
12+
"type": "composer",
13+
"url": "https://repo.magento.com/"
14+
}
15+
],
16+
"require": {
17+
"php": "~5.5.0|~5.6.0|~7.0.0",
18+
"ext-openssl": "*"
19+
},
20+
"require-dev": {
21+
"phpunit/phpunit": "4.1.0",
22+
"squizlabs/php_codesniffer": "1.5.3",
23+
"phpmd/phpmd": "@stable",
24+
"pdepend/pdepend": "2.0.6",
25+
"sjparkinson/static-review": "~4.1",
26+
"fabpot/php-cs-fixer": "~1.2",
27+
"lusitanian/oauth": "~0.3 <=0.7.0"
28+
},
29+
"replace": {
30+
"magento/module-marketplace": "100.0.2",
31+
"tinymce/tinymce": "3.4.7"
32+
},
33+
"extra": {
34+
"component_paths": {
35+
"trentrichardson/jquery-timepicker-addon": "lib/web/jquery/jquery-ui-timepicker-addon.js",
36+
"components/jquery": [
37+
"lib/web/jquery.js",
38+
"lib/web/jquery/jquery.min.js",
39+
"lib/web/jquery/jquery-migrate.js"
40+
],
41+
"blueimp/jquery-file-upload": "lib/web/jquery/fileUploader",
42+
"components/jqueryui": [
43+
"lib/web/jquery/jquery-ui.js"
44+
],
45+
"twbs/bootstrap": [
46+
"lib/web/jquery/jquery.tabs.js"
47+
],
48+
"tinymce/tinymce": "lib/web/tiny_mce"
49+
}
50+
},
51+
"config": {
52+
"use-include-path": true
53+
},
54+
"autoload": {
55+
"psr-4": {
56+
"Magento\\Framework\\": "lib/internal/Magento/Framework/",
57+
"Magento\\Setup\\": "setup/src/Magento/Setup/",
58+
"Magento\\": "app/code/Magento/"
59+
},
60+
"psr-0": {
61+
"": "app/code/"
62+
},
63+
"files": [
64+
"app/etc/NonComposerComponentRegistration.php"
65+
]
66+
},
67+
"autoload-dev": {
68+
"psr-4": {
69+
"Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/",
70+
"Magento\\Tools\\": "dev/tools/Magento/Tools/",
71+
"Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/",
72+
"Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
73+
"Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/"
74+
}
75+
},
76+
"minimum-stability": "alpha",
77+
"prefer-stable": true
78+
}

lib/internal/Magento/Framework/AppInterface.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ interface AppInterface
1414
*/
1515
const DISTRO_LOCALE_CODE = 'en_US';
1616

17-
/**
18-
* Magento version
19-
*/
20-
const VERSION = '2.0.0';
21-
2217
/**
2318
* Launch application
2419
*

0 commit comments

Comments
 (0)