Skip to content

Commit

Permalink
Merge pull request #238 from magento-extensibility/develop
Browse files Browse the repository at this point in the history
[Extensibility] Sprint 60 pull request
  • Loading branch information
He, Joan(johe) committed Dec 9, 2015
2 parents c334bf2 + d5b833a commit d391b29
Show file tree
Hide file tree
Showing 14 changed files with 283 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,12 @@ protected function setUp()

$this->deploymentConfig = $this->getMockBuilder('Magento\Framework\App\DeploymentConfig')
->disableOriginalConstructor()->getMock();

$this->objectManagerHelper = new ObjectManagerHelper($this);

$this->productMetadata = $this->getMock('Magento\Framework\App\ProductMetadata');
$this->productMetadata = $this->getMockBuilder('Magento\Framework\App\ProductMetadata')
->disableOriginalConstructor()->getMock();

$this->urlBuilder = $this->getMock('Magento\Framework\UrlInterface');

$this->feed = $this->objectManagerHelper->getObject(
Expand Down
13 changes: 7 additions & 6 deletions app/code/Magento/Backend/Block/Dashboard/Graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,7 @@ public function getChartUrl($directUrl = true)
$this->setAxisLabels($axis, $this->getRowsData($attr, true));
}

$timezoneLocal = $this->_scopeConfig->getValue(
$this->_localeDate->getDefaultTimezonePath(),
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
$timezoneLocal = $this->_localeDate->getConfigTimezone();

/** @var \DateTime $dateStart */
/** @var \DateTime $dateEnd */
Expand All @@ -214,10 +211,14 @@ public function getChartUrl($directUrl = true)
true
);

$dateStart->setTimezone(new \DateTimeZone($timezoneLocal));
$dateEnd->setTimezone(new \DateTimeZone($timezoneLocal));

if ($this->getDataHelper()->getParam('period') == '24h') {
$dateStart->setTimezone(new \DateTimeZone($timezoneLocal));
$dateEnd->setTimezone(new \DateTimeZone($timezoneLocal));
$dateEnd->modify('-1 hour');
} else {
$dateEnd->setTime(23, 59, 59);
$dateStart->setTime(0, 0, 0);
}

$dates = [];
Expand Down
29 changes: 29 additions & 0 deletions app/code/Magento/Backend/Block/Page/Footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,40 @@ class Footer extends \Magento\Backend\Block\Template
*/
protected $_template = 'page/footer.phtml';

/**
* @var \Magento\Framework\App\ProductMetadataInterface
*/
protected $productMetadata;

/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Framework\App\ProductMetadataInterface $productMetadata
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\App\ProductMetadataInterface $productMetadata,
array $data = []
) {
$this->productMetadata = $productMetadata;
parent::__construct($context, $data);
}

/**
* @return void
*/
protected function _construct()
{
$this->setShowProfiler(true);
}

/**
* Get product version
*
* @return string
*/
public function getMagentoVersion()
{
return $this->productMetadata->getVersion();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
?>
<p class="magento-version">
<strong><?php /* @escapeNotVerified */ echo __('Magento'); ?></strong>
<?php /* @escapeNotVerified */ echo __('ver. %1', \Magento\Framework\AppInterface::VERSION) ?>
<?php /* @escapeNotVerified */ echo __('ver. %1', $block->getMagentoVersion()) ?>
</p>
8 changes: 5 additions & 3 deletions bin/magento
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
use \Magento\Framework\App\ProductMetadata;
use \Magento\Framework\Composer\ComposerJsonFinder;
use Magento\Framework\App\Filesystem\DirectoryList;

use Magento\Framework\AppInterface;
if (PHP_SAPI !== 'cli') {
echo 'bin/magento must be run as a CLI application';
exit(1);
Expand All @@ -20,8 +22,8 @@ try {
try {
$handler = new \Magento\Framework\App\ErrorHandler();
set_error_handler([$handler, 'handler']);

$application = new Magento\Framework\Console\Cli('Magento CLI', AppInterface::VERSION);
$productMetadata = new ProductMetadata(new ComposerJsonFinder(new DirectoryList(BP)));
$application = new Magento\Framework\Console\Cli('Magento CLI', $productMetadata->getVersion());
$application->run();
} catch (\Exception $e) {
while ($e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\Page;

/**
* Test \Magento\Backend\Block\Page\Footer
* @magentoAppArea adminhtml
*/
class FooterTest extends \PHPUnit_Framework_TestCase
{
/**
* Test Product Version Value
*/
const TEST_PRODUCT_VERSION = '222.333.444';

/**
* @var \Magento\Backend\Block\Page\Footer
*/
protected $block;

protected function setUp()
{
parent::setUp();
$productMetadataMock = $this->getMockBuilder('Magento\Framework\App\ProductMetadata')
->setMethods(['getVersion'])
->disableOriginalConstructor()
->getMock();
$productMetadataMock->expects($this->once())
->method('getVersion')
->willReturn($this::TEST_PRODUCT_VERSION);
$this->block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
'Magento\Framework\View\LayoutInterface'
)->createBlock(
'Magento\Backend\Block\Page\Footer',
'',
['productMetadata' => $productMetadataMock]
);
}

public function testToHtml()
{
$footerContent = $this->block->toHtml();
$this->assertContains('ver. ' . $this::TEST_PRODUCT_VERSION, $footerContent, 'No or wrong product version.');
}
}
41 changes: 38 additions & 3 deletions lib/internal/Magento/Framework/App/ProductMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,56 @@
*/
namespace Magento\Framework\App;

use Magento\Framework\AppInterface;

class ProductMetadata implements ProductMetadataInterface
{
const EDITION_NAME = 'Community';
const PRODUCT_NAME = 'Magento';

/**
* Product version
*
* @var string
*/
protected $version;

/**
* @var \Magento\Framework\Composer\ComposerJsonFinder
*/
protected $composerJsonFinder;

/**
* @param \Magento\Framework\Composer\ComposerJsonFinder $composerJsonFinder
*/
public function __construct(\Magento\Framework\Composer\ComposerJsonFinder $composerJsonFinder)
{
$this->composerJsonFinder = $composerJsonFinder;
}

/**
* Get Product version
*
* @return string
* @throws \Exception
*/
public function getVersion()
{
return AppInterface::VERSION;
if (!$this->version) {
$composerJsonFile = $this->composerJsonFinder->findComposerJson();

$composerContent = file_get_contents($composerJsonFile);
if ($composerContent === false) {
throw new \Exception('Composer file content is empty');
}
$composerContent = json_decode($composerContent, true);
if (!$composerContent
|| !is_array($composerContent)
|| !array_key_exists('version', $composerContent)
) {
throw new \Exception('Unable to decode Composer file');
}
$this->version = $composerContent['version'];
}
return $this->version;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ class ProductMetadataTest extends \PHPUnit_Framework_TestCase

protected function setUp()
{
$composerJsonFinder = $this->getMockBuilder('Magento\Framework\Composer\ComposerJsonFinder')
->disableOriginalConstructor()->setMethods(['findComposerJson'])->getMock();
$composerJsonFinder->expects($this->any())->method('findComposerJson')
->willReturn(realpath(__DIR__ . '/_files/test.composer.json'));

$objectManager = new ObjectManager($this);
$this->productMetadata = $objectManager->getObject('Magento\Framework\App\ProductMetadata');
$this->productMetadata = $objectManager->getObject(
'Magento\Framework\App\ProductMetadata',
['composerJsonFinder' => $composerJsonFinder]
);
}

public function testGetVersion()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"name": "magento/magento2ce",
"description": "Magento 2 (Test Edition)",
"type": "project",
"version": "222.333.444",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"repositories": [
{
"type": "composer",
"url": "https://repo.magento.com/"
}
],
"require": {
"php": "~5.5.0|~5.6.0|~7.0.0",
"ext-openssl": "*"
},
"require-dev": {
"phpunit/phpunit": "4.1.0",
"squizlabs/php_codesniffer": "1.5.3",
"phpmd/phpmd": "@stable",
"pdepend/pdepend": "2.0.6",
"sjparkinson/static-review": "~4.1",
"fabpot/php-cs-fixer": "~1.2",
"lusitanian/oauth": "~0.3 <=0.7.0"
},
"replace": {
"magento/module-marketplace": "100.0.2",
"tinymce/tinymce": "3.4.7"
},
"extra": {
"component_paths": {
"trentrichardson/jquery-timepicker-addon": "lib/web/jquery/jquery-ui-timepicker-addon.js",
"components/jquery": [
"lib/web/jquery.js",
"lib/web/jquery/jquery.min.js",
"lib/web/jquery/jquery-migrate.js"
],
"blueimp/jquery-file-upload": "lib/web/jquery/fileUploader",
"components/jqueryui": [
"lib/web/jquery/jquery-ui.js"
],
"twbs/bootstrap": [
"lib/web/jquery/jquery.tabs.js"
],
"tinymce/tinymce": "lib/web/tiny_mce"
}
},
"config": {
"use-include-path": true
},
"autoload": {
"psr-4": {
"Magento\\Framework\\": "lib/internal/Magento/Framework/",
"Magento\\Setup\\": "setup/src/Magento/Setup/",
"Magento\\": "app/code/Magento/"
},
"psr-0": {
"": "app/code/"
},
"files": [
"app/etc/NonComposerComponentRegistration.php"
]
},
"autoload-dev": {
"psr-4": {
"Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/",
"Magento\\Tools\\": "dev/tools/Magento/Tools/",
"Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/",
"Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
"Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/"
}
},
"minimum-stability": "alpha",
"prefer-stable": true
}
5 changes: 0 additions & 5 deletions lib/internal/Magento/Framework/AppInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ interface AppInterface
*/
const DISTRO_LOCALE_CODE = 'en_US';

/**
* Magento version
*/
const VERSION = '2.0.0';

/**
* Launch application
*
Expand Down
17 changes: 14 additions & 3 deletions setup/src/Magento/Setup/Controller/LandingInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Setup\Controller;

use Magento\Framework\AppInterface;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

Expand All @@ -15,6 +13,19 @@
*/
class LandingInstaller extends AbstractActionController
{
/**
* @var \Magento\Framework\App\ProductMetadata
*/
protected $productMetadata;

/**
* @param \Magento\Framework\App\ProductMetadata $productMetadata
*/
public function __construct(\Magento\Framework\App\ProductMetadata $productMetadata)
{
$this->productMetadata = $productMetadata;
}

/**
* @return array|ViewModel
*/
Expand All @@ -27,7 +38,7 @@ public function indexAction()
$view = new ViewModel;
$view->setTerminal(true);
$view->setTemplate('/magento/setup/landing.phtml');
$view->setVariable('version', AppInterface::VERSION);
$view->setVariable('version', $this->productMetadata->getVersion());
$view->setVariable('welcomeMsg', $welcomeMsg);
$view->setVariable('docRef', $docRef);
$view->setVariable('agreeButtonText', $agreeButtonText);
Expand Down
Loading

0 comments on commit d391b29

Please sign in to comment.