Skip to content
Merged
Changes from 1 commit
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 Oct 13, 2023
7fa4832
Merge branch 'magento:2.4-develop' into 2.4-develop
rostilos May 26, 2024
b3804fa
[issue #38758] Area code parameter for dev:di:info CLI command
rostilos May 26, 2024
f969a17
[issue #38758] Area code parameter for dev:di:info CLI command ( fixes )
rostilos May 26, 2024
b8060ac
Merge branch 'magento:2.4-develop' into 2.4-develop
rostilos Jul 12, 2024
2553d94
Merge remote-tracking branch 'refs/remotes/origin/2.4-develop' into f…
Aug 11, 2024
691b517
Merge branch '2.4-develop' into fix-for-issue-38758
engcom-Charlie Aug 13, 2024
07a2784
Merge branch '2.4-develop' into fix-for-issue-38758
engcom-Hotel Aug 19, 2024
c90d2dd
issue-38758 added new constructor param as null and handle with Objec…
Aug 30, 2024
d72c7ae
issue-38758 code refactoring ( dev:di:info )
Aug 30, 2024
ed345a1
issue-38703 codestyle issues fix
Sep 4, 2024
6447c54
issue-38703 codestyle ( prettify )
Sep 4, 2024
0a20ef5
issue-38758 added test coverage ( integration tests )
Sep 4, 2024
2735499
Merge branch '2.4-develop' into fix-for-issue-38758
engcom-Hotel Sep 9, 2024
5b29414
issue-38758 codestyle fixes ( static tests )
Sep 11, 2024
e81b4de
Merge remote-tracking branch 'origin/fix-for-issue-38758' into fix-fo…
Sep 11, 2024
671583d
issue-38758 codestyle fixes ( strict_types and copyright )
Sep 11, 2024
21e3f48
Merge branch '2.4-develop' into fix-for-issue-38758
engcom-Bravo Sep 12, 2024
60c3032
Merge branch '2.4-develop' into fix-for-issue-38758
engcom-Charlie Sep 13, 2024
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
Prev Previous commit
Next Next commit
issue-38758 added test coverage ( integration tests )
  • Loading branch information
rostislav committed Sep 4, 2024
commit 0a20ef5084b55ad5e88c190454dc72aab0b7042f
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?php

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()
);
}
}