コード例 #1
0
 /**
  * @param array $extensions
  * @dataProvider dataProviderForTestExtensionsAction
  * @covers \Magento\Setup\Controller\InstallExtensionGrid::extensionsAction
  */
 public function testExtensionsAction($extensions)
 {
     $this->marketplaceManager->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']);
 }
コード例 #2
0
ファイル: ComponentGrid.php プロジェクト: razbakov/magento2
    /**
     * Sync action
     *
     * @return \Zend\View\Model\JsonModel
     */
    public function syncAction()
    {
        $error = '';
        try {
            $this->updatePackagesCache->syncPackagesForUpdate();
            $lastSyncData = $this->updatePackagesCache->getPackagesForUpdate();

            $this->marketplaceManager->syncPackagesForInstall();
            $packagesForInstall = $this->marketplaceManager->getPackagesForInstall();
        } catch (\Exception $e) {
            $error = $e->getMessage();
        }


        $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,
                'error' => $error
            ]
        );
    }
コード例 #3
0
 /**
  * Remove credentials from auth.json
  *
  * @return JsonModel
  */
 public function removeCredentialsAction()
 {
     try {
         $result = $this->marketplaceManager->removeCredentials();
         return new JsonModel(['success' => $result]);
     } catch (\Exception $e) {
         return new JsonModel(['success' => false, 'message' => $e->getMessage()]);
     }
 }
コード例 #4
0
 /**
  * @covers \Magento\Setup\Controller\Marketplace::removeAuthAction
  */
 public function testRemoveCredentialsWithError()
 {
     $this->marketplaceManager->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']);
 }
コード例 #5
0
 /**
  * Sync action
  *
  * @return \Zend\View\Model\JsonModel
  */
 public function syncAction()
 {
     $error = '';
     try {
         $this->updatePackagesCache->syncPackagesForUpdate();
         $lastSyncData = $this->updatePackagesCache->getPackagesForUpdate();
         $this->marketplaceManager->syncPackagesForInstall();
         $packagesForInstall = $this->marketplaceManager->getPackagesForInstall();
     } catch (\Exception $e) {
         $error = $e->getMessage();
     }
     $lastSyncData = $this->formatLastSyncData($packagesForInstall, $lastSyncData);
     return new \Zend\View\Model\JsonModel(['success' => true, 'lastSyncData' => $lastSyncData, 'error' => $error]);
 }