public function testGetVersionsWithModule()
 {
     $req = new GetVersionsRequest();
     $resp = new GetVersionsResponse();
     $req->setModule('module1');
     $resp->addVersion('v1');
     $resp->addVersion('v2');
     $this->apiProxyMock->expectCall('modules', 'GetVersions', $req, $resp);
     $this->assertEquals(['v1', 'v2'], ModulesService::getVersions('module1'));
     $this->apiProxyMock->verify();
 }
Ejemplo n.º 2
0
 /**
  * Get an array of all versions associated with a module.
  *
  * @param string $module The name of the module to retrieve the versions for.
  * If null then the versions for the current module will be retrieved.
  *
  * @return string[] An array of strings containing the names of versions
  * associated with the module. The current version will also be included in
  * this list.
  *
  * @throws \InvalidArgumentException If $module is not a string.
  * @throws ModulesException If the given $module isn't valid.
  * @throws TransientModulesException if there is an issue fetching the
  * information.
  */
 public static function getVersions($module = null)
 {
     $req = new GetVersionsRequest();
     $resp = new GetVersionsResponse();
     if ($module !== null) {
         if (!is_string($module)) {
             throw new \InvalidArgumentException('$module must be a string. Actual type: ' . gettype($module));
         }
         $req->setModule($module);
     }
     try {
         ApiProxy::makeSyncCall('modules', 'GetVersions', $req, $resp);
     } catch (ApplicationError $e) {
         throw errorCodeToException($e->getApplicationError());
     }
     return $resp->getVersionList();
 }