SystemListTest.php in Drupal 8
File
core/tests/Drupal/KernelTests/Core/Theme/SystemListTest.php
View source
<?php
namespace Drupal\KernelTests\Core\Theme;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Routing\NullMatcherDumper;
use Drupal\KernelTests\KernelTestBase;
class SystemListTest extends KernelTestBase {
public static $modules = [
'system',
];
public function register(ContainerBuilder $container) {
parent::register($container);
$container
->register('router.dumper', NullMatcherDumper::class);
}
protected function setUp() {
parent::setUp();
$this
->installConfig([
'system',
]);
}
public function testSystemList() {
$this
->assertEmpty(system_list('theme'));
$this
->assertEmpty(system_list('filepaths'));
$this->container
->get('theme_installer')
->install([
'test_basetheme',
]);
$themes = system_list('theme');
$this
->assertTrue(isset($themes['test_basetheme']));
$this
->assertEqual($themes['test_basetheme']
->getName(), 'test_basetheme');
$filepaths = system_list('filepaths');
$this
->assertEquals('test_basetheme', $filepaths[0]['name']);
$this
->assertEquals('core/modules/system/tests/themes/test_basetheme/test_basetheme.info.yml', $filepaths[0]['filepath']);
$this
->assertCount(1, $filepaths);
$this->container
->get('theme_installer')
->uninstall([
'test_basetheme',
]);
$this
->assertEmpty(system_list('theme'));
$this
->assertEmpty(system_list('filepaths'));
system_list_reset();
}
}