public function ComponentsInfoTest::setUp in Components! 8.2
Overrides UnitTestCase::setUp
File
- tests/
src/ Unit/ ComponentsInfoTest.php, line 60
Class
- ComponentsInfoTest
- @coversDefaultClass \Drupal\components\Template\ComponentsInfo @group components
Namespace
Drupal\Tests\components\UnitCode
public function setUp() {
parent::setUp();
// Prevent test failures due to constants used in ModuleExtensionList.
if (!defined('DRUPAL_MINIMUM_PHP')) {
define('DRUPAL_MINIMUM_PHP', '7.0.8');
}
$this->moduleExtensionList = $this
->createMock('\\Drupal\\Core\\Extension\\ModuleExtensionList');
$this->themeExtensionList = $this
->createMock('\\Drupal\\Core\\Extension\\ThemeExtensionList');
$this->rootDir = '/drupal';
$this->modulesDir = '/drupal/modules';
$this->themesDir = '/drupal/themes';
// Ensure \Drupal::root() is available.
$container = new ContainerBuilder();
// Mock Drupal 8 Drupal::root().
$container
->set('app.root', $this->rootDir);
// Mock Drupal 9 Drupal::root().
$container
->setParameter('app.root', $this->rootDir);
// Mock LoggerChannelTrait.
$loggerFactory = $this
->createMock('\\Drupal\\Core\\Logger\\LoggerChannelFactory');
$loggerFactory
->method('get')
->willReturn($this
->createMock('\\Drupal\\Core\\Logger\\LoggerChannel'));
$container
->set('logger.factory', $loggerFactory);
\Drupal::setContainer($container);
}