Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / views / tests / src / Functional / ViewsFormMultipleTest.php
1 <?php
2
3 namespace Drupal\Tests\views\Functional;
4
5 /**
6  * Tests a page with multiple Views forms.
7  *
8  * @group views
9  */
10 class ViewsFormMultipleTest extends ViewTestBase {
11
12   /**
13    * Views used by this test.
14    *
15    * @var array
16    */
17   public static $testViews = ['test_form_multiple'];
18
19   /**
20    * {@inheritdoc}
21    */
22   protected function setUp($import_test_views = TRUE) {
23     parent::setUp($import_test_views);
24
25     $this->enableViewsTestModule();
26   }
27
28   /**
29    * {@inheritdoc}
30    */
31   protected function viewsData() {
32     $data = parent::viewsData();
33     $data['views_test_data']['field_form_button_test']['field'] = [
34       'title' => t('Button test'),
35       'help' => t('Adds a test form button.'),
36       'id' => 'field_form_button_test',
37     ];
38     return $data;
39   }
40
41   /**
42    * Tests the a page with multiple View forms in it.
43    */
44   public function testViewsFormMultiple() {
45     // Get the test page.
46     $this->drupalGet('views_test_form_multiple');
47
48     $this->assertText('Test base form ID with Views forms and arguments.');
49
50     // Submit the forms, validate argument returned in message set by handler.
51     // @note There is not a way to specify a specific index for a submit button. So
52     // the row index returned is always the last occurrence.
53     $this->getSession()->getPage()->pressButton('edit-field-form-button-test-4--2');
54     $this->assertText('The test button at row 4 for test_form_multiple (default) View with args: arg2 was submitted.');
55     $this->getSession()->getPage()->pressButton('edit-field-form-button-test-4');
56     $this->assertText('The test button at row 4 for test_form_multiple (default) View with args: arg1 was submitted.');
57   }
58
59 }