/** * @param array $extensions * @dataProvider dataProviderForTestExtensionsAction * @covers \Magento\Setup\Controller\InstallExtensionGrid::extensionsAction */ public function testExtensionsAction($extensions) { $this->connectManager->expects($this->once())->method('getPackagesForInstall')->will($this->returnValue($extensions)); $jsonModel = $this->controller->extensionsAction(); $this->assertInstanceOf('\\Zend\\View\\Model\\JsonModel', $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('success', $variables); $this->assertArrayHasKey('extensions', $variables); $this->assertArrayHasKey('total', $variables); $this->assertTrue($variables['success']); }
/** * Remove credentials from auth.json * * @return JsonModel */ public function removeCredentialsAction() { try { $result = $this->connectManager->removeCredentials(); return new JsonModel(['success' => $result]); } catch (\Exception $e) { return new JsonModel(['success' => false, 'message' => $e->getMessage()]); } }
/** * Sync action * * @return \Zend\View\Model\JsonModel */ public function syncAction() { $this->updatePackagesCache->syncPackagesForUpdate(); $lastSyncData = $this->updatePackagesCache->getPackagesForUpdate(); $this->connectManager->syncPackagesForInstall(); $packagesForInstall = $this->connectManager->getPackagesForInstall(); $lastSyncData['countOfInstall'] = isset($packagesForInstall['packages']) ? count($packagesForInstall['packages']) : 0; $lastSyncData['countOfUpdate'] = isset($lastSyncData['packages']) ? count($lastSyncData['packages']) : 0; return new \Zend\View\Model\JsonModel(['success' => true, 'lastSyncData' => $lastSyncData]); }
/** * @covers \Magento\Setup\Controller\Connect::removeAuthAction */ public function testRemoveCredentialsWithError() { $this->connectManager->expects($this->once())->method('removeCredentials')->will($this->throwException(new \Exception())); $jsonModel = $this->controller->removeCredentialsAction(); $this->assertInstanceOf('\\Zend\\View\\Model\\JsonModel', $jsonModel); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('success', $variables); $this->assertArrayHasKey('message', $variables); $this->assertFalse($variables['success']); }