Pantheon\Terminus\Commands\Redis\DisableCommand::disable PHP Method

disable() public method

Disable Redis caching on a site
public disable ( string $site_id )
$site_id string Name of the site to disable Redis on
    public function disable($site_id)
    {
        $site = $this->getSite($site_id);
        $site->getRedis()->disable();
        $this->log()->notice('Redis disabled. Converging bindings.');
        $workflow = $site->converge();
        // Wait for the workflow to complete.
        while (!$workflow->checkProgress()) {
            // @TODO: Add Symfony progress bar to indicate that something is happening.
        }
        $this->log()->notice($workflow->getMessage());
    }

Usage Example

 /**
  * Tests the redis:disable command
  */
 public function testDisable()
 {
     $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->redis = $this->getMockBuilder(Redis::class)->disableOriginalConstructor()->getMock();
     $this->redis->expects($this->once())->method('disable');
     $this->site->expects($this->once())->method('converge')->willReturn($workflow);
     $this->site->method('getRedis')->willReturn($this->redis);
     $this->logger->expects($this->at(0))->method('log')->with($this->equalTo('notice'), $this->equalTo('Redis disabled. Converging bindings.'));
     $this->logger->expects($this->at(1))->method('log')->with($this->equalTo('notice'), $this->equalTo('successful workflow'));
     $command = new DisableCommand();
     $command->setSites($this->sites);
     $command->setLogger($this->logger);
     $command->disable('mysite');
 }
DisableCommand