Sets up unit test environment.
Unlike Drupal\simpletest\WebTestBase::setUp(), UnitTestBase::setUp() does not install modules because tests are performed without accessing the database. Any required files must be explicitly included by the child class setUp() method.
Overrides UnitTestBase::setUp
public function setUp() {
global $conf;
parent::setUp();
// Use a non-db cache backend, so that we can use DiscoveryTestBase (which
// extends UnitTestBase).
$conf['cache_classes'][$this->cacheBin] = 'Drupal\\Core\\Cache\\MemoryBackend';
// Create discovery objects to test.
$this->emptyDiscovery = new StaticDiscovery();
$this->emptyDiscovery = new CacheDecorator($this->emptyDiscovery, $this->cacheKey . '_empty', $this->cacheBin);
$this->discovery = new StaticDiscovery();
$this->discovery = new CacheDecorator($this->discovery, $this->cacheKey, $this->cacheBin);
// Populate sample definitions.
$this->expectedDefinitions = array(
'apple' => array(
'label' => 'Apple',
'color' => 'green',
),
'cherry' => array(
'label' => 'Cherry',
'color' => 'red',
),
'orange' => array(
'label' => 'Orange',
'color' => 'orange',
),
);
foreach ($this->expectedDefinitions as $plugin_id => $definition) {
$this->discovery
->setDefinition($plugin_id, $definition);
}
}