isSelected example

$this->drupalLogin($this->drupalCreateUser([
      'administer entity_test display',
    ]));
  }

  /** * Tests the use of regions for entity view displays. */
  public function testEntityView() {
    $this->drupalGet('entity_test/structure/entity_test/display');
    $this->assertSession()->elementExists('css', '.region-content-message.region-empty');
    $this->assertTrue($this->assertSession()->optionExists('fields[field_test_text][region]', 'hidden')->isSelected());

    $this->getSession()->getPage()->selectFieldOption('fields[field_test_text][region]', 'content');
    $this->assertTrue($this->assertSession()->optionExists('fields[field_test_text][region]', 'content')->isSelected());

    $this->submitForm([], 'Save');
    $this->assertSession()->pageTextContains('Your settings have been saved.');
    $this->assertTrue($this->assertSession()->optionExists('fields[field_test_text][region]', 'content')->isSelected());
  }

}
$this->drupalGet($fieldEditUrl);

    // Click on the widget settings button to open the widget settings form.     $this->submitForm([]$field_name . "_settings_edit");
    $this->assertSession()->elementExists('xpath', $xpathIncr);

    // Display creation form.     $this->drupalGet('entity_test/add');

    // Year element.     $this->assertSession()->elementExists('xpath', "//*[@id=\"edit-$field_name-0-value-year\"]");
    $this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-year", '')->isSelected());
    $this->assertSession()->optionExists("edit-$field_name-0-value-year", 'Year');
    // Month element.     $this->assertSession()->elementExists('xpath', "//*[@id=\"edit-$field_name-0-value-month\"]");
    $this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-month", '')->isSelected());
    $this->assertSession()->optionExists("edit-$field_name-0-value-month", 'Month');
    // Day element.     $this->assertSession()->elementExists('xpath', "//*[@id=\"edit-$field_name-0-value-day\"]");
    $this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-value-day", '')->isSelected());
    $this->assertSession()->optionExists("edit-$field_name-0-value-day", 'Day');
    // Hour element.     $this->assertSession()->elementExists('xpath', "//*[@id=\"edit-$field_name-0-value-hour\"]");
    


  /** * Tests the upgrade report with the view enabled, disabled and uninstalled. */
  public function testUpgradeReport() {
    $session = $this->assertSession();

    $this->assertTrue(View::load('watchdog')->status(), 'Watchdog view is enabled');
    // Tests redirection to report page when the watchdog view is enabled.     $this->drupalGet('admin/reports/upgrade');
    $session->optionExists('type[]', 'migrate_drupal_ui')->isSelected();
    $session->pageTextContainsOnce('A test message');

    // Disable the watchdog view.     $this->drupalGet('admin/structure/views');
    $this->assertTrue($this->clickViewsOperationsLink('Disable', '/watchdog/'));
    $session->statusCodeEquals(200);

    // Tests redirection to report page when the watchdog view is disabled.     $this->drupalGet('admin/reports/upgrade');
    $session->optionExists('type[]', 'migrate_drupal_ui')->isSelected();
    $session->pageTextContainsOnce('A test message');

    
    $this->assertSession()->elementNotExists('css', '.layout--twocol');
    $this->assertSession()->elementNotExists('css', '.layout__region');
    $this->assertSession()->pageTextNotContains('The field test text value');

    // After a refresh the new regions are still there.     $this->drupalGet('entity_test/structure/entity_test/display');
    $this->assertEquals(['Top', 'First', 'Second', 'Bottom', 'Disabled']$this->getRegionTitles());
    $this->assertSession()->waitForElement('css', '.tabledrag-handle');
    $id = $this->getSession()->getPage()->find('css', '[name="form_build_id"]')->getValue();

    // Drag the field to the first region.     $this->assertTrue($this->assertSession()->optionExists('fields[field_test_text][region]', 'hidden')->isSelected());
    $field_test_text_row = $this->getSession()->getPage()->find('css', '#field-test-text');
    $first_region_row = $this->getSession()->getPage()->find('css', '.region-first-message');
    $field_test_text_row->find('css', '.handle')->dragTo($first_region_row);
    $this->assertSession()->assertWaitOnAjaxRequest();
    $this->assertFalse($this->assertSession()->optionExists('fields[field_test_text][region]', 'hidden')->isSelected());
    $this->assertSession()->waitForElement('css', "[name='form_build_id']:not([value='$id'])");
    $this->submitForm([], 'Save');
    $this->assertSession()->pageTextContains('Your settings have been saved.');

    // The new layout is used.     $this->drupalGet('entity_test/1');
    
// Set language negotiation.     $edit = [
      'language_interface[enabled][language-url]' => TRUE,
    ];
    $this->drupalGet('admin/config/regional/language/detection');
    $this->submitForm($edit, 'Save settings');
    $this->assertSession()->pageTextContains('Language detection configuration saved.');

    // Check if the language selector is available on admin/people/create and     // set to the currently active language.     $this->drupalGet($langcode . '/admin/people/create');
    $this->assertTrue($this->assertSession()->optionExists("edit-preferred-langcode", $langcode)->isSelected());

    // Create a user with the admin/people/create form and check if the correct     // language is set.     $username = $this->randomMachineName(10);
    $edit = [
      'name' => $username,
      'mail' => $this->randomMachineName(4) . '@example.com',
      'pass[pass1]' => $username,
      'pass[pass2]' => $username,
    ];

    
// Click on the widget settings button to open the widget settings form.     $this->submitForm([]$field_name . "_settings_edit");
    $this->assertSession()->elementExists('xpath', $xpathIncr);

    // Display creation form.     $this->drupalGet('entity_test/add');

    foreach (['value', 'end-value'] as $column) {
      foreach (['year', 'month', 'day', 'hour', 'minute', 'ampm'] as $element) {
        $this->assertSession()->elementExists('xpath', "//*[@id=\"edit-$field_name-0-$column-$element\"]");
        $this->assertTrue($this->assertSession()->optionExists("edit-$field_name-0-$column-$element", '')->isSelected());
      }
    }

    // Submit a valid date and ensure it is accepted.     $start_date_value = ['year' => 2012, 'month' => 12, 'day' => 31, 'hour' => 5, 'minute' => 15];
    $end_date_value = ['year' => 2013, 'month' => 1, 'day' => 15, 'hour' => 3, 'minute' => 30];

    $edit = [];
    // Add the ampm indicator since we are testing 12 hour time.     $start_date_value['ampm'] = 'am';
    $end_date_value['ampm'] = 'pm';
    
$this->submitForm($edit, 'Apply');

        // Disable language content negotiation.         $edit = [
          'language_content[configurable]' => FALSE,
        ];
        $this->drupalGet('admin/config/regional/language/detection');
        $this->submitForm($edit, 'Save settings');

        // Check that the previous selection is listed and selected.         $this->drupalGet($langcode_url);
        $this->assertTrue($this->assertSession()->optionExists('edit-rendering-language', '***LANGUAGE_language_content***')->isSelected());

        // Check the order for the langcode filter.         $langcode_url = 'admin/structure/views/nojs/handler/' . $view_name . '/' . $display . '/filter/langcode';
        $this->drupalGet($langcode_url);
        $this->assertSession()->statusCodeEquals(200);

        $expected_elements = [
          'all',
          '***LANGUAGE_site_default***',
          '***LANGUAGE_language_interface***',
          '***LANGUAGE_language_content***',
          
$this->submitForm([
      'menu[type]' => 'normal',
      'menu[title]' => 'Secondary level view page',
      'menu[parent]' => $parent_menu_value,
    ], 'Apply');

    // Save view which has pending changes.     $this->submitForm([], 'Save');

    // Test if the node as parent menu item is selected in our views settings.     $this->drupalGet('admin/structure/views/nojs/display/test_menu_link/page_1/menu');
    $this->assertTrue($this->assertSession()->optionExists('edit-menu-parent', $parent_menu_value)->isSelected());

    $this->drupalGet('');

    // Test if the primary menu item (node) is visible, and the secondary menu     // item (view) is hidden.     $this->assertSession()->pageTextContains('Primary level node');
    $this->assertSession()->pageTextNotContains('Secondary level view page');

    // Go to the node page and ensure that both the first and second level items     // are visible.     $this->drupalGet($node->toUrl());
    
'langcode[0][value]' => 'aa',
    ];
    $this->submitForm($edit, 'Save');
    $terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadByProperties([
      'name' => $edit['name[0][value]'],
    ]);
    $term = reset($terms);
    $this->assertEquals($edit['langcode[0][value]']$term->language()->getId(), 'The term contains the correct langcode.');

    // Check if on the edit page the language is correct.     $this->drupalGet('taxonomy/term/' . $term->id() . '/edit');
    $this->assertTrue($this->assertSession()->optionExists('edit-langcode-0-value', $edit['langcode[0][value]'])->isSelected());

    // Change the language of the term.     $edit['langcode[0][value]'] = 'bb';
    $this->drupalGet('taxonomy/term/' . $term->id() . '/edit');
    $this->submitForm($edit, 'Save');

    // Check again that on the edit page the language is correct.     $this->drupalGet('taxonomy/term/' . $term->id() . '/edit');
    $this->assertTrue($this->assertSession()->optionExists('edit-langcode-0-value', $edit['langcode[0][value]'])->isSelected());
  }

  

  protected function verifyUnicornEditorConfiguration($format_id$ponies_too = TRUE) {
    $editor = editor_load($format_id);
    $settings = $editor->getSettings();
    $this->assertSame('unicorn', $editor->getEditor(), 'The text editor is configured correctly.');
    $this->assertSame($ponies_too$settings['ponies_too'], 'The text editor settings are stored correctly.');
    $this->drupalGet('admin/config/content/formats/manage/' . $format_id);
    $select = $this->assertSession()->selectExists('editor[editor]');
    $this->assertFalse($select->hasAttribute('disabled'));
    $options = $select->findAll('css', 'option');
    $this->assertCount(2, $options);
    $this->assertTrue($options[1]->isSelected(), 'Option 2 ("Unicorn Editor") is selected.');
  }

}
// Create the vocabulary.     $vid = mb_strtolower($this->randomMachineName());
    $edit['name'] = $this->randomMachineName();
    $edit['description'] = $this->randomMachineName();
    $edit['langcode'] = 'aa';
    $edit['vid'] = $vid;
    $this->submitForm($edit, 'Save');

    // Check the language on the edit page.     $this->drupalGet('admin/structure/taxonomy/manage/' . $vid);
    $this->assertTrue($this->assertSession()->optionExists('edit-langcode', $edit['langcode'])->isSelected());

    // Change the language and save again.     $edit['langcode'] = 'bb';
    unset($edit['vid']);
    $this->submitForm($edit, 'Save');

    // Check again the language on the edit page.     $this->drupalGet('admin/structure/taxonomy/manage/' . $vid);
    $this->assertTrue($this->assertSession()->optionExists('edit-langcode', $edit['langcode'])->isSelected());
  }

  
$this->drupalLogin($web_user);
  }

  /** * Tests the node type initial language defaults, and modifies them. * * The default initial language must be the site's default, and the language * locked option must be on. */
  public function testNodeTypeInitialLanguageDefaults() {
    $this->drupalGet('admin/structure/types/manage/article');
    $this->assertTrue($this->assertSession()->optionExists('edit-language-configuration-langcode', LanguageInterface::LANGCODE_SITE_DEFAULT)->isSelected());
    $this->assertSession()->checkboxNotChecked('edit-language-configuration-language-alterable');

    // Tests if the language field cannot be rearranged on the manage fields tab.     $this->drupalGet('admin/structure/types/manage/article/fields');
    $this->assertSession()->elementNotExists('xpath', '//*[@id="field-overview"]/*[@id="language"]');

    // Verify that language is not selectable on node add page by default.     $this->drupalGet('node/add/article');
    $this->assertSession()->fieldNotExists('langcode');

    // Adds a new language and set it as default.
// Move the test block to the header region.       $edit['blocks[' . $values['settings']['id'] . '][region]'] = 'header';
      // Look for a test block weight select form element.       $this->assertSession()->fieldExists('blocks[' . $values['settings']['id'] . '][weight]');
      // Change the test block's weight.       $edit['blocks[' . $values['settings']['id'] . '][weight]'] = $values['test_weight'];
    }
    $this->drupalGet('admin/structure/block');
    $this->submitForm($edit, 'Save blocks');
    foreach ($this->blockValues as $values) {
      // Check if the region and weight settings changes have persisted.       $this->assertTrue($this->assertSession()->optionExists('edit-blocks-' . $values['settings']['id'] . '-region', 'header')->isSelected());
      $this->assertTrue($this->assertSession()->optionExists('edit-blocks-' . $values['settings']['id'] . '-weight', $values['test_weight'])->isSelected());
    }

    // Add a block with a machine name the same as a region name.     $this->drupalPlaceBlock('system_powered_by_block', ['region' => 'header', 'id' => 'header']);
    $this->drupalGet('admin/structure/block');
    $this->assertSession()->elementExists('xpath', '//tr[contains(@class, "region-title-header")]');

    // Ensure hidden themes do not appear in the UI. Enable another non base     // theme and place the local tasks block.     $this->assertTrue(\Drupal::service('theme_handler')->themeExists('stark'), 'The stark base theme is enabled');
    


  /** * Verifies plugin-supplied settings form. */
  public function testSearchModuleSettingsPage() {
    $this->drupalGet('admin/config/search/pages');
    $this->clickLink('Edit', 1);

    // Ensure that the default setting was picked up from the default config     $this->assertTrue($this->assertSession()->optionExists('edit-extra-type-settings-boost', 'bi')->isSelected());

    // Change extra type setting and also modify a common search setting.     $edit = [
      'extra_type_settings[boost]' => 'ii',
    ];
    $this->submitForm($edit, 'Save search page');

    // Ensure that the modifications took effect.     $this->assertSession()->statusMessageContains("The Dummy search type search page has been updated.", 'status');
    $this->drupalGet('admin/config/search/pages/manage/dummy_search_type');
    $this->assertTrue($this->assertSession()->optionExists('edit-extra-type-settings-boost', 'ii')->isSelected());
  }
$this->drupalGet('');
    $session = $this->getSession();

    // Select first option and trigger ajax update.     $session->getPage()->selectFieldOption('edit-test1', 'option1');

    // DOM update: The InsertCommand in the AJAX response changes the text     // in the option element to 'Option1!!!'.     $opt1_selector = $this->assertSession()->waitForElement('css', "select[data-drupal-selector='edit-test1'] option:contains('Option 1!!!')");
    $this->assertNotEmpty($opt1_selector);
    $this->assertTrue($opt1_selector->isSelected());

    // Confirm option 3 exists.     $page = $session->getPage();
    $opt3_selector = $page->find('xpath', '//select[@data-drupal-selector="edit-test1"]//option[@value="option3"]');
    $this->assertNotEmpty($opt3_selector);

    // Confirm success message appears after a submit.     $page->findButton('edit-submit')->click();
    $this->assertSession()->waitForButton('edit-submit');
    $updated_page = $session->getPage();
    $updated_page->hasContent('Submission successful.');
  }
Home | Imprint | This part of the site doesn't use cookies.