LanguageTestBase.php in Drupal 10
File
core/modules/language/tests/src/Kernel/Views/LanguageTestBase.php
View source
<?php
namespace Drupal\Tests\language\Kernel\Views;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
abstract class LanguageTestBase extends ViewsKernelTestBase {
protected static $modules = [
'system',
'language',
];
protected function setUp($import_test_views = TRUE) : void {
parent::setUp();
$this
->installConfig([
'language',
]);
ConfigurableLanguage::create([
'id' => 'xx-lolspeak',
'label' => 'Lolspeak',
])
->save();
}
protected function schemaDefinition() {
$schema = parent::schemaDefinition();
$schema['views_test_data']['fields']['langcode'] = [
'description' => 'The {language}.langcode of this beatle.',
'type' => 'varchar',
'length' => 12,
'default' => '',
];
return $schema;
}
protected function viewsData() {
$data = parent::viewsData();
$data['views_test_data']['langcode'] = [
'title' => t('Langcode'),
'help' => t('Langcode'),
'field' => [
'id' => 'language',
],
'argument' => [
'id' => 'language',
],
'filter' => [
'id' => 'language',
],
];
return $data;
}
protected function dataSet() {
$data = parent::dataSet();
$data[0]['langcode'] = 'en';
$data[1]['langcode'] = 'xx-lolspeak';
$data[2]['langcode'] = '';
$data[3]['langcode'] = '';
$data[4]['langcode'] = '';
return $data;
}
}