X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fviews_ui%2Ftests%2Fsrc%2FFunctional%2FRowUITest.php;fp=web%2Fcore%2Fmodules%2Fviews_ui%2Ftests%2Fsrc%2FFunctional%2FRowUITest.php;h=8b256f4373eb391dbab9f29e3308e0d8f4d98cdf;hp=0000000000000000000000000000000000000000;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/views_ui/tests/src/Functional/RowUITest.php b/web/core/modules/views_ui/tests/src/Functional/RowUITest.php new file mode 100644 index 000000000..8b256f437 --- /dev/null +++ b/web/core/modules/views_ui/tests/src/Functional/RowUITest.php @@ -0,0 +1,82 @@ +drupalGet($row_plugin_url); + $this->assertFieldByName('row[type]', 'fields', 'The default row plugin selected in the UI should be fields.'); + + $edit = [ + 'row[type]' => 'test_row', + ]; + $this->drupalPostForm(NULL, $edit, t('Apply')); + $this->assertFieldByName('row_options[test_option]', NULL, 'Make sure the custom settings form from the test plugin appears.'); + $random_name = $this->randomMachineName(); + $edit = [ + 'row_options[test_option]' => $random_name, + ]; + $this->drupalPostForm(NULL, $edit, t('Apply')); + $this->drupalGet($row_options_url); + $this->assertFieldByName('row_options[test_option]', $random_name, 'Make sure the custom settings form field has the expected value stored.'); + + $this->drupalPostForm($view_edit_url, [], t('Save')); + $this->assertLink(t('Test row plugin'), 0, 'Make sure the test row plugin is shown in the UI'); + + $view = Views::getView($view_name); + $view->initDisplay(); + $row = $view->display_handler->getOption('row'); + $this->assertEqual($row['type'], 'test_row', 'Make sure that the test_row got saved as used row plugin.'); + $this->assertEqual($row['options']['test_option'], $random_name, 'Make sure that the custom settings field got saved as expected.'); + + $this->drupalPostForm($row_plugin_url, ['row[type]' => 'fields'], 'Apply'); + $this->drupalGet($row_plugin_url); + $this->assertResponse(200); + $this->assertFieldByName('row[type]', 'fields', 'Make sure that the fields got saved as used row plugin.'); + + // Ensure that entity row plugins appear. + $view_name = 'content'; + $row_plugin_url = "admin/structure/views/nojs/display/$view_name/default/row"; + $row_options_url = "admin/structure/views/nojs/display/$view_name/default/row_options"; + + $this->drupalGet($row_plugin_url); + $this->assertFieldByName('row[type]', 'entity:node'); + $this->drupalPostForm(NULL, ['row[type]' => 'entity:node'], t('Apply')); + $this->assertUrl($row_options_url); + $this->assertFieldByName('row_options[view_mode]', 'teaser'); + + // Change the teaser label to have markup so we can test escaping. + $teaser = EntityViewMode::load('node.teaser'); + $teaser->set('label', 'Teaser markup'); + $teaser->save(); + $this->drupalGet('admin/structure/views/view/frontpage/edit/default'); + $this->assertEscaped('Teaser markup'); + } + +}