You are here

public function AssertButtonsTrait::assertButtons in Support Ticketing System 8

Assert method to verify the buttons in the dropdown element.

Parameters

array $buttons: A collection of buttons to assert for on the page.

bool $dropbutton: Whether to check if the buttons are in a dropbutton widget or not.

1 call to AssertButtonsTrait::assertButtons()
SupportTicketFormButtonsTest::testSupportTicketFormButtons in modules/support_ticket/src/Tests/SupportTicketFormButtonsTest.php
Tests that the right buttons are displayed for saving support_tickets.

File

modules/support_ticket/src/Tests/AssertButtonsTrait.php, line 23
Contains \Drupal\support_ticket\Tests\AssertButtonsTrait.

Class

AssertButtonsTrait
Asserts that buttons are present on a page.

Namespace

Drupal\support_ticket\Tests

Code

public function assertButtons($buttons, $dropbutton = TRUE) {

  // Try to find a Save button.
  $save_button = $this
    ->xpath('//input[@type="submit"][@value="Save"]');

  // Verify that the number of buttons passed as parameters is
  // available in the dropbutton widget.
  if ($dropbutton) {
    $i = 0;
    $count = count($buttons);

    // Assert there is no save button.
    $this
      ->assertTrue(empty($save_button));

    // Dropbutton elements.
    $elements = $this
      ->xpath('//div[@class="dropbutton-wrapper"]//input[@type="submit"]');
    $this
      ->assertEqual($count, count($elements));
    foreach ($elements as $element) {
      $value = isset($element['value']) ? (string) $element['value'] : '';
      $this
        ->assertEqual($buttons[$i], $value);
      $i++;
    }
  }
  else {

    // Assert there is a save button.
    $this
      ->assertTrue(!empty($save_button));
    $this
      ->assertNoRaw('dropbutton-wrapper');
  }
}