-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Ability to define Area for dev:di:info CLI command #38758 #38759
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
Merged
magento-devops-reposync-svc
merged 19 commits into
magento:2.4-develop
from
rostilos:fix-for-issue-38758
Oct 18, 2024
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
292c9b6
Merge pull request #1 from magento/2.4-develop
rostilos 7fa4832
Merge branch 'magento:2.4-develop' into 2.4-develop
rostilos b3804fa
[issue #38758] Area code parameter for dev:di:info CLI command
rostilos f969a17
[issue #38758] Area code parameter for dev:di:info CLI command ( fixes )
rostilos b8060ac
Merge branch 'magento:2.4-develop' into 2.4-develop
rostilos 2553d94
Merge remote-tracking branch 'refs/remotes/origin/2.4-develop' into f…
691b517
Merge branch '2.4-develop' into fix-for-issue-38758
engcom-Charlie 07a2784
Merge branch '2.4-develop' into fix-for-issue-38758
engcom-Hotel c90d2dd
issue-38758 added new constructor param as null and handle with Objec…
d72c7ae
issue-38758 code refactoring ( dev:di:info )
ed345a1
issue-38703 codestyle issues fix
6447c54
issue-38703 codestyle ( prettify )
0a20ef5
issue-38758 added test coverage ( integration tests )
2735499
Merge branch '2.4-develop' into fix-for-issue-38758
engcom-Hotel 5b29414
issue-38758 codestyle fixes ( static tests )
e81b4de
Merge remote-tracking branch 'origin/fix-for-issue-38758' into fix-fo…
671583d
issue-38758 codestyle fixes ( strict_types and copyright )
21e3f48
Merge branch '2.4-develop' into fix-for-issue-38758
engcom-Bravo 60c3032
Merge branch '2.4-develop' into fix-for-issue-38758
engcom-Charlie 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
146 changes: 146 additions & 0 deletions
146
dev/tests/integration/testsuite/Magento/Developer/Console/Command/DiInfoCommandTest.php
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 |
---|---|---|
@@ -0,0 +1,146 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Developer\Console\Command; | ||
|
||
use Magento\Developer\Model\Di\Information; | ||
use Magento\Framework\App\AreaList; | ||
use Magento\TestFramework\Helper\Bootstrap; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Console\Tester\CommandTester; | ||
use Magento\Framework\ObjectManagerInterface; | ||
|
||
class DiInfoCommandTest extends TestCase | ||
{ | ||
/** | ||
* @var ObjectManagerInterface | ||
*/ | ||
private ObjectManagerInterface $objectManager; | ||
|
||
/** | ||
* @var Information|MockObject | ||
*/ | ||
private Information|MockObject $informationMock; | ||
|
||
/** | ||
* @var AreaList|MockObject | ||
*/ | ||
private AreaList|MockObject $areaListMock; | ||
|
||
/** | ||
* @var DiInfoCommand | ||
*/ | ||
private DiInfoCommand $command; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
$this->objectManager = Bootstrap::getObjectManager(); | ||
$this->informationMock = $this->createMock(Information::class); | ||
$this->areaListMock = $this->createMock(AreaList::class); | ||
$this->command = new DiInfoCommand($this->informationMock, $this->objectManager, $this->areaListMock); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function testExecuteWithGlobalArea(): void | ||
{ | ||
$this->informationMock->expects($this->any()) | ||
->method('getPreference') | ||
->with('Magento\Framework\App\RouterList') | ||
->willReturn('Magento\Framework\App\RouterList'); | ||
|
||
$this->informationMock->expects($this->any()) | ||
->method('getParameters') | ||
->with('Magento\Framework\App\RouterList') | ||
->willReturn([ | ||
['objectManager', 'Magento\Framework\ObjectManagerInterface', null], | ||
['routerList', null, null] | ||
]); | ||
|
||
$this->informationMock->expects($this->once()) | ||
->method('getVirtualTypes') | ||
->with('Magento\Framework\App\RouterList') | ||
->willReturn([]); | ||
|
||
$this->informationMock->expects($this->any()) | ||
->method('getPlugins') | ||
->with('Magento\Framework\App\RouterList') | ||
->willReturn([ | ||
'before' => [], | ||
'around' => [], | ||
'after' => [] | ||
]); | ||
|
||
$commandTester = new CommandTester($this->command); | ||
$commandTester->execute( | ||
[ | ||
DiInfoCommand::CLASS_NAME => "Magento\Framework\App\RouterList", | ||
DiInfoCommand::AREA_CODE => null | ||
], | ||
); | ||
$this->assertStringContainsString( | ||
'DI configuration for the class Magento\Framework\App\RouterList in the GLOBAL area', | ||
$commandTester->getDisplay() | ||
); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function testExecuteWithAreaCode(): void | ||
{ | ||
$className = "Magento\Framework\App\RouterList"; | ||
$this->informationMock->expects($this->any()) | ||
->method('getPreference') | ||
->with($className) | ||
->willReturn($className); | ||
|
||
$this->informationMock->expects($this->any()) | ||
->method('getParameters') | ||
->with($className) | ||
->willReturn([ | ||
['objectManager', 'Magento\Framework\ObjectManagerInterface', null], | ||
['routerList', null, null] | ||
]); | ||
|
||
$this->informationMock->expects($this->once()) | ||
->method('getVirtualTypes') | ||
->with($className) | ||
->willReturn([]); | ||
|
||
$this->informationMock->expects($this->any()) | ||
->method('getPlugins') | ||
->with($className) | ||
->willReturn([ | ||
'before' => [], | ||
'around' => [], | ||
'after' => [] | ||
]); | ||
|
||
$this->areaListMock->expects($this->once()) | ||
->method('getCodes') | ||
->willReturn(['frontend', 'adminhtml']); | ||
|
||
$commandTester = new CommandTester($this->command); | ||
$commandTester->execute( | ||
[ | ||
DiInfoCommand::CLASS_NAME => "$className", | ||
DiInfoCommand::AREA_CODE => "adminhtml" | ||
], | ||
); | ||
|
||
$this->assertStringContainsString( | ||
"DI configuration for the class $className in the ADMINHTML area", | ||
$commandTester->getDisplay() | ||
); | ||
} | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.