protected function ParagraphsAccessTest::setUp in Paragraphs 8
Same name in this branch
- 8 tests/src/Functional/WidgetLegacy/ParagraphsAccessTest.php \Drupal\Tests\paragraphs\Functional\WidgetLegacy\ParagraphsAccessTest::setUp()
- 8 tests/src/Functional/WidgetStable/ParagraphsAccessTest.php \Drupal\Tests\paragraphs\Functional\WidgetStable\ParagraphsAccessTest::setUp()
Overrides ParagraphsTestBase::setUp
File
- tests/
src/ Functional/ WidgetStable/ ParagraphsAccessTest.php, line 40
Class
- ParagraphsAccessTest
- Tests the access check of paragraphs.
Namespace
Drupal\Tests\paragraphs\Functional\WidgetStableCode
protected function setUp() : void {
parent::setUp();
ConfigurableLanguage::create([
'id' => 'de',
'label' => '1German',
])
->save();
ConfigurableLanguage::create([
'id' => 'fr',
'label' => '2French',
])
->save();
$this
->addParagraphedContentType('paragraphed_content_demo', 'field_paragraphs_demo');
$this
->loginAsAdmin([
'administer site configuration',
'administer content translation',
'administer languages',
]);
$this
->addParagraphsType('nested_paragraph');
$this
->addParagraphsField('nested_paragraph', 'field_paragraphs_demo', 'paragraph');
$this
->addParagraphsType('images');
static::fieldUIAddNewField('admin/structure/paragraphs_type/images', 'images_demo', 'Images', 'image', [
'cardinality' => -1,
], [
'settings[alt_field]' => FALSE,
]);
$this
->addParagraphsType('text_image');
static::fieldUIAddNewField('admin/structure/paragraphs_type/text_image', 'image_demo', 'Images', 'image', [
'cardinality' => -1,
], [
'settings[alt_field]' => FALSE,
]);
static::fieldUIAddNewField('admin/structure/paragraphs_type/text_image', 'text_demo', 'Text', 'text_long', [], []);
$this
->addParagraphsType('text');
static::fieldUIAddExistingField('admin/structure/paragraphs_type/text', 'field_text_demo', 'Text', []);
$edit = [
'entity_types[node]' => TRUE,
'entity_types[paragraph]' => TRUE,
'settings[node][paragraphed_content_demo][translatable]' => TRUE,
'settings[node][paragraphed_content_demo][fields][field_paragraphs_demo]' => FALSE,
'settings[paragraph][images][translatable]' => TRUE,
'settings[paragraph][text_image][translatable]' => TRUE,
'settings[paragraph][text][translatable]' => TRUE,
'settings[paragraph][nested_paragraph][translatable]' => TRUE,
'settings[paragraph][nested_paragraph][fields][field_paragraphs_demo]' => FALSE,
'settings[paragraph][nested_paragraph][settings][language][language_alterable]' => TRUE,
'settings[paragraph][images][fields][field_images_demo]' => TRUE,
'settings[paragraph][text_image][fields][field_image_demo]' => TRUE,
'settings[paragraph][text_image][fields][field_text_demo]' => TRUE,
'settings[node][paragraphed_content_demo][settings][language][language_alterable]' => TRUE,
];
$this
->drupalGet('admin/config/regional/content-language');
$this
->submitForm($edit, 'Save configuration');
$view_display = \Drupal::service('entity_display.repository')
->getViewDisplay('paragraph', 'images');
$view_display
->setComponent('field_images_demo', [
'settings' => [
'image_style' => 'medium',
],
]);
$view_display
->save();
}