You are here

protected function ViewsXMLBackendBase::addMinimalXMLBackendView in Views XML Backend 8

Adds and verifies that a new Views XML Backend View can be created.

2 calls to ViewsXMLBackendBase::addMinimalXMLBackendView()
ViewsXMLBackendAddTest::testAddMinimalViewViewsXMLBackend in src/Tests/ViewsXMLBackendAddTest.php
Tests new Views XML Backend View can be created.
ViewsXMLBackendBase::addStandardXMLBackendView in src/Tests/ViewsXMLBackendBase.php
Adds and verifies that a new Views XML Backend View can be created and specific basic Views XML Backend settings can be set.

File

src/Tests/ViewsXMLBackendBase.php, line 180
Contains \Drupal\views_xml_backend\Tests\ViewsXMLBackendBase.

Class

ViewsXMLBackendBase
Provides supporting functions for testing the Views XML Backend module.

Namespace

Drupal\views_xml_backend\Tests

Code

protected function addMinimalXMLBackendView() {

  /*
   * NOTE: To save a test view $strictConfigSchema must be set to FALSE.
   * @see https://www.drupal.org/node/2679725
   */

  // Setup consistent test variables to use throughout new test View.
  $this
    ->setUpViewsVariables();
  $default = [
    $this->viewsXMLBackendViewFieldName => $this->viewsXMLBackendViewValue,
  ];
  $this
    ->drupalPostAjaxForm($this->viewsXMLBackendViewAddPath, $default, $this->viewsXMLBackendViewFieldName);

  // Confirm standard:views_xml_backend was selected in show[wizard_key] select
  $new_id = $this
    ->xpath("//*[starts-with(@id, 'edit-show-wizard-key')]/@id");
  $new_wizard_id = (string) $new_id[0]['id'];
  $this
    ->assertOptionSelected($new_wizard_id, $this->viewsXMLBackendViewValue, "The XML select option 'standard:views_xml_backend' was selected on {$new_wizard_id}");

  // Save the new test View.
  $default = [
    'label' => $this->viewsXMLBackendTitle,
    'id' => $this->viewsXMLBackendViewId,
    'description' => $this
      ->randomMachineName(16),
    $this->viewsXMLBackendViewFieldName => $this->viewsXMLBackendViewValue,
  ];
  $this
    ->drupalPostForm($this->viewsXMLBackendViewAddPath, $default, t('Save and edit'));

  // Confirm new view is saved.
  $this
    ->assertText("The view {$this->viewsXMLBackendTitle} has been saved");
}