isChecked example

$this->assertSelectedMediaCount('1 of 2 items selected');
    $assert_session->hiddenFieldValueEquals('media-library-modal-selection', '3');
    // Assert deselected items are available again.     $this->assertFalse($checkboxes[2]->hasAttribute('disabled'));
    $this->assertFalse($checkboxes[3]->hasAttribute('disabled'));
    // The selection should be persisted when navigating to other media types in     // the modal.     $this->switchToMediaType('Three');
    $this->switchToMediaType('One');
    $selected_checkboxes = [];
    foreach ($this->getCheckboxes() as $checkbox) {
      if ($checkbox->isChecked()) {
        $selected_checkboxes[] = $checkbox->getValue();
      }
    }
    $this->assertCount(1, $selected_checkboxes);
    $assert_session->hiddenFieldValueEquals('media-library-modal-selection', implode(',', $selected_checkboxes));
    $this->assertSelectedMediaCount('1 of 2 items selected');
    // Add to selection from another type.     $this->switchToMediaType('Two');
    $checkboxes = $this->getCheckboxes();
    $this->assertCount(4, $checkboxes);
    $this->selectMediaItem(0, '2 of 2 items selected');
    
 $permissions);
    $this->drupalLogin($this->adminAccount);
    $this->drupalGet('admin/config/services/linkset');
    $this->assertSession()
      ->elementExists('css', '#edit-actions > input.button--primary');

    // Confirm endpoint can be enabled.     $this->assertSession()->fieldExists('edit-enable-endpoint')->check();
    $this->submitForm([], 'Save configuration');
    $this->assertSession()
      ->pageTextContains('The configuration options have been saved.');
    $this->assertSession()->fieldExists('edit-enable-endpoint')->isChecked();
    $is_endpoint_enabled = $this->config('system.feature_flags')->get('linkset_endpoint');
    $this->assertTrue($is_endpoint_enabled, 'Endpoint is enabled.');

    // Confirm endpoint can be disabled.     $this->assertSession()->fieldExists('edit-enable-endpoint')->uncheck();
    $this->submitForm([], 'Save configuration');
    $this->assertSession()
      ->pageTextContains('The configuration options have been saved.');
    $is_endpoint_enabled = $this->config('system.feature_flags')->get('linkset_endpoint');
    $this->assertFalse($is_endpoint_enabled, 'Endpoint is disabled.');
  }

}
$assert_session->pageTextContains('Unlimited Cardinality Image');
    $assert_session->fieldValueEquals('media_library_select_form[0]', $added_media->id());
    $assert_session->checkboxChecked('media_library_select_form[0]');
    // Assert the item that was selected before uploading the file is still     // selected.     $assert_session->pageTextContains('2 items selected');
    $assert_session->checkboxChecked("Select $added_media_name");
    $assert_session->checkboxChecked("Select $existing_media_name");
    $assert_session->hiddenFieldValueEquals('current_selection', implode(',', [$selected_item_id$added_media->id()]));
    $selected_checkboxes = [];
    foreach ($this->getCheckboxes() as $checkbox) {
      if ($checkbox->isChecked()) {
        $selected_checkboxes[] = $checkbox->getAttribute('value');
      }
    }
    $this->assertCount(2, $selected_checkboxes);
    // Ensure the created item is added in the widget.     $this->pressInsertSelected('Added 2 media items.');
    $this->waitForText('Unlimited Cardinality Image');

    // Assert we can now only upload one more media item.     $this->openMediaLibraryForField('field_twin_media');
    $this->switchToMediaType('Four');
    

  public function testRemoveFieldHandler() {
    $this->drupalGet('admin/structure/views/view/test_content_ajax');
    $page = $this->getSession()->getPage();

    $this->openFieldDialog();
    $remove_link = $page->findAll('css', '.views-remove-link')[1];
    $parent = $remove_link->getParent();
    $this->assertTrue($remove_link->isVisible());
    $remove_checkbox = $this->assertSession()->fieldExists('fields[title][removed]', $parent);
    $this->assertFalse($remove_checkbox->isVisible());
    $this->assertFalse($remove_checkbox->isChecked());
    $remove_link->click();
    $this->assertFalse($remove_link->isVisible());
    $this->assertTrue($remove_checkbox->isChecked());
  }

  /** * Uses the 'And/Or Rearrange' link for fields to open a dialog. */
  protected function openFieldDialog() {
    $assert_session = $this->assertSession();
    $page = $this->getSession()->getPage();
    
$radios_some_disabled_value2 = $this->xpath('//input[@name=:name][@value=:value]', [':name' => 'radios_some_disabled_when_checkbox_trigger_checked', ':value' => 'value2']);
    $this->assertCount(1, $radios_some_disabled_value2);
    $radios_some_disabled_value2 = reset($radios_some_disabled_value2);

    // Verify initial state.     $this->assertTrue($textfield_invisible_element->isVisible());
    $this->assertFalse($details->hasAttribute('open'));
    $this->assertFalse($textfield_in_details->isVisible());
    $this->assertFalse($textfield_required_element->hasAttribute('required'));
    $this->assertFalse($textfield_readonly_element->hasAttribute('readonly'));
    $this->assertFalse($textarea_readonly_element->hasAttribute('readonly'));
    $this->assertFalse($checkbox_checked_element->isChecked());
    $this->assertTrue($checkbox_unchecked_element->isChecked());
    $this->assertFalse($checkbox_visible_element->isVisible());
    $this->assertTrue($text_format_invisible_value->isVisible());
    $this->assertTrue($text_format_invisible_format->isVisible());
    $this->assertFalse($checkboxes_all_checked_element_value1->isChecked());
    $this->assertFalse($checkboxes_all_checked_element_value2->isChecked());
    $this->assertFalse($checkboxes_all_checked_element_value3->isChecked());
    $this->assertFalse($checkboxes_some_checked_element_value1->isChecked());
    $this->assertFalse($checkboxes_some_checked_element_value2->isChecked());
    $this->assertFalse($checkboxes_some_checked_element_value3->isChecked());
    $this->assertFalse($checkboxes_all_disabled_element_value1->hasAttribute('disabled'));
    
$assert_session->pageTextContains('Custom video title');
    $assert_session->fieldValueEquals('media_library_select_form[0]', $added_media->id());
    $assert_session->checkboxChecked('media_library_select_form[0]');
    // Assert the item that was selected before uploading the file is still     // selected.     $assert_session->pageTextContains('2 items selected');
    $assert_session->checkboxChecked("Select Custom video title");
    $assert_session->checkboxChecked("Select $youtube_title");
    $assert_session->hiddenFieldValueEquals('current_selection', implode(',', [$selected_item_id$added_media->id()]));
    $selected_checkboxes = [];
    foreach ($this->getCheckboxes() as $checkbox) {
      if ($checkbox->isChecked()) {
        $selected_checkboxes[] = $checkbox->getAttribute('value');
      }
    }
    $this->assertCount(2, $selected_checkboxes);
    // Ensure the created item is added in the widget.     $this->pressInsertSelected('Added 2 media items.');
    $this->waitForText('Custom video title');

    // Assert we can directly insert added oEmbed media in the widget.     $this->openMediaLibraryForField('field_unlimited_media');
    $this->switchToMediaType('Five');
    
    $web_assert->elementExists('css', '.dialog-off-canvas-main-canvas.js-settings-tray-edit-mode');
  }

  /** * Asserts that Off-Canvas block form is valid. */
  protected function assertOffCanvasBlockFormIsValid() {
    $web_assert = $this->assertSession();
    // Confirm that Block title display label has been changed.     $web_assert->elementTextContains('css', '.form-item-settings-label-display label', 'Display block title');
    // Confirm Block title label is shown if checkbox is checked.     if ($this->getSession()->getPage()->find('css', 'input[name="settings[label_display]"]')->isChecked()) {
      $this->assertTrue($this->isLabelInputVisible(), 'Label is visible');
      $web_assert->elementTextContains('css', '.form-item-settings-label label', 'Block title');
    }
    else {
      $this->assertFalse($this->isLabelInputVisible(), 'Label is not visible');
    }

    // Check that common block form elements exist.     $web_assert->elementExists('css', static::LABEL_INPUT_SELECTOR);
    $web_assert->elementExists('css', 'input[data-drupal-selector="edit-settings-label-display"]');
    // Check that advanced block form elements do not exist.
$results = json_decode($this->getSession()->getPage()->getContent());
    $this->assertSame(['0', 0, 0]$results->checkbox_off, 'The first choice is on in checkbox_off but the rest is not');

    // Ensure that each checkbox is rendered correctly for a checkboxes group     // that includes a 0-indexed array of options.     $this->drupalGet('form-test/checkboxes-zero/0');
    $this->submitForm([], 'Save');
    $checkboxes = $this->xpath('//input[@type="checkbox"]');

    $this->assertCount(9, $checkboxes, 'Correct number of checkboxes found.');
    foreach ($checkboxes as $checkbox) {
      $checked = $checkbox->isChecked();
      $name = $checkbox->getAttribute('name');
      $this->assertSame($checked$name == 'checkbox_zero_default[0]' || $name == 'checkbox_string_zero_default[0]', new FormattableMarkup('Checkbox %name correctly checked', ['%name' => $name]));
    }
    // Due to Mink driver differences, we cannot submit an empty checkbox value     // to submitForm(), even if that empty value is the 'true' value for     // the checkbox.     $this->drupalGet('form-test/checkboxes-zero/0');
    $this->assertSession()->fieldExists('checkbox_off[0]')->check();
    $this->submitForm([], 'Save');
    $checkboxes = $this->xpath('//input[@type="checkbox"]');

    
$two_items_selected = '2 items selected';
    $vbo_available_message = 'Bulk actions are now available';
    $this->assertNotNull($assert_session->waitForElementVisible('css', ".js-views-bulk-actions-status:contains(\"$no_items_selected\")"));
    $select_all = $page->find('css', '.select-all > input');

    $page->checkField('node_bulk_form[0]');
    $this->assertNotNull($assert_session->waitForElementVisible('css', ".js-views-bulk-actions-status:contains(\"$one_item_selected\")"));

    // When the bulk operations controls are first activated, this should be     // relayed to screen readers.     $this->assertNotNull($assert_session->waitForElement('css', "#drupal-live-announce:contains(\"$vbo_available_message\")"));
    $this->assertFalse($select_all->isChecked());

    $page->checkField('node_bulk_form[1]');
    $this->assertNotNull($assert_session->waitForElementVisible('css', ".js-views-bulk-actions-status:contains(\"$two_items_selected\")"));
    $this->assertNotNull($assert_session->waitForElement('css', "#drupal-live-announce:contains(\"$two_items_selected\")"));
    $assert_session->pageTextNotContains($vbo_available_message);
    $this->assertTrue($select_all->isChecked());

    $page->uncheckField('node_bulk_form[0]');
    $this->assertNotNull($assert_session->waitForElementVisible('css', ".js-views-bulk-actions-status:contains(\"$one_item_selected\")"));
    $this->assertNotNull($assert_session->waitForElement('css', "#drupal-live-announce:contains(\"$one_item_selected\")"));
    $assert_session->pageTextNotContains($vbo_available_message);
    
$this->drupalLogin($this->adminUser);
    $this->drupalGet('admin/people/permissions');

    $page = $this->getSession()->getPage();
    $wrapper = $page->find('css', '.form-item-' . $this->rid . '-administer-modules');
    $real_checkbox = $wrapper->find('css', '.real-checkbox');
    $dummy_checkbox = $wrapper->find('css', '.dummy-checkbox');

    // The real per-role checkbox is visible and unchecked, the dummy copy is     // invisible.     $this->assertTrue($real_checkbox->isVisible());
    $this->assertFalse($real_checkbox->isChecked());
    $this->assertFalse($dummy_checkbox->isVisible());

    // Enable the permission for all authenticated users.     $page->findField('authenticated[administer modules]')->click();

    // The real and dummy checkboxes switch visibility and the dummy is now both     // checked and disabled.     $this->assertFalse($real_checkbox->isVisible());
    $this->assertTrue($dummy_checkbox->isVisible());
    $this->assertTrue($dummy_checkbox->isChecked());
    $this->assertTrue($dummy_checkbox->hasAttribute('disabled'));
  }
Home | Imprint | This part of the site doesn't use cookies.