public function testStartModuleWithTransientError()
 {
     $req = new StartModuleRequest();
     $resp = new ApplicationError(ErrorCode::TRANSIENT_ERROR, 'invalid version');
     $req->setModule('module1');
     $req->setVersion('v1');
     $this->setExpectedException('\\google\\appengine\\api\\modules\\TransientModulesException');
     $this->apiProxyMock->expectCall('modules', 'StartModule', $req, $resp);
     ModulesService::startVersion('module1', 'v1');
     $this->apiProxyMock->verify();
 }
Exemple #2
0
 /**
  * Starts all instances of the given version of a module.
  * *
  * @param string $module The name of the module to start.
  *
  * @param string $version The version of the module to start.
  *
  * @throws \InvalidArgumentException If $module or $version is not a string.
  * @throws ModulesException if the given combination of $module and $version
  * is invalid.
  * @throws InvalidModuleStateException if the given $version is already
  * started or cannot be started.
  * @throws TransientModulesException if there is an issue starting the module
  * version.
  */
 public static function startVersion($module, $version)
 {
     $req = new StartModuleRequest();
     $resp = new StartModuleResponse();
     if (!is_string($module)) {
         throw new \InvalidArgumentException('$module must be a string. Actual type: ' . gettype($module));
     }
     $req->setModule($module);
     if (!is_string($version)) {
         throw new \InvalidArgumentException('$version must be a string. Actual type: ' . gettype($version));
     }
     $req->setVersion($version);
     try {
         ApiProxy::makeSyncCall('modules', 'StartModule', $req, $resp);
     } catch (ApplicationError $e) {
         throw self::errorCodeToException($e->getApplicationError());
     }
 }