forked from magento/magento2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2.4-develop' into fix-for-issue-38059
- Loading branch information
Showing
2,506 changed files
with
56,630 additions
and
27,458 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
app/code/Magento/AdminAnalytics/Test/Mftf/class-file-naming-allowlist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CloseAllDialogBoxes | ||
SelectAdminUsageSetting |
128 changes: 128 additions & 0 deletions
128
...ode/Magento/AdminAnalytics/Test/Unit/Controller/Adminhtml/Config/EnableAdminUsageTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\AdminAnalytics\Test\Unit\Controller\Adminhtml\Config; | ||
|
||
use Magento\AdminAnalytics\Controller\Adminhtml\Config\EnableAdminUsage; | ||
use Magento\AdminAnalytics\Model\ResourceModel\Viewer\Logger as NotificationLogger; | ||
use Magento\Config\Model\Config; | ||
use Magento\Config\Model\Config\Factory as ConfigFactory; | ||
use Magento\Framework\App\ProductMetadataInterface; | ||
use Magento\Framework\Controller\Result\Json as JsonResult; | ||
use Magento\Framework\Controller\ResultFactory; | ||
use Magento\Framework\Controller\ResultInterface; | ||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
|
||
/** | ||
* @covers \Magento\AdminAnalytics\Controller\Adminhtml\Config\EnableAdminUsage | ||
*/ | ||
class EnableAdminUsageTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
private const STUB_PRODUCT_VERSION = 'Product Version'; | ||
|
||
/** @var EnableAdminUsage */ | ||
private $controller; | ||
|
||
/** @var MockObject|Config */ | ||
private $configMock; | ||
|
||
/** @var MockObject|ProductMetadataInterface */ | ||
private $productMetadataMock; | ||
|
||
/** @var MockObject|NotificationLogger */ | ||
private $notificationLoggerMock; | ||
|
||
/** @var MockObject|ResultFactory */ | ||
private $resultFactoryMock; | ||
|
||
/** @var JsonResult|MockObject */ | ||
private $resultMock; | ||
|
||
protected function setUp(): void | ||
{ | ||
$objectManager = new ObjectManager($this); | ||
|
||
$this->configMock = $this->getMockBuilder(Config::class) | ||
->disableOriginalConstructor() | ||
->onlyMethods(['setDataByPath', 'save']) | ||
->getMock(); | ||
|
||
$configFactory = $this->getMockBuilder(ConfigFactory::class) | ||
->disableOriginalConstructor() | ||
->onlyMethods(['create']) | ||
->getMock(); | ||
|
||
$configFactory->method('create') | ||
->willReturn($this->configMock); | ||
|
||
$this->productMetadataMock = $this->getMockBuilder(ProductMetadataInterface::class) | ||
->onlyMethods(['getVersion']) | ||
->getMockForAbstractClass(); | ||
|
||
$this->productMetadataMock->method('getVersion') | ||
->willReturn(self::STUB_PRODUCT_VERSION); | ||
|
||
$this->notificationLoggerMock = $this->getMockBuilder(NotificationLogger::class) | ||
->disableOriginalConstructor() | ||
->onlyMethods(['log']) | ||
->getMock(); | ||
|
||
$this->resultFactoryMock = $this->getMockBuilder(ResultFactory::class) | ||
->disableOriginalConstructor() | ||
->onlyMethods(['create']) | ||
->getMock(); | ||
|
||
$this->resultMock = $this->getMockBuilder(JsonResult::class) | ||
->disableOriginalConstructor() | ||
->onlyMethods(['setData']) | ||
->getMock(); | ||
|
||
$this->resultFactoryMock->method('create') | ||
->with(ResultFactory::TYPE_JSON) | ||
->willReturn($this->resultMock); | ||
|
||
$this->controller = $objectManager->getObject(EnableAdminUsage::class, [ | ||
'configFactory' => $configFactory, | ||
'productMetadata' => $this->productMetadataMock, | ||
'notificationLogger' => $this->notificationLoggerMock, | ||
'resultFactory' => $this->resultFactoryMock | ||
]); | ||
} | ||
|
||
/** | ||
* If Controller returns `null`, no data is passed to the browser | ||
*/ | ||
public function testResponseAfterAdminUsageChange() | ||
{ | ||
// Given | ||
$this->resultMock->method('setData')->willReturnSelf(); | ||
|
||
// When | ||
$response = $this->controller->execute(); | ||
|
||
// Then | ||
$this->assertInstanceOf(ResultInterface::class, $response); | ||
} | ||
|
||
public function testResponseWhenExceptionThrown() | ||
{ | ||
$this->markTestSkipped('magento/magento2#31393 Lack of exception handling'); | ||
|
||
$this->configMock->method('setDataByPath') | ||
->willThrowException( | ||
new \Exception('System Exception') | ||
); | ||
|
||
// When | ||
$response = $this->controller->execute(); | ||
|
||
// Then | ||
$this->assertInstanceOf(ResultInterface::class, $response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.