test_support-1.0.x-dev/tests/src/Traits/Installs/InstallsViews.php
tests/src/Traits/Installs/InstallsViews.php
<?php
namespace Drupal\Tests\test_support\Traits\Installs;
use Drupal\Tests\test_support\Traits\Installs\Configuration\InstallConfiguration;
trait InstallsViews
{
use InstallConfiguration;
/** @var bool */
private $setupViewsDependencies = false;
/** @param string|string[] $views */
public function installViews($views): self
{
$this->setupViewsDependencies();
foreach ((array) $views as $view) {
$this->installExportedConfig('views.view.' . $view);
}
return $this;
}
private function setupViewsDependencies(): self
{
if ($this->setupViewsDependencies === false) {
$this->enableModules([
'system',
'user',
'views',
]);
$this->installEntitySchema('view');
$this->setupViewsDependencies = true;
}
return $this;
}
}
