public function ThunderParagraphsTestTrait::getParagraphDelta in Thunder 6.1.x
Same name and namespace in other branches
- 8.5 tests/src/FunctionalJavascript/ThunderParagraphsTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderParagraphsTestTrait::getParagraphDelta()
- 8.2 tests/src/FunctionalJavascript/ThunderParagraphsTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderParagraphsTestTrait::getParagraphDelta()
- 8.3 tests/src/FunctionalJavascript/ThunderParagraphsTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderParagraphsTestTrait::getParagraphDelta()
- 8.4 tests/src/FunctionalJavascript/ThunderParagraphsTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderParagraphsTestTrait::getParagraphDelta()
- 6.2.x tests/src/FunctionalJavascript/ThunderParagraphsTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderParagraphsTestTrait::getParagraphDelta()
- 6.0.x tests/src/FunctionalJavascript/ThunderParagraphsTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderParagraphsTestTrait::getParagraphDelta()
Get dalta of paragraph item for a given filed on a specific position.
Parameters
string $fieldName: Field name.
int $position: The Position of the paragraph item.
Return value
int The delta of the paragraph
Throws
\Exception
2 calls to ThunderParagraphsTestTrait::getParagraphDelta()
- ParagraphSplitTest::testAddParagraphAfterSplitDataLoss in tests/
src/ FunctionalJavascript/ Integration/ ParagraphSplitTest.php - Test if a adding paragraph after split leads to data loss.
- ThunderParagraphsTestTrait::addParagraph in tests/
src/ FunctionalJavascript/ ThunderParagraphsTestTrait.php - Add paragraph for field with defined paragraph type.
File
- tests/
src/ FunctionalJavascript/ ThunderParagraphsTestTrait.php, line 109
Class
- ThunderParagraphsTestTrait
- Trait for handling of Paragraph related test actions.
Namespace
Drupal\Tests\thunder\FunctionalJavascriptCode
public function getParagraphDelta($fieldName, $position) {
$fieldSelector = HTML::cleanCssIdentifier($fieldName);
// Retrieve new paragraphs delta from id attribute of the item.
$paragraphItem = $this
->getParagraphItems($fieldName)[$position];
$itemId = $paragraphItem
->getAttribute('id');
preg_match("/^edit-{$fieldSelector}-(\\d+)--/", $itemId, $matches);
if (!isset($matches[1])) {
throw new \Exception('No new paragraph is found');
}
return $matches[1];
}