public function ParagraphsAddModesTest::testDefaultParagraphTypeWithSingleType in Paragraphs 8
Same name in this branch
- 8 tests/src/Functional/WidgetLegacy/ParagraphsAddModesTest.php \Drupal\Tests\paragraphs\Functional\WidgetLegacy\ParagraphsAddModesTest::testDefaultParagraphTypeWithSingleType()
- 8 tests/src/Functional/WidgetStable/ParagraphsAddModesTest.php \Drupal\Tests\paragraphs\Functional\WidgetStable\ParagraphsAddModesTest::testDefaultParagraphTypeWithSingleType()
Tests the default paragraph type behavior for a field with a single type.
File
- tests/
src/ Functional/ WidgetStable/ ParagraphsAddModesTest.php, line 203
Class
- ParagraphsAddModesTest
- Tests paragraphs add modes.
Namespace
Drupal\Tests\paragraphs\Functional\WidgetStableCode
public function testDefaultParagraphTypeWithSingleType() {
$this
->addParagraphedContentType('paragraphed_test', 'paragraphs');
$this
->loginAsAdmin([
'administer content types',
'administer node form display',
'edit any paragraphed_test content',
]);
// Add a Paragraphed test content.
$paragraphs_type_text = ParagraphsType::create([
'id' => 'text',
'label' => 'Text',
]);
$paragraphs_type_text
->save();
// Check that when only one paragraph type is allowed in a content type,
// one instance is automatically added in the 'Add content' dialogue.
$this
->drupalGet('node/add/paragraphed_test');
$elements = $this
->xpath('//table[@id="paragraphs-values"]/tbody');
$header = $this
->xpath('//table[@id="paragraphs-values"]/thead');
$this
->assertNotEquals($elements, []);
$this
->assertNotEquals($header, []);
// Check that no paragraph type is automatically added, if the defaut
// setting was set to '- None -'.
$this
->setDefaultParagraphType('paragraphed_test', 'paragraphs', 'paragraphs_settings_edit', '_none');
$this
->drupalGet('node/add/paragraphed_test');
$elements = $this
->xpath('//table[@id="paragraphs-values"]/tbody');
$header = $this
->xpath('//table[@id="paragraphs-values"]/thead');
$this
->assertEquals($elements, []);
$this
->assertNotEquals($header, []);
}