Tests paragraphs with contact forms.
@group paragraphs
Expanded class hierarchy of ParagraphsContactTest
class ParagraphsContactTest extends ParagraphsTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = array(
'contact',
);
/**
* Tests adding paragraphs in contact forms.
*/
public function testContactForm() {
$this
->loginAsAdmin([
'administer contact forms',
'access site-wide contact form',
]);
// Add a paragraph type.
$this
->addParagraphsType('paragraphs_contact');
$this
->addParagraphsType('text');
// Create a contact form.
$contact_form = ContactForm::create([
'id' => 'test_contact_form',
'label' => 'Test form',
]);
$contact_form
->save();
// Add a paragraphs field to the contact form.
$this
->addParagraphsField($contact_form
->id(), 'paragraphs', 'contact_message');
// Add a paragraph to the contact form.
$this
->drupalGet('contact/test_contact_form');
$this
->submitForm([], 'paragraphs_paragraphs_contact_add_more');
// Check that the paragraph is displayed.
$this
->assertSession()
->pageTextContains('paragraphs_contact');
$this
->submitForm([], 'paragraphs_0_remove');
$elements = $this
->xpath('//table[starts-with(@id, :id)]/tbody', [
':id' => 'paragraphs-values',
]);
$header = $this
->xpath('//table[starts-with(@id, :id)]/thead', [
':id' => 'paragraphs-values',
]);
$this
->assertEquals($elements, []);
$this
->assertNotEquals($header, []);
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ParagraphsContactTest:: |
protected static | property |
Modules to enable. Overrides ParagraphsTestBase:: |
|
ParagraphsContactTest:: |
public | function | Tests adding paragraphs in contact forms. | |
ParagraphsTestBase:: |
protected | property | List of permissions used by loginAsAdmin(). | |
ParagraphsTestBase:: |
protected | property | Drupal user object created by loginAsAdmin(). | 1 |
ParagraphsTestBase:: |
protected | property | 2 | |
ParagraphsTestBase:: |
function | Creates an user with admin permissions and log in. | ||
ParagraphsTestBase:: |
protected | function |
Removes the default paragraph type. Overrides ParagraphsTestBase:: |
|
ParagraphsTestBase:: |
protected | function |
Sets the Paragraphs widget add mode. Overrides ParagraphsTestBase:: |
|
ParagraphsTestBase:: |
protected | function | Sets the allowed Paragraphs types that can be added. | |
ParagraphsTestBase:: |
protected | function | Sets the default paragraph type. | |
ParagraphsTestBase:: |
protected | function | Sets the weight of a given Paragraphs type. | |
ParagraphsTestBase:: |
protected | function | Sets the Paragraphs widget display mode. | |
ParagraphsTestBase:: |
protected | function | 19 | |
ParagraphsTestBaseTrait:: |
protected | property | The workflow entity. | |
ParagraphsTestBaseTrait:: |
protected | function | Adds a field to a given paragraph type. | |
ParagraphsTestBaseTrait:: |
protected | function | Adds a content type with a Paragraphs field. | |
ParagraphsTestBaseTrait:: |
protected | function | Adds a Paragraphs field to a given entity type. | |
ParagraphsTestBaseTrait:: |
protected | function | Adds a Paragraphs type. | |
ParagraphsTestBaseTrait:: |
protected | function | Adds an icon to a paragraphs type. | |
ParagraphsTestBaseTrait:: |
protected | function | Checks the core version. | |
ParagraphsTestBaseTrait:: |
protected | function | Creates a workflow entity. | |
ParagraphsTestBaseTrait:: |
protected | function | Sets some of the settings of a paragraphs field widget. |