AllowedLanguagesKernelTestBase.php in Allowed Languages 8
File
tests/src/Kernel/AllowedLanguagesKernelTestBase.php
View source
<?php
namespace Drupal\Tests\allowed_languages\Kernel;
use Drupal\KernelTests\KernelTestBase;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\user\Entity\User;
class AllowedLanguagesKernelTestBase extends KernelTestBase {
public static $modules = [
'allowed_languages',
'content_translation',
'field',
'language',
'user',
'system',
];
protected $user;
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('user');
$this->user = User::create([
'uid' => 1,
'name' => $this
->randomString(),
]);
$this->user
->save();
$sv = ConfigurableLanguage::create([
'label' => 'Swedish',
'id' => 'sv',
]);
$en = ConfigurableLanguage::create([
'label' => 'English',
'id' => 'en',
]);
$sv
->save();
$en
->save();
$this->user
->set('allowed_languages', [
$sv,
$en,
]);
}
}