Skip to content

Commit 055a79b

Browse files
authored
Merge pull request #2354 from magento-honey-badgers/MAGETWO-90203
[honey] MAGETWO-90203: Failing Magento\Version\Controller\Index\IndexTest::testIndexAction
2 parents 81b10b7 + 7cdeafc commit 055a79b

File tree

2 files changed

+26
-5
lines changed
  • app/code/Magento/Version/Controller/Index
  • dev/tests/integration/testsuite/Magento/Version/Controller/Index

2 files changed

+26
-5
lines changed

app/code/Magento/Version/Controller/Index/Index.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,12 @@ public function __construct(Context $context, ProductMetadataInterface $productM
3939
*/
4040
public function execute()
4141
{
42-
$versionParts = explode('.', $this->productMetadata->getVersion());
43-
if (!isset($versionParts[0]) || !isset($versionParts[1])) {
44-
return ; // Major and minor version are not set - return empty response
42+
$version = $this->productMetadata->getVersion();
43+
$versionParts = explode('.', $version);
44+
if ((!isset($versionParts[0]) || !isset($versionParts[1]))
45+
|| $this->isGitBasedInstallation($version)
46+
) {
47+
return;
4548
}
4649
$majorMinorVersion = $versionParts[0] . '.' . $versionParts[1];
4750
$this->getResponse()->setBody(
@@ -50,4 +53,16 @@ public function execute()
5053
$this->productMetadata->getEdition() . ')'
5154
);
5255
}
56+
57+
/**
58+
* Check if provided version is generated by Git-based Magento instance.
59+
*
60+
* @param string $fullVersion
61+
* @return bool
62+
*/
63+
private function isGitBasedInstallation($fullVersion)
64+
{
65+
$versionParts = explode('-', $fullVersion);
66+
return (isset($versionParts[0]) && $versionParts[0] == 'dev');
67+
}
5368
}

dev/tests/integration/testsuite/Magento/Version/Controller/Index/IndexTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public function testIndexAction()
2020
$edition = $productMetadata->getEdition();
2121

2222
$fullVersion = $productMetadata->getVersion();
23-
$versionParts = explode('.', $fullVersion);
24-
if (isset($versionParts[1]) && isset($versionParts[0])) {
23+
if ($this->isComposerBasedInstallation($fullVersion)) {
24+
$versionParts = explode('.', $fullVersion);
2525
$majorMinor = $versionParts[0] . '.' . $versionParts[1];
2626

2727
// Response must contain Major.Minor version, product name, and edition
@@ -36,4 +36,10 @@ public function testIndexAction()
3636
$this->assertEmpty($body);
3737
}
3838
}
39+
40+
private function isComposerBasedInstallation($fullVersion)
41+
{
42+
$versionParts = explode('-', $fullVersion);
43+
return !(isset($versionParts[0]) && $versionParts[0] == 'dev');
44+
}
3945
}

0 commit comments

Comments
 (0)