Tests the anchor plugin.
@group paragraphs_collection_demo
Expanded class hierarchy of ParagraphsAnchorPluginTest
\Drupal\paragraphs_collection_demo\Plugin\paragraphs\Behavior\ParagraphsAnchorPlugin
class ParagraphsAnchorPluginTest extends ParagraphsTestBase {
/**
* Modules to be enabled.
*
* @var array
*/
protected static $modules = [
'paragraphs_collection_demo',
];
/**
* Tests the anchor plugin functionality.
*/
public function testAnchorPlugin() {
$this
->loginAsAdmin([
'edit behavior plugin settings',
]);
$this
->drupalGet('admin/structure/paragraphs_type/add');
$this
->assertSession()
->responseContains('Anchor');
$this
->assertSession()
->responseContains('Allows to set ID attribute that can be used as jump position in URLs.');
$paragraph_type = 'text_test';
$this
->addParagraphsType($paragraph_type);
$bundle_path = 'admin/structure/paragraphs_type/' . $paragraph_type;
$this
->fieldUIAddExistingField('admin/structure/paragraphs_type/' . $paragraph_type, 'paragraphs_text');
$this
->drupalGet($bundle_path);
$edit = [
'behavior_plugins[anchor][enabled]' => TRUE,
];
$this
->submitForm($edit, t('Save'));
$this
->addParagraphedContentType('paragraphed_test', 'text');
$this
->setParagraphsWidgetMode('paragraphed_test', 'text', 'closed');
$this
->loginAsAdmin([
'create paragraphed_test content',
'edit any paragraphed_test content',
'edit behavior plugin settings',
]);
$this
->drupalGet('node/add/paragraphed_test');
$this
->submitForm([], 'text_text_test_add_more');
$this
->assertSession()
->responseContains('Anchor');
$this
->assertSession()
->responseContains('Sets an ID attribute prefixed with "scrollto-" in the Paragraph so that it can be used as a jump-to link.');
$edit = [
'title[0][value]' => t('Anchor'),
'text[0][subform][paragraphs_text][0][value]' => t('Test Anchor'),
'text[0][behavior_plugins][anchor][anchor]' => 'element-anchor',
];
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->responseContains('id="scrollto-element-anchor"');
// Test settings summary.
$this
->clickLink('Edit');
$this
->assertSession()
->responseContains('<span class="summary-content">Test Anchor</span></div><div class="paragraphs-plugin-wrapper"><span class="summary-plugin"><span class="summary-plugin-label">Anchor</span>scrollto-element-anchor');
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ParagraphsAnchorPluginTest:: |
protected static | property |
Modules to be enabled. Overrides ParagraphsTestBase:: |
|
ParagraphsAnchorPluginTest:: |
public | function | Tests the anchor plugin functionality. | |
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. |