public function testInstalledSystemPackageActionWithError() { $this->systemPackage->expects($this->once())->method('getInstalledSystemPackages')->will($this->throwException(new \Exception("Test error message"))); $jsonModel = $this->controller->installedSystemPackageAction(); $variables = $jsonModel->getVariables(); $this->assertArrayHasKey('responseType', $variables); $this->assertEquals(ResponseTypeInterface::RESPONSE_TYPE_ERROR, $variables['responseType']); }
/** * Gets installed system package * * @return JsonModel */ public function installedSystemPackageAction() { $data = []; try { $data['packages'] = $this->systemPackage->getInstalledSystemPackages([]); $data['responseType'] = ResponseTypeInterface::RESPONSE_TYPE_SUCCESS; } catch (\Exception $e) { $data['error'] = $e->getMessage(); $data['responseType'] = ResponseTypeInterface::RESPONSE_TYPE_ERROR; } return new JsonModel($data); }
/** * Gets system package and versions * * @return JsonModel */ public function systemPackageAction() { $data = []; try { $data['packages'] = $this->systemPackage->getPackageVersions(); $responseType = ResponseTypeInterface::RESPONSE_TYPE_SUCCESS; } catch (\Exception $e) { $responseType = ResponseTypeInterface::RESPONSE_TYPE_ERROR; $data['error'] = $e->getMessage(); } $data['responseType'] = $responseType; return new JsonModel($data); }