-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Cover magento/module-admin-analytics with unit tests #31065
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mbvb1223
wants to merge
23
commits into
magento:2.4-develop
Choose a base branch
from
mbvb1223:cover-admin-analytics-unit-tests
base: 2.4-develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
01c167a
Fix coding standards
binhtd-smartosc 3e8212e
remove trailing_comma_in_multiline_array
binhtd-smartosc b532170
Add test for Model\Viewer\Log
binhtd-smartosc 533eb63
Add unit tests for Model, Action, Ui, ViewModel
binhtd-smartosc 5462836
Sort imported class
binhtd-smartosc 061b1ec
Remove ProductMetadataInterface in CanViewNotificationTest
binhtd-smartosc a910e64
Merge branch '2.4-develop' into cover-admin-analytics-unit-tests
mbvb1223 acdc483
Merge branch '2.4-develop' into cover-admin-analytics-unit-tests
mbvb1223 02eac6d
Merge branch '2.4-develop' into cover-admin-analytics-unit-tests
mbvb1223 a5c44a7
Merge branch '2.4-develop' into cover-admin-analytics-unit-tests
mbvb1223 da3ad3d
Merge branch '2.4-develop' into cover-admin-analytics-unit-tests
mbvb1223 0d46f43
Merge branch '2.4-develop' into cover-admin-analytics-unit-tests
mbvb1223 af574fe
Merge branch '2.4-develop' of github.com:magento/magento2 into cover-…
khienpc2 50af59c
Update unit tests for MetadataTest.php
khienpc2 6a2ff65
Merge branch '2.4-develop' into cover-admin-analytics-unit-tests
mbvb1223 6f78b0e
Merge branch '2.4-develop' into cover-admin-analytics-unit-tests
mbvb1223 f08c58f
Merge branch '2.4-develop' into cover-admin-analytics-unit-tests
mbvb1223 3ec916d
Merge branch '2.4-develop' into cover-admin-analytics-unit-tests
mbvb1223 634e08c
Merge branch '2.4-develop' into cover-admin-analytics-unit-tests
mbvb1223 a1fa710
Merge branch '2.4-develop' into cover-admin-analytics-unit-tests
mbvb1223 f2532d9
Merge branch '2.4-develop' into cover-admin-analytics-unit-tests
mbvb1223 872e301
Merge branch '2.4-develop' into cover-admin-analytics-unit-tests
mbvb1223 9323f0f
Merge branch '2.4-develop' into cover-admin-analytics-unit-tests
mbvb1223 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 | ||
---|---|---|---|---|
|
@@ -11,7 +11,6 @@ | |||
use Magento\AdminAnalytics\Model\ResourceModel\Viewer\Logger; | ||||
use Magento\AdminAnalytics\Model\Viewer\Log; | ||||
use Magento\Framework\App\CacheInterface; | ||||
use Magento\Framework\App\ProductMetadataInterface; | ||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | ||||
use PHPUnit\Framework\MockObject\MockObject; | ||||
use PHPUnit\Framework\TestCase; | ||||
|
@@ -21,31 +20,28 @@ class CanViewNotificationTest extends TestCase | |||
/** @var CanViewNotification */ | ||||
private $canViewNotification; | ||||
|
||||
/** @var Logger|MockObject */ | ||||
/** @var Logger|MockObject */ | ||||
private $viewerLoggerMock; | ||||
|
||||
/** @var ProductMetadataInterface|MockObject */ | ||||
private $productMetadataMock; | ||||
/** @var CacheInterface|MockObject */ | ||||
private $cacheStorageMock; | ||||
|
||||
/** @var Log|MockObject */ | ||||
/** @var Log|MockObject */ | ||||
private $logMock; | ||||
|
||||
/** @var MockObject|CacheInterface $cacheStorageMock */ | ||||
private $cacheStorageMock; | ||||
|
||||
protected function setUp(): void | ||||
{ | ||||
$this->viewerLoggerMock = $this->createMock(Logger::class); | ||||
$this->cacheStorageMock = $this->getMockBuilder(CacheInterface::class) | ||||
->getMockForAbstractClass(); | ||||
|
||||
$this->logMock = $this->createMock(Log::class); | ||||
$this->viewerLoggerMock = $this->createMock(Logger::class); | ||||
$this->productMetadataMock = $this->getMockForAbstractClass(ProductMetadataInterface::class); | ||||
|
||||
$objectManager = new ObjectManager($this); | ||||
$this->canViewNotification = $objectManager->getObject( | ||||
CanViewNotification::class, | ||||
[ | ||||
'viewerLogger' => $this->viewerLoggerMock, | ||||
'productMetadata' => $this->productMetadataMock, | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't have
|
||||
'cacheStorage' => $this->cacheStorageMock, | ||||
] | ||||
); | ||||
|
@@ -55,6 +51,7 @@ protected function setUp(): void | |||
* @param $expected | ||||
* @param $cacheResponse | ||||
* @param $logExists | ||||
* | ||||
* @dataProvider isVisibleProvider | ||||
*/ | ||||
public function testIsVisibleLoadDataFromLog($expected, $cacheResponse, $logExists) | ||||
|
@@ -72,6 +69,13 @@ public function testIsVisibleLoadDataFromLog($expected, $cacheResponse, $logExis | |||
$this->assertEquals($expected, $this->canViewNotification->isVisible([])); | ||||
} | ||||
|
||||
public function testGetName() | ||||
{ | ||||
$result = $this->canViewNotification->getName(); | ||||
|
||||
$this->assertSame('can_view_admin_usage_notification', $result); | ||||
} | ||||
|
||||
/** | ||||
* @return array | ||||
*/ | ||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved
private
-disableAdminUsage, markUserNotified
method down