protected function PrivateFileOnTranslatedEntityTest::setUp in Drupal 8
Same name and namespace in other branches
- 9 core/modules/file/tests/src/Functional/PrivateFileOnTranslatedEntityTest.php \Drupal\Tests\file\Functional\PrivateFileOnTranslatedEntityTest::setUp()
Overrides FileFieldTestBase::setUp
File
- core/
modules/ file/ tests/ src/ Functional/ PrivateFileOnTranslatedEntityTest.php, line 35
Class
- PrivateFileOnTranslatedEntityTest
- Uploads private files to translated node and checks access.
Namespace
Drupal\Tests\file\FunctionalCode
protected function setUp() {
parent::setUp();
// Create the "Basic page" node type.
$this
->drupalCreateContentType([
'type' => 'page',
'name' => 'Basic page',
]);
// Create a file field on the "Basic page" node type.
$this->fieldName = strtolower($this
->randomMachineName());
$this
->createFileField($this->fieldName, 'node', 'page', [
'uri_scheme' => 'private',
]);
// Create and log in user.
$permissions = [
'access administration pages',
'administer content translation',
'administer content types',
'administer languages',
'create content translations',
'create page content',
'edit any page content',
'translate any entity',
];
$admin_user = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($admin_user);
// Add a second language.
$edit = [];
$edit['predefined_langcode'] = 'fr';
$this
->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Enable translation for "Basic page" nodes.
$edit = [
'entity_types[node]' => 1,
'settings[node][page][translatable]' => 1,
"settings[node][page][fields][{$this->fieldName}]" => 1,
];
$this
->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
}