3 namespace Drupal\node\Tests;
5 @trigger_error('\Drupal\Tests\node\Functional\AssertButtonsTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\node\Functional\AssertButtonsTrait', E_USER_DEPRECATED);
8 * Asserts that buttons are present on a page.
10 * @deprecated Scheduled for removal before Drupal 9.0.0.
11 * Use \Drupal\Tests\node\Functional\AssertButtonsTrait instead.
13 trait AssertButtonsTrait {
16 * Assert method to verify the buttons in the dropdown element.
18 * @param array $buttons
19 * A collection of buttons to assert for on the page.
20 * @param bool $dropbutton
21 * Whether to check if the buttons are in a dropbutton widget or not.
23 public function assertButtons($buttons, $dropbutton = TRUE) {
25 // Try to find a Save button.
26 $save_button = $this->xpath('//input[@type="submit"][@value="Save"]');
28 // Verify that the number of buttons passed as parameters is
29 // available in the dropbutton widget.
32 $count = count($buttons);
34 // Assert there is no save button.
35 $this->assertTrue(empty($save_button));
37 // Dropbutton elements.
38 $elements = $this->xpath('//div[@class="dropbutton-wrapper"]//input[@type="submit"]');
39 $this->assertEqual($count, count($elements));
40 foreach ($elements as $element) {
41 $value = isset($element['value']) ? (string) $element['value'] : '';
42 $this->assertEqual($buttons[$i], $value);
47 // Assert there is a save button.
48 $this->assertTrue(!empty($save_button));
49 $this->assertNoRaw('dropbutton-wrapper');