コード例 #1
0
 /**
  * @param array $extensions
  * @dataProvider dataProviderForTestExtensionsAction
  * @covers \Magento\Setup\Controller\InstallExtensionGrid::extensionsAction
  */
 public function testExtensionsAction($extensions)
 {
     $this->packagesData->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
 public function testSyncPackagesData()
 {
     $latestData = $this->packagesData->syncPackagesData();
     $this->assertArrayHasKey('lastSyncDate', $latestData);
     $this->assertArrayHasKey('date', $latestData['lastSyncDate']);
     $this->assertArrayHasKey('time', $latestData['lastSyncDate']);
     $this->assertArrayHasKey('packages', $latestData);
     $this->assertSame(2, count($latestData['packages']));
     $this->assertSame(2, $latestData['countOfUpdate']);
     $this->assertArrayHasKey('installPackages', $latestData);
     $this->assertSame(1, count($latestData['installPackages']));
     $this->assertSame(1, $latestData['countOfInstall']);
 }
コード例 #3
0
 public function testSyncAction()
 {
     $this->packagesData->expects($this->once())->method('syncPackagesData')->willReturn($this->lastSyncData);
     $jsonModel = $this->controller->syncAction();
     $this->assertInstanceOf('Zend\\View\\Model\\JsonModel', $jsonModel);
     $variables = $jsonModel->getVariables();
     $this->assertArrayHasKey('success', $variables);
     $this->assertTrue($variables['success']);
     $this->assertEquals($this->lastSyncData, $variables['lastSyncData']);
 }
コード例 #4
0
 /**
  * Sync action
  *
  * @return \Zend\View\Model\JsonModel
  */
 public function syncAction()
 {
     $error = '';
     $lastSyncData = [];
     try {
         $lastSyncData = $this->packagesData->syncPackagesData();
     } catch (\Exception $e) {
         $error = $e->getMessage();
     }
     return new \Zend\View\Model\JsonModel(['success' => true, 'lastSyncData' => $lastSyncData, 'error' => $error]);
 }
コード例 #5
0
ファイル: Marketplace.php プロジェクト: Doability/magento2dev
 /**
  * Save auth.json
  *
  * @return array|ViewModel
  */
 public function saveAuthJsonAction()
 {
     $params = [];
     if ($this->getRequest()->getContent()) {
         $params = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY);
     }
     try {
         $userName = isset($params['username']) ? $params['username'] : '';
         $password = isset($params['password']) ? $params['password'] : '';
         $isValid = $this->packagesAuth->checkCredentials($userName, $password);
         $isValid = json_decode($isValid, true);
         if ($isValid['success'] === true && $this->packagesAuth->saveAuthJson($userName, $password)) {
             $this->packagesData->syncPackagesData();
             return new JsonModel(['success' => true]);
         } else {
             return new JsonModel(['success' => false, 'message' => $isValid['message']]);
         }
     } catch (\Exception $e) {
         return new JsonModel(['success' => false, 'message' => $e->getMessage()]);
     }
 }
コード例 #6
0
 /**
  * Get Extensions info action
  *
  * @return JsonModel
  */
 public function extensionsAction()
 {
     $extensions = $this->packagesData->getPackagesForInstall();
     $packages = isset($extensions['packages']) ? $extensions['packages'] : [];
     return new JsonModel(['success' => true, 'extensions' => array_values($packages), 'total' => count($packages)]);
 }