Pantheon\Terminus\UnitTests\Commands\CommandTestCase::setUp PHP Method

setUp() protected method

protected setUp ( )
    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();
    }

Usage Example

Esempio n. 1
0
 /**
  * @inheritdoc
  */
 protected function setUp()
 {
     parent::setUp();
     $this->domains = $this->getMockBuilder(Domains::class)->disableOriginalConstructor()->getMock();
     $this->environment->method('getDomains')->willReturn($this->domains);
     $this->domain = $this->getMockBuilder(Domain::class)->disableOriginalConstructor()->getMock();
 }
All Usage Examples Of Pantheon\Terminus\UnitTests\Commands\CommandTestCase::setUp