protected function LanguageNeutralAliasesTest::setUp in Language neutral aliases 8.2
Same name and namespace in other branches
- 3.x tests/src/Kernel/LanguageNeutralAliasesTest.php \Drupal\Tests\language_neutral_aliases\Kernel\LanguageNeutralAliasesTest::setUp()
Setup test.
Overrides KernelTestBase::setUp
File
- tests/
src/ Kernel/ LanguageNeutralAliasesTest.php, line 40
Class
- LanguageNeutralAliasesTest
- Test language neutral aliases.
Namespace
Drupal\Tests\language_neutral_aliases\KernelCode
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('path_alias');
$database = $this->container
->get('database');
// Create some test data.
$storage = $this->container
->get('entity_type.manager')
->getStorage('path_alias');
$paths = [
'/node/1' => '/path/first',
'/node/2' => '/path/second',
'/node/3' => '/path/third',
];
foreach ($paths as $path => $alias) {
$values = [
'path' => $path,
'alias' => $alias,
];
$alias = $storage
->create($values);
$storage
->save($alias);
}
// Change the language of some aliases.
$database
->update(self::TABLE)
->fields([
'langcode' => 'de',
])
->condition('path', '/node/1')
->execute();
$database
->update(self::TABLE)
->fields([
'langcode' => 'da',
])
->condition('path', '/node/2')
->execute();
$database
->update(self::TABLE . '_revision')
->fields([
'langcode' => 'de',
])
->condition('path', '/node/1')
->execute();
$database
->update(self::TABLE . '_revision')
->fields([
'langcode' => 'da',
])
->condition('path', '/node/2')
->execute();
}