protected function setUp()
{
if (!$this->config) {
$this->config = new Config();
}
if (!$this->container) {
$this->container = new Container();
}
// These are not used by every test but are useful for SiteAwareInterface commands. Which is a lot of them.
// Use `$command->setSites($this->site());` after you create your command to test.
$this->site = $this->getMockBuilder(Site::class)->disableOriginalConstructor()->getMock();
$this->environment = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
$this->environments = $this->getMockBuilder(Environments::class)->disableOriginalConstructor()->getMock();
$this->environments->method('get')->willReturn($this->environment);
$this->site->method('getEnvironments')->willReturn($this->environments);
$this->sites = $this->getMockBuilder(Sites::class)->disableOriginalConstructor()->getMock();
$this->sites->method('get')->willReturn($this->site);
// A lot of commands output to a logger.
// To use this call `$command->setLogger($this->logger);` after you create your command to test.
$this->logger = $this->getMockBuilder(NullLogger::class)->setMethods(array('log'))->getMock();
}