diff --git a/app/code/Magento/Version/Controller/Index/Index.php b/app/code/Magento/Version/Controller/Index/Index.php index 512dbe13ab3c0..6123ed32bd754 100644 --- a/app/code/Magento/Version/Controller/Index/Index.php +++ b/app/code/Magento/Version/Controller/Index/Index.php @@ -1,7 +1,7 @@ rawFactory = $rawFactory; $this->productMetadata = $productMetadata; + $this->appState = $appState ?: ObjectManager::getInstance()->get(AppState::class); } /** @@ -55,11 +65,12 @@ public function execute() $version = $this->productMetadata->getVersion() ?? ''; $versionParts = explode('.', $version); if (!$this->isGitBasedInstallation($version) && $this->isCorrectVersion($versionParts)) { - $rawResponse->setContents( - $this->productMetadata->getName() . '/' . - $this->getMajorMinorVersion($versionParts) . - ' (' . $this->productMetadata->getEdition() . ')' - ); + $content = $this->productMetadata->getName(); + if ($this->appState->getMode() != AppState::MODE_PRODUCTION) { + $content .= '/' . $this->getMajorMinorVersion($versionParts) . + ' (' . $this->productMetadata->getEdition() . ')'; + } + $rawResponse->setContents($content); } return $rawResponse; diff --git a/app/code/Magento/Version/Test/Unit/Controller/Index/IndexTest.php b/app/code/Magento/Version/Test/Unit/Controller/Index/IndexTest.php index 045cb4c40267e..eb27230064bf5 100644 --- a/app/code/Magento/Version/Test/Unit/Controller/Index/IndexTest.php +++ b/app/code/Magento/Version/Test/Unit/Controller/Index/IndexTest.php @@ -1,7 +1,7 @@ onlyMethods(['getName', 'getEdition', 'getVersion']) ->getMockForAbstractClass(); + $this->appStateMock = $this->createMock(AppState::class); + $this->rawResponseFactoryMock = $this->createPartialMock(RawFactory::class, ['create']); $this->rawResponseMock = $this->createPartialMock(Raw::class, ['setContents']); $this->rawResponseFactoryMock->method('create')->willReturn($this->rawResponseMock); @@ -51,7 +57,8 @@ protected function setUp(): void $this->versionController = new VersionIndex( $this->contextMock, $this->rawResponseFactoryMock, - $this->productMetadataMock + $this->productMetadataMock, + $this->appStateMock ); } @@ -85,4 +92,19 @@ public function testCommunityVersionDisplaysMajorMinorVersionAndEditionName(): v $this->versionController->execute(); } + + public function testCommunityVersionDisplaysMajorMinorVersionAndEditionNameProductionMode(): void + { + $this->productMetadataMock->expects($this->any())->method('getVersion')->willReturn('2.3.3'); + $this->productMetadataMock->expects($this->any())->method('getEdition')->willReturn('Community'); + $this->productMetadataMock->expects($this->any())->method('getName')->willReturn('Magento'); + + $this->appStateMock->expects($this->any())->method('getMode')->willReturn(AppState::MODE_PRODUCTION); + + $this->rawResponseMock->expects($this->once())->method('setContents') + ->with('Magento') + ->willReturnSelf(); + + $this->versionController->execute(); + } }