public function testRollback()
 {
     $body = m::mock(\Psr\Http\Message\StreamInterface::class);
     $body->shouldReceive('getContents')->once()->andReturn('{"success": "Rolled back"}');
     $response = m::mock(\Psr\Http\Message\ResponseInterface::class);
     $response->shouldReceive('getBody')->once()->andReturn($body);
     $client = m::mock(\GuzzleHttp\Client::class);
     $client->shouldReceive('request')->with(m::mustBe('POST'), m::mustBe($this->config['remote_endpoint'] . '?cmd=rollback'), new PayloadMatcher(['headers', 'form_params']))->once()->andReturn($response);
     $this->httpServer->setClient($client);
     $this->httpServer->rollback();
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $deployments = $this->fetchDeployments();
     $version = $this->argument('version');
     $deploymentName = $this->argument('deployment');
     $this->onStartCommand();
     foreach ($deployments as $section => $config) {
         if ($deploymentName != null && $deploymentName != $section) {
             continue;
         }
         $this->info("Rolling back {$section}");
         try {
             $server = new HttpServer($this->getLogger());
             $server->initialize($config);
             $response = $server->rollback($version);
             $this->info($response['success']);
         } catch (ServerException $e) {
             $this->error("Server error: " . $e->getMessage());
         }
     }
     $this->onEndCommand();
 }