public function ParagraphsWidgetButtonsTest::checkParagraphInMode in Paragraphs 8
Asserts that a paragraph is in a particular mode.
It does this indirectly by checking checking what buttons are available.
Parameters
string $button_prefix: An initial part of the button name; namely "<paragraphs_field>_<delta>".
string $mode: Assert that the paragraphs is in this widget item mode. Supported modes are "edit", "closed" and "removed". A paragraph in the "removed" mode cannot be distinguished from one that has never been added.
3 calls to ParagraphsWidgetButtonsTest::checkParagraphInMode()
- ParagraphsWidgetButtonsTest::testAutocollapse in tests/
src/ Functional/ ParagraphsWidgetButtonsTest.php - Tests the autocollapse functionality.
- ParagraphsWidgetButtonsTest::testClosedExtendNestedEditMode in tests/
src/ Functional/ ParagraphsWidgetButtonsTest.php - Tests the "Closed, show nested" edit mode.
- ParagraphsWidgetButtonsTest::testClosedModeThreshold in tests/
src/ Functional/ ParagraphsWidgetButtonsTest.php - Tests the closed mode threshold.
File
- tests/
src/ Functional/ ParagraphsWidgetButtonsTest.php, line 522
Class
- ParagraphsWidgetButtonsTest
- Tests paragraphs stable widget buttons.
Namespace
Drupal\Tests\paragraphs\FunctionalCode
public function checkParagraphInMode($button_prefix, $mode) {
switch ($mode) {
case 'edit':
$this
->assertSession()
->buttonNotExists($button_prefix . '_edit');
$this
->assertSession()
->buttonExists($button_prefix . '_collapse');
break;
case 'closed':
$this
->assertSession()
->buttonExists($button_prefix . '_edit');
$this
->assertSession()
->buttonNotExists($button_prefix . '_collapse');
break;
case 'removed':
$this
->assertSession()
->buttonNotExists($button_prefix . '_edit');
$this
->assertSession()
->buttonNotExists($button_prefix . '_collapse');
break;
default:
throw new \InvalidArgumentException('This function does not support "' . $mode . '" as an argument for "$mode" parameter');
}
}