Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
InstallExtensionGridTest.php
Go to the documentation of this file.
1 <?php
8 
12 
13 class InstallExtensionGridTest extends \PHPUnit\Framework\TestCase
14 {
20  private $controller;
21 
25  private $packagesData;
26 
27  public function setUp()
28  {
29  $this->packagesData = $this->getMockBuilder(PackagesData::class)
30  ->disableOriginalConstructor()
31  ->getMock();
32 
33  $this->controller = new InstallExtensionGrid(
34  $this->packagesData
35  );
36  }
37 
41  public function testIndexAction()
42  {
43  $viewModel = $this->controller->indexAction();
44  static::assertInstanceOf(\Zend\View\Model\ViewModel::class, $viewModel);
45  }
46 
52  public function testExtensionsAction($extensions)
53  {
54  $this->packagesData->expects(static::once())
55  ->method('getPackagesForInstall')
56  ->willReturn($extensions);
57 
58  $jsonModel = $this->controller->extensionsAction();
59  static::assertInstanceOf(\Zend\View\Model\JsonModel::class, $jsonModel);
60  $variables = $jsonModel->getVariables();
61  static::assertArrayHasKey('success', $variables);
62  static::assertArrayHasKey('extensions', $variables);
63  static::assertArrayHasKey('total', $variables);
64  static::assertTrue($variables['success']);
65  }
66 
71  {
72  $extensions['packages'] = [
73  'magento/testing-extension' => [
74  'name' => 'magento/testing-extension',
76  'vendor' => 'magento',
77  'version' => '2.2.2',
78  'author' => 'magento'],
79  'magento/my-first-module' => [
80  'name' => 'magento/my-first-module',
82  'vendor' => 'magento',
83  'version' => '2.0.0',
84  'author' => 'magento'],
85  'magento/last-extension' => [
86  'name' => 'magento/theme',
88  'vendor' => 'magento',
89  'version' => '2.1.1',
90  'author' => 'magento'],
91  'magento/magento-second-module' => [
92  'name' => 'magento/magento-second-module',
94  'vendor' => 'magento',
95  'version' => '2.0.0',
96  'author' => 'magento']
97  ];
98  return [[$extensions]];
99  }
100 }
$viewModel