randomView example

$view = Views::getView('test_attachment_ui');
    $view->initDisplay();
    $this->assertEquals(['default', 'page_1']array_keys($view->displayHandlers->get('attachment_1')->getOption('displays')), 'The attached displays got saved as expected');
  }

  /** * Tests the attachment working after the attached page was deleted. */
  public function testRemoveAttachedDisplay() {
    // Create a view.     $view = $this->randomView();
    $path_prefix = 'admin/structure/views/view/' . $view['id'] . '/edit';
    $attachment_display_url = 'admin/structure/views/nojs/display/' . $view['id'] . '/attachment_1/displays';

    // Open the Page display and create the attachment display.     $this->drupalGet($path_prefix . '/page_1');
    $this->submitForm([], 'Add Attachment');
    $this->assertSession()->pageTextContains('Not defined');

    // Attach the Attachment to the Page display.     $this->drupalGet($attachment_display_url);
    $this->submitForm(['displays[page_1]' => 1], 'Apply');
    

  protected $defaultTheme = 'stark';

  /** * Tests that the right tokens are shown as available for replacement. */
  public function testTokenUI() {
    $entity_test = EntityTest::create(['bundle' => 'entity_test']);
    $entity_test->save();

    $default = $this->randomView([]);
    $id = $default['id'];
    $view = View::load($id);

    $this->drupalGet($view->toUrl('edit-form'));

    // Add a global NULL argument to the view for testing argument tokens.     $this->drupalGet("admin/structure/views/nojs/add-handler/{$id}/page_1/argument");
    $this->submitForm(['name[views.null]' => 1], 'Add and configure contextual filters');
    $this->submitForm([], 'Apply');

    $this->drupalGet("admin/structure/views/nojs/add-handler/{$id}/page_1/header");
    

  protected $defaultTheme = 'stark';

  /** * Tests adding a display. */
  public function testAddDisplay() {
    // Show the default display.     $this->config('views.settings')->set('ui.show.default_display', TRUE)->save();

    $settings['page[create]'] = FALSE;
    $view = $this->randomView($settings);

    $path_prefix = 'admin/structure/views/view/' . $view['id'] . '/edit';
    $this->drupalGet($path_prefix);

    // Add a new display.     $this->submitForm([], 'Add Page');
    $this->assertSession()->linkByHrefExists($path_prefix . '/page_1', 0, 'Make sure after adding a display the new display appears in the UI');

    $this->assertSession()->linkNotExists('Default*', 'Make sure the default display is not marked as changed.');
    $this->assertSession()->linkExists('Page*', 0, 'Make sure the added display is marked as changed.');

    
protected static $modules = ['contextual'];

  /** * {@inheritdoc} */
  protected $defaultTheme = 'stark';

  /** * Tests adding a display. */
  public function testAddDisplay() {
    $view = $this->randomView();
    $this->assertSession()->elementNotExists('xpath', '//li[@data-drupal-selector="edit-displays-top-tabs-block-1"]');
    $this->assertSession()->elementNotExists('xpath', '//li[@data-drupal-selector="edit-displays-top-tabs-block-2"]');
    $this->assertSession()->pageTextMatchesCount(0, '/Block name:/');

    $this->submitForm([], 'Add Block');
    $this->assertSession()->elementTextContains('xpath', '//li[@data-drupal-selector="edit-displays-top-tabs-block-1"]', 'Block*');
    $this->assertSession()->elementNotExists('xpath', '//li[@data-drupal-selector="edit-displays-top-tabs-block-2"]');
    $this->assertSession()->pageTextMatchesCount(1, '/Block name:/');
  }

  /** * Tests reordering of displays. */

  protected $defaultTheme = 'stark';

  public function testUI() {
    // Set up a block and an entity_test entity.     $block = Block::create(['id' => 'test_id', 'plugin' => 'system_main_block']);
    $block->save();

    $entity_test = EntityTest::create(['bundle' => 'entity_test']);
    $entity_test->save();

    $default = $this->randomView([]);
    $id = $default['id'];
    $view = View::load($id);

    $this->drupalGet($view->toUrl('edit-form'));

    // Add a global NULL argument to the view for testing argument placeholders.     $this->drupalGet("admin/structure/views/nojs/add-handler/{$id}/page_1/argument");
    $this->submitForm(['name[views.null]' => TRUE], 'Add and configure contextual filters');
    $this->submitForm([], 'Apply');

    // Configure both the entity_test area header and the block header to
// Click the Expose sort button.     $edit = [];
    $this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/sort/created');
    $this->submitForm($edit, 'Expose sort');
    // Check the label of the expose button.     $this->helperButtonHasLabel('edit-options-expose-button-button', 'Hide sort');
    $this->assertSession()->fieldValueEquals('edit-options-expose-label', 'Authored on');
    $this->assertSession()->fieldValueEquals('Sort field identifier', 'created');

    // Test adding a new exposed sort criteria.     $view_id = $this->randomView()['id'];
    $this->drupalGet("admin/structure/views/nojs/add-handler/$view_id/default/sort");
    $this->submitForm(['name[node_field_data.created]' => 1], 'Add and configure sort criteria');
    $this->assertSession()->fieldValueEquals('options[order]', 'ASC');
    // Change the order and expose the sort.     $this->submitForm(['options[order]' => 'DESC'], 'Apply');
    $this->drupalGet("admin/structure/views/nojs/handler/{$view_id}/default/sort/created");
    $this->submitForm([], 'Expose sort');
    $this->assertSession()->fieldValueEquals('options[order]', 'DESC');
    $this->assertSession()->fieldValueEquals('options[expose][label]', 'Authored on');
    $this->assertSession()->fieldValueEquals('Sort field identifier', 'created');

    
parent::setUp($import_test_views$modules);

    $this->placeBlock('page_title_block');
  }

  /** * Checks if duplicated view exists and has correct label. */
  public function testDuplicateView() {

    // Create random view.     $random_view = $this->randomView();

    // Initialize array for duplicated view.     $view = [];

    // Generate random label and id for new view.     $view['label'] = $this->randomMachineName(255);
    $view['id'] = strtolower($this->randomMachineName(128));

    // Duplicate view.     $this->drupalGet('admin/structure/views/view/' . $random_view['id'] . '/duplicate');
    $this->submitForm($view, 'Duplicate');

    
Home | Imprint | This part of the site doesn't use cookies.