Pantheon\Terminus\Commands\ServiceLevel\SetCommand::set PHP Method

set() public method

Set a site's service level
public set ( string $site_id, string $level )
$site_id string The name of the site to set the service level of
$level string [free|basic|pro|business] The service level to set the site to
    public function set($site_id, $level)
    {
        $site = $this->getSite($site_id);
        $workflow = $site->updateServiceLevel($level);
        $this->log()->notice('Setting plan of "{site_id}" to "{level}".', compact('site_id', 'level'));
        while (!$workflow->checkProgress()) {
            // @TODO: Add Symfony progress bar to indicate that something is happening.
        }
        $this->log()->notice($workflow->getMessage());
    }

Usage Example

 /**
  * Tests the service-level:set command
  */
 public function testServiceLevelSet()
 {
     $workflow = $this->getMockBuilder(Workflow::class)->disableOriginalConstructor()->getMock();
     // workflow succeeded
     $workflow->expects($this->once())->method('checkProgress')->willReturn(true);
     $workflow->expects($this->once())->method('getMessage')->willReturn('successful workflow');
     $this->logger->expects($this->at(0))->method('log')->with($this->equalTo('notice'), $this->equalTo('Setting plan of "{site_id}" to "{level}".'), $this->equalTo(['site_id' => 'my-site', 'level' => 'free']));
     $this->logger->expects($this->at(1))->method('log')->with($this->equalTo('notice'), $this->equalTo('successful workflow'));
     $this->site->expects($this->once())->method('updateServiceLevel')->with('free')->willReturn($workflow);
     $command = new SetCommand();
     $command->setSites($this->sites);
     $command->setLogger($this->logger);
     $command->set('my-site', 'free');
 }
SetCommand