コード例 #1
0
 public function testStatus()
 {
     $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=status'), new PayloadMatcher(['headers', 'form_params']))->once()->andReturn($response);
     $this->httpServer->setClient($client);
     $this->httpServer->status();
 }
コード例 #2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $deployments = $this->fetchDeployments();
     $deploymentName = $this->argument('deployment');
     $time = time();
     $this->info("Started at " . date('[Y-m-d H:i:s]'));
     $this->info("Config file is " . $this->argument('config'));
     $logger = new OutputLogger($this->output);
     foreach ($deployments as $section => $config) {
         if ($deploymentName != null && $deploymentName != $section) {
             continue;
         }
         $this->info("Getting the status of {$section}");
         try {
             $server = new HttpServer($logger);
             $server->initialize($config);
             $data = $server->status();
             $this->info("Current version: " . $data['currentVersion']);
             $this->info("Old versions: " . implode(', ', $data['oldVersions']));
         } catch (ServerException $e) {
             $this->error("Server error: " . $e->getMessage());
         }
     }
     $time = time() - $time;
     $this->info("Finished at " . date('[Y-m-d H:i:s]') . " (in {$time} seconds)");
 }
コード例 #3
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $deployments = $this->fetchDeployments();
     $deploymentName = $this->argument('deployment');
     $this->onStartCommand();
     foreach ($deployments as $section => $config) {
         if ($deploymentName != null && $deploymentName != $section) {
             continue;
         }
         $this->info("Getting the status of {$section}");
         try {
             $server = new HttpServer($this->getLogger());
             $server->initialize($config);
             $data = $server->status();
             $this->info("Current version: " . $data['currentVersion']);
             $this->info("Old versions: " . implode(', ', $data['oldVersions']));
         } catch (ServerException $e) {
             $this->error("Server error: " . $e->getMessage());
         }
     }
     $this->onEndCommand();
 }