uncheckField example

/** @var \Behat\Mink\Session $session */
    $session = $this->getSession();
    $this->assertSession()->statusCodeEquals(200);

    /** @var \Behat\Mink\Element\DocumentElement $page */
    $page = $session->getPage();
    $page->fillField('Title', $label);
    if ($publish) {
      $page->findButton('Save')->click();
    }
    else {
      $page->uncheckField('Published');
      $page->findButton('Save')->click();
    }

    $session->getPage()->hasContent("{$label} has been created");

    return $this->getOneEntityByLabel('node', $label);
  }

  /** * Determine if the content list has an entity's label. * * This assertion can be used to validate a particular entity exists in the * current workspace. */
// At a wider width, vertical tabs are used for the meta section of the node     // form.     $this->getSession()->resizeWindow(1200, 1200);
    $this->drupalGet('node/1/edit');

    $assert_session->waitForText("New revision");
    $summary = $assert_session->waitForElement('css', '.vertical-tabs__menu-item-summary');
    $this->assertNotNull($summary);
    $this->assertTrue($summary->isVisible());
    $this->assertEquals('New revision', $summary->getText());
    $page->uncheckField('revision');
    $assert_session->waitForText('No revision');
    $this->assertEquals('No revision', $summary->getText());

    // At a narrower width, details are used for the meta section of the node     // form.     $this->getSession()->resizeWindow(600, 1200);
    $this->drupalGet('node/1/edit');

    $summary = $assert_session->waitForElement('css', 'span.summary');
    $this->assertNotNull($summary);
    $this->assertTrue($summary->isVisible());
    


    // Open single item layout page.     $this->drupalGet('node/1/layout');

    // Placeholder label should not be visible, preview content should be.     $assert_session->elementNotExists('css', '.layout-builder-block__content-preview-placeholder-label');
    $assert_session->pageTextContains($content_preview_body_text);

    // Disable content preview, confirm presence of placeholder labels.     $this->assertTrue($page->hasCheckedField('layout-builder-content-preview'));
    $page->uncheckField('layout-builder-content-preview');
    $this->assertNotEmpty($assert_session->waitForElementVisible('css', '.layout-builder-block__content-preview-placeholder-label'));

    // Confirm that block content is not on page.     $assert_session->pageTextNotContains($content_preview_body_text);
    $this->assertContextualLinks();

    // Check that content preview is still disabled on page reload.     $this->getSession()->reload();
    $this->assertNotEmpty($assert_session->waitForElement('css', '.layout-builder-block__content-preview-placeholder-label'));
    $assert_session->pageTextNotContains($content_preview_body_text);
    $this->assertContextualLinks();

    
$this->createNewTextFormat($page$assert_session, 'unicorn');
    $page->selectFieldOption('editor[editor]', 'unicorn');
    $assert_session->assertWaitOnAjaxRequest();
    $page->checkField('filters[filter_html][status]');
    $page->checkField($incompatible_filter_name);
    $assert_session->assertWaitOnAjaxRequest();
    $page->selectFieldOption('editor[editor]', 'ckeditor5');
    $assert_session->assertWaitOnAjaxRequest();
    $assert_session->pageTextContains($filter_warning);

    // Disable the incompatible filter.     $page->uncheckField($incompatible_filter_name);

    // Confirm there are no longer any warnings.     $assert_session->waitForElementRemoved('css', '[data-drupal-messages] [role="alert"]');

    // Confirm the text format can be saved.     $this->saveNewTextFormat($page$assert_session);
  }

  /** * Tests that when image uploads were enabled, they remain enabled. */
  
$page->pressButton('Save');

    // Enable the new view mode.     $this->drupalGet("$field_ui_prefix/default");
    $page->checkField('display_modes_custom[new]');
    $page->pressButton('Save');

    // Enable and disable Layout Builder for the new view mode.     $this->drupalGet("$field_ui_prefix/new");
    $page->checkField('layout[enabled]');
    $page->pressButton('Save');
    $page->uncheckField('layout[enabled]');
    $page->pressButton('Save');
    $page->pressButton('Confirm');

    // The node using the default view mode still contains its overrides.     $this->drupalGet('node/1');
    $assert_session->pageTextContains('Powered by Drupal');
  }

}
// The AJAX command in the response will update the DOM       $select = $assertSession->waitForElement('css', "div#ajax_selected_color:contains('$item')");
      $this->assertNotNull($select, "DataCommand has updated the page with a value of $item.");
    }

    // Verify form values of a checkbox element.     $session->getPage()->checkField('checkbox');
    $div0 = $this->assertSession()->waitForElement('css', "div#ajax_checkbox_value:contains('checked')");
    $this->assertNotNull($div0, 'DataCommand updates the DOM as expected when a checkbox is selected');

    $session->getPage()->uncheckField('checkbox');
    $div1 = $this->assertSession()->waitForElement('css', "div#ajax_checkbox_value:contains('unchecked')");
    $this->assertNotNull($div1, 'DataCommand updates the DOM as expected when a checkbox is de-selected');
  }

  /** * Tests that AJAX elements with invalid callbacks return error code 500. */
  public function testSimpleInvalidCallbacksAjaxFormValue() {
    $this->drupalGet('ajax_forms_test_get_form');

    $session = $this->getSession();

    
$page->pressButton('Save');
    $assert_session->checkboxChecked('layout[enabled]');
    $assert_session->checkboxNotChecked('layout[allow_custom]');

    // Check and submit allow_custom.     $page->checkField('layout[allow_custom]');
    $page->pressButton('Save');
    $assert_session->checkboxChecked('layout[enabled]');
    $assert_session->checkboxChecked('layout[allow_custom]');

    // Reset the checkboxes.     $page->uncheckField('layout[enabled]');
    $page->pressButton('Save');
    $page->pressButton('Confirm');
    $assert_session->checkboxNotChecked('layout[enabled]');
    $assert_session->checkboxNotChecked('layout[allow_custom]');

    // Check both at the same time.     $page->checkField('layout[enabled]');
    $page->checkField('layout[allow_custom]');
    $page->pressButton('Save');
    $assert_session->checkboxChecked('layout[enabled]');
    $assert_session->checkboxChecked('layout[allow_custom]');
  }
self::assertFalse($twig_config['debug']);
    self::assertNull($twig_config['auto_reload']);
    self::assertTrue($twig_config['cache']);

    $this->drupalGet(Url::fromRoute('system.development_settings'));
    if ($twig_development_mode) {
      $this->getSession()->getPage()->checkField('Twig development mode');
      $this->assertSession()->checkboxChecked('Twig debug mode');
      $this->assertSession()->checkboxChecked('Disable Twig cache');
    }
    if (!$twig_debug) {
      $this->getSession()->getPage()->uncheckField('Twig debug mode');
    }
    if (!$twig_cache_disable) {
      $this->getSession()->getPage()->uncheckField('Disable Twig cache');
    }
    $this->getSession()->getPage()->pressButton('Save settings');

    $this->drupalGet(Url::fromRoute('system.status'));
    if (!$twig_development_mode) {
      $this->assertSession()->pageTextNotContains('Twig development mode');
    }
    else {
      
$page->checkField('settings[label_display]');
    $page->pressButton('Add block');
    $page->pressButton('Save layout');
    $assert_session->pageTextContains('This is an override');

    // Get the UUID of the component.     $components = Node::load(1)->get('layout_builder__layout')->getSection(0)->getComponents();
    end($components);
    $uuid = key($components);

    $this->drupalGet('layout_builder/update/block/overrides/node.1/0/content/' . $uuid);
    $page->uncheckField('settings[label_display]');
    $page->pressButton('Update');
    $assert_session->pageTextNotContains('This is an override');
    $page->pressButton('Save layout');
    $assert_session->pageTextNotContains('This is an override');
  }

  /** * Tests the Layout Builder UI for an entity type without a bundle. */
  public function testNonBundleEntityType() {
    $assert_session = $this->assertSession();
    
// 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->assertFalse($select_all->isChecked());

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

    
    $assert_session->fieldDisabled('Machine-readable name');

    // Edit and save media type form fields with new values.     $new_name = $this->randomMachineName();
    $new_description = $this->randomMachineName();
    $page->fillField('label', $new_name);
    $page->fillField('description', $new_description);
    $page->selectFieldOption('source', 'test');
    $page->fillField('Test config value', 'This is new config value.');
    $page->selectFieldOption('field_map[attribute_1]', 'name');
    $page->checkField('options[new_revision]');
    $page->uncheckField('options[status]');
    $page->checkField('options[queue_thumbnail_downloads]');
    $page->pressButton('Save');
    // The wait prevents intermittent test failures.     $result = $assert_session->waitForLink('Add media type');
    $this->assertNotEmpty($result);
    $assert_session->addressEquals('admin/structure/media');
    $assert_session->pageTextContains("The media type $new_name has been updated.");

    // Test if edit worked and if new field values have been saved as expected.     $this->drupalGet('admin/structure/media/manage/' . $this->testMediaType->id());
    $assert_session->fieldValueEquals('label', $new_name);
    
$this->drupalGet('media/' . $media_id);
    $assert_session->statusCodeEquals(404);
    /** @var \Drupal\media\MediaInterface $media */
    $media = $this->container->get('entity_type.manager')
      ->getStorage('media')
      ->loadUnchanged($media_id);
    $this->assertSame($media->getRevisionLogMessage()$revision_log_message);
    $this->assertNotEquals($previous_revision_id$media->getRevisionId());

    // Test the status checkbox.     $this->drupalGet('media/' . $media_id . '/edit');
    $page->uncheckField('status[value]');
    $page->pressButton('Save');
    /** @var \Drupal\media\MediaInterface $media */
    $media = $this->container->get('entity_type.manager')
      ->getStorage('media')
      ->loadUnchanged($media_id);
    $this->assertFalse($media->isPublished());

    // Tests media delete form.     $this->drupalGet('media/' . $media_id . '/edit');
    $page->clickLink('Delete');
    $assert_session->pageTextContains('This action cannot be undone');
    
$selected_item_id = $checkbox->getAttribute('value');
    $checkbox->click();
    $assert_session->hiddenFieldValueEquals('current_selection', $selected_item_id);
    $this->assertTrue($assert_session->fieldExists('Add files')->hasAttribute('multiple'));
    $png_uri_5 = $file_system->copy($png_image->uri, 'public://');
    $this->addMediaFileToField('Add files', $this->container->get('file_system')->realpath($png_uri_5));
    // assertWaitOnAjaxRequest() required for input "id" attributes to     // consistently match their label's "for" attribute.     $assert_session->assertWaitOnAjaxRequest();
    $page->fillField('Alternative text', $this->randomString());
    $this->pressSaveButton();
    $page->uncheckField('media_library_select_form[2]');
    $this->waitForText('1 item selected');
    $this->waitForText("Select $existing_media_name");
    $media_items = Media::loadMultiple();
    $added_media = array_pop($media_items);
    $added_media_name = $added_media->label();
    $assert_session->pageTextContains('1 item selected');
    $assert_session->checkboxChecked("Select $added_media_name");
    $assert_session->checkboxNotChecked("Select $existing_media_name");
    $assert_session->hiddenFieldValueEquals('current_selection', $added_media->id());
    $this->pressInsertSelected('Added one media item.');
    $this->waitForText($file_system->basename($png_uri_5));

    
$selected_item_id = $checkbox->getAttribute('value');
    $checkbox->click();
    $assert_session->hiddenFieldValueEquals('current_selection', $selected_item_id);
    $page->fillField('Add Type Five via URL', $youtube_url);
    $page->pressButton('Add');
    // assertWaitOnAjaxRequest() required for input "id" attributes to     // consistently match their label's "for" attribute.     $assert_session->assertWaitOnAjaxRequest();
    $this->waitForText('The media item has been created but has not yet been saved');
    $page->fillField('Name', 'Another video');
    $this->pressSaveButton();
    $page->uncheckField('media_library_select_form[1]');
    $this->waitForText('1 item selected');
    $this->pressInsertSelected('Added one media item.');
    $this->waitForText('Another video');

    // Assert removing an added oEmbed media item before save works as expected.     $this->openMediaLibraryForField('field_unlimited_media');
    $this->switchToMediaType('Five');
    $page->fillField('Add Type Five via URL', $youtube_url);
    $page->pressButton('Add');
    // Assert the media item fields are shown and the vertical tabs are no     // longer shown.
$view['page[items_per_page]'] = 4;
    $view['block[create]'] = 1;
    $view['block[title]'] = $this->randomMachineName(16);
    $view['block[items_per_page]'] = 3;
    $this->drupalGet('admin/structure/views/add');
    $this->submitForm($view, 'Save and edit');

    // Uncheck items per page in block settings.     $this->drupalGet($this->getSession()->getCurrentUrl() . '/edit/block_1');
    $this->clickLink('Items per page');
    $this->assertSession()->checkboxChecked('allow[items_per_page]');
    $this->getSession()->getPage()->uncheckField('allow[items_per_page]');
    $this->getSession()->getPage()->pressButton('Apply');
    $this->getSession()->getPage()->pressButton('Save');

    // Check items per page in block settings.     $this->drupalGet('admin/structure/views/nojs/display/' . $view['id'] . '/block_1/allow');
    $this->assertSession()->checkboxNotChecked('allow[items_per_page]');
    $this->getSession()->getPage()->checkField('allow[items_per_page]');
    $this->getSession()->getPage()->pressButton('Apply');
    $this->getSession()->getPage()->pressButton('Save');

    // Ensure that items per page checkbox remains checked.
Home | Imprint | This part of the site doesn't use cookies.