protected function LangCodeTest::setUp in Porter-Stemmer 8
Overrides BrowserTestBase::setUp
File
- tests/
src/ Functional/ LangCodeTest.php, line 80
Class
- LangCodeTest
- Tests that EN language search terms are stemmed and return stemmed content.
Namespace
Drupal\Tests\porterstemmer\FunctionalCode
protected function setUp() : void {
parent::setUp();
$this->testUser = $this
->drupalCreateUser([
'search content',
'access content',
'administer nodes',
'access site reports',
'use advanced search',
'administer languages',
'access administration pages',
'administer site configuration',
]);
$this
->drupalLogin($this->testUser);
// Create Basic page node types.
if ($this->profile != 'standard') {
$this
->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page',
]);
}
// Add a new language.
ConfigurableLanguage::createFromLangcode('fr')
->save();
// Make the body field translatable. The title is already translatable by
// definition.
$field_storage = FieldStorageConfig::loadByName('node', 'body');
$field_storage
->setTranslatable(TRUE);
$field_storage
->save();
// Create EN language nodes.
foreach ($this->testData as $title => $body) {
$info = [
'title' => $title . ' (EN)',
'body' => [
[
'value' => $body,
],
],
'type' => 'page',
'langcode' => 'en',
];
$this->nodes[$title] = $this
->drupalCreateNode($info);
}
// Create non-EN nodes.
foreach ($this->testData as $title => $body) {
$info = [
'title' => $title . ' (FR)',
'body' => [
[
'value' => $body,
],
],
'type' => 'page',
'langcode' => 'fr',
];
$this->nodes[$title] = $this
->drupalCreateNode($info);
}
// Create language-unspecified nodes.
foreach ($this->testData as $title => $body) {
$info = [
'title' => $title . ' (UND)',
'body' => [
[
'value' => $body,
],
],
'type' => 'page',
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
];
$this->nodes[$title] = $this
->drupalCreateNode($info);
}
// Run cron to ensure the content is indexed.
$this
->cronRun();
$this
->drupalGet('admin/reports/dblog');
$this
->assertText(t('Cron run completed'), 'Log shows cron run completed');
}