9 use \Magento\Setup\Controller\OtherComponentsGrid;
10 use \Magento\Setup\Controller\ResponseTypeInterface;
18 private $composerInformation;
34 $this->composerInformation = $this->createMock(\
Magento\Framework\Composer\ComposerInformation::class);
35 $this->infoCommand = $this->createMock(\
Magento\Composer\InfoCommand::class);
36 $magentoComposerApplicationFactory =
37 $this->createMock(\
Magento\Framework\Composer\MagentoComposerApplicationFactory::class);
38 $magentoComposerApplicationFactory->expects($this->once())
39 ->method(
'createInfoCommand')
40 ->willReturn($this->infoCommand);
42 $this->composerInformation,
43 $magentoComposerApplicationFactory
49 $this->composerInformation->expects($this->once())
50 ->method(
'getInstalledMagentoPackages')
52 'magento/sample-module1' => [
53 'name' =>
'magento/sample-module1',
54 'type' =>
'magento2-module',
58 $this->composerInformation->expects($this->once())
59 ->method(
'isPackageInComposerJson')
61 $this->infoCommand->expects($this->once())
64 'versions' =>
'3.0.0, 2.0.0',
65 'current_version' =>
'1.0.0',
71 $jsonModel = $this->controller->componentsAction();
72 $this->assertInstanceOf(\
Zend\View\Model\JsonModel::class, $jsonModel);
73 $variables = $jsonModel->getVariables();
74 $this->assertArrayHasKey(
'responseType', $variables);
76 $this->assertArrayHasKey(
'components', $variables);
79 'name' =>
'magento/sample-module1',
80 'type' =>
'magento2-module',
82 'vendor' =>
'magento',
86 'name' =>
'3.0.0 (latest)' 94 'name' =>
'1.0.0 (current)' 97 'dropdownId' =>
'dd_magento/sample-module1',
98 'checkboxId' =>
'cb_magento/sample-module1' 101 $this->assertEquals($expected, $variables[
'components']);
102 $this->assertArrayHasKey(
'total', $variables);
103 $this->assertEquals(1, $variables[
'total']);
108 $this->composerInformation->expects($this->once())
109 ->method(
'getInstalledMagentoPackages')
110 ->will($this->throwException(
new \
Exception(
"Test error message")));
111 $jsonModel = $this->controller->componentsAction();
112 $this->assertInstanceOf(\
Zend\View\Model\JsonModel::class, $jsonModel);
113 $variables = $jsonModel->getVariables();
114 $this->assertArrayHasKey(
'responseType', $variables);
120 $model = $this->controller->indexAction();
121 $this->assertInstanceOf(\
Zend\View\Model\ViewModel::class,
$model);
const RESPONSE_TYPE_SUCCESS
testComponentsActionWithError()
const RESPONSE_TYPE_ERROR