protected function ParagraphsTranslationTest::assertParagraphsButtonsHelper

Same name in this branch
  1. 8.x-1.x paragraphs/tests/src/Functional/WidgetStable/ParagraphsTranslationTest.php \Drupal\Tests\paragraphs\Functional\WidgetStable\ParagraphsTranslationTest::assertParagraphsButtonsHelper()
  2. 8.x-1.x paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsTranslationTest.php \Drupal\Tests\paragraphs\Functional\WidgetLegacy\ParagraphsTranslationTest::assertParagraphsButtonsHelper()

Helper for assertParagraphsButtons and assertNoParagraphsButtons.

Parameters

int $count: Number of paragraphs buttons to look for.

bool $hidden: TRUE if these buttons should not be shown, FALSE otherwise. Defaults to TRUE.

2 calls to ParagraphsTranslationTest::assertParagraphsButtonsHelper()
ParagraphsTranslationTest::assertNoParagraphsButtons in paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsTranslationTest.php
Passes if the paragraphs buttons are NOT present.
ParagraphsTranslationTest::assertParagraphsButtons in paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsTranslationTest.php
Passes if the paragraphs buttons are present.

File

paragraphs/tests/src/Functional/WidgetLegacy/ParagraphsTranslationTest.php, line 793

Class

ParagraphsTranslationTest
Tests the configuration of paragraphs.

Namespace

Drupal\Tests\paragraphs\Functional\WidgetLegacy

Code

protected function assertParagraphsButtonsHelper($count, $hidden = TRUE) {
  for ($i = 0; $i < $count; $i++) {
    $remove_button = $this
      ->xpath('//*[@name="field_paragraphs_demo_' . $i . '_remove"]');
    if (!$hidden) {
      $this
        ->assertNotEquals(count($remove_button), 0);
    }
    else {
      $this
        ->assertEquals(count($remove_button), 0);
    }
  }

  // It is enough to check for the specific paragraph type 'Images' to assert
  // the add more buttons presence for this test class.
  $add_button = $this
    ->xpath('//input[@value="Add images"]');
  if (!$hidden) {
    $this
      ->assertNotEquals(count($add_button), 0);
  }
  else {
    $this
      ->assertEquals(count($add_button), 0);
  }
}