checkboxChecked example

$assert->addressEquals('admin/content/media');

    // The media item was just created, so it should only have one revision.     $media = $this->container
      ->get('entity_type.manager')
      ->getStorage('media')
      ->load(1);
    $this->assertRevisionCount($media, 1);

    // If we edit the item, we should get a new revision.     $this->drupalGet('/media/1/edit');
    $assert->checkboxChecked('Create new revision');
    $page = $this->getSession()->getPage();
    $page->fillField('Name', 'Foo');
    $page->pressButton('Save');
    $this->assertRevisionCount($media, 2);

    // Confirm the correct revision title appears on "view revisions" page.     $media = $this->container->get('entity_type.manager')
      ->getStorage('media')
      ->loadUnchanged(1);
    $this->drupalGet("media/" . $media->id() . "/revisions/" . $media->getRevisionId() . "/view");
    $assert->pageTextContains('Foo');
  }
$file = array_pop($files);
    $this->assertFalse($file->isTemporary());
    // Load the created media item.     $media_items = Media::loadMultiple();
    $added_media = array_pop($media_items);
    // Ensure the media item was saved to the library and automatically     // selected. The added media items should be in the first position of the     // add form.     $assert_session->pageTextContains('Add or select media');
    $assert_session->pageTextContains($png_image->filename);
    $assert_session->fieldValueEquals('media_library_select_form[0]', $added_media->id());
    $assert_session->checkboxChecked('media_library_select_form[0]');
    $assert_session->pageTextContains('1 of 2 items selected');
    $assert_session->hiddenFieldValueEquals('current_selection', $added_media->id());
    // Ensure the created item is added in the widget.     $this->pressInsertSelected('Added one media item.');
    $this->waitForText($png_image->filename);

    // Remove the item.     $assert_session->elementTextContains('css', '.field--name-field-twin-media', $png_image->filename);
    $assert_session->elementExists('css', '.field--name-field-twin-media')->pressButton('Remove');
    $this->waitForElementTextContains('#drupal-live-announce', $png_image->filename . ' has been removed');
    $assert_session->elementTextNotContains('css', '.field--name-field-twin-media', $png_image->filename);

    
// Set page revision setting 'create new revision'. This will mean new     // revisions are created by default when the node is edited.     $type = NodeType::load('page');
    $type->setNewRevision(TRUE);
    $type->save();

    // Create the node.     $node = $this->drupalCreateNode();

    // Verify the checkbox is checked on the node edit form.     $this->drupalGet('node/' . $node->id() . '/edit');
    $this->assertSession()->checkboxChecked('edit-revision');

    // Uncheck the create new revision checkbox and save the node.     $edit = ['revision' => FALSE];
    $this->drupalGet('node/' . $node->id() . '/edit');
    $this->submitForm($edit, 'Save');

    // Load the node again and check the revision is the same as before.     $node_storage->resetCache([$node->id()]);
    $node_revision = $node_storage->load($node->id(), TRUE);
    $this->assertEquals($node->getRevisionId()$node_revision->getRevisionId(), "After an existing node is saved with 'Create new revision' unchecked, a new revision is not created.");

    
// Test comment field widget changes.     $limited_user = $this->drupalCreateUser([
      'administer entity_test fields',
      'view test entity',
      'administer entity_test content',
      'administer comments',
    ]);
    $this->drupalLogin($limited_user);
    $this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment');
    $this->assertSession()->checkboxNotChecked('edit-default-value-input-comment-0-status-0');
    $this->assertSession()->checkboxNotChecked('edit-default-value-input-comment-0-status-1');
    $this->assertSession()->checkboxChecked('edit-default-value-input-comment-0-status-2');
    // Test comment option change in field settings.     $edit = [
      'default_value_input[comment][0][status]' => CommentItemInterface::CLOSED,
      'settings[anonymous]' => CommentInterface::ANONYMOUS_MAY_CONTACT,
    ];
    $this->submitForm($edit, 'Save settings');
    $this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment');
    $this->assertSession()->checkboxNotChecked('edit-default-value-input-comment-0-status-0');
    $this->assertSession()->checkboxChecked('edit-default-value-input-comment-0-status-1');
    $this->assertSession()->checkboxNotChecked('edit-default-value-input-comment-0-status-2');
    $this->assertSession()->fieldValueEquals('settings[anonymous]', CommentInterface::ANONYMOUS_MAY_CONTACT);

    
'alt_field' => 0,
        'title_field' => 0,
        'max_resolution' => '85x85',
        'min_resolution' => '',
      ],
    ])->save();

    // Test user creation page for valid fields.     $this->drupalGet('admin/people/create');
    $this->assertSession()->fieldValueEquals('edit-status-0', '1');
    $this->assertSession()->fieldValueEquals('edit-status-1', '1');
    $this->assertSession()->checkboxChecked('edit-status-1');

    // Test that browser autocomplete behavior does not occur.     $this->assertSession()->responseNotContains('data-user-info-from-browser');

    // Test that the password strength indicator displays.     $config = $this->config('user.settings');

    $config->set('password_strength', TRUE)->save();
    $this->drupalGet('admin/people/create');
    $this->assertSession()->responseContains("Password strength:");

    
$this->assertSame('None', $options[0]->getText(), 'Option 1 in the Text Editor select is "None".');
    $this->assertSame('Unicorn Editor', $options[1]->getText(), 'Option 2 in the Text Editor select is "Unicorn Editor".');
    $this->assertTrue($options[0]->hasAttribute('selected'), 'Option 1 ("None") is selected.');
    // Ensure the none option is selected.     $this->assertSession()->pageTextNotContains('This option is disabled because no modules that provide a text editor are currently enabled.');

    // Select the "Unicorn Editor" editor and click the "Configure" button.     $edit = [
      'editor[editor]' => 'unicorn',
    ];
    $this->submitForm($edit, 'Configure');
    $this->assertSession()->checkboxChecked('editor[settings][ponies_too]');

    return $edit;
  }

  /** * Verifies unicorn editor configuration. * * @param string $format_id * The format machine name. * @param bool $ponies_too * The expected value of the ponies_too setting. */
// Test that the encoded query appears in the page title. Only test the     // part not including the quote, because assertText() cannot seem to find     // the quote marks successfully.     $this->assertSession()->pageTextContains('Search for cat dog OR gerbil -fish -snake');

    // Verify that all of the form fields are filled out.     foreach ($edit as $key => $value) {
      if ($key != 'type[page]') {
        $this->assertSession()->fieldValueEquals($key$value);
      }
      else {
        $this->assertSession()->checkboxChecked($key);
      }
    }

    // Now test by submitting the or/not part of the query in the main     // search box, and verify that the advanced form is not filled out.     // (It shouldn't be filled out unless you submit values in those fields.)     $edit2 = ['keys' => 'cat dog OR gerbil -fish -snake'];
    $this->drupalGet('search/node');
    $this->submitForm($edit2, 'edit-submit--2');
    $this->assertSession()->pageTextContains('Search for cat dog OR gerbil -fish -snake');
    foreach ($edit as $key => $value) {
      
$this->assertEquals('en', $language['langcode']);

    // Check if the Default English language has no path prefix.     $this->drupalGet('admin/config/regional/language/detection/url');
    $this->assertSession()->fieldValueEquals("prefix[en]", '');
    // Check if French has a path prefix.     $this->drupalGet('admin/config/regional/language/detection/url');
    $this->assertSession()->fieldValueEquals("prefix[fr]", 'fr');

    // Check if we can change the default language.     $this->drupalGet('admin/config/regional/language');
    $this->assertSession()->checkboxChecked('edit-site-default-language-en');

    // Change the default language.     $edit = [
      'site_default_language' => 'fr',
    ];
    $this->submitForm($edit, 'Save configuration');
    $this->rebuildContainer();
    $this->assertSession()->checkboxChecked('edit-site-default-language-fr');
    $this->assertSession()->addressEquals(Url::fromRoute('entity.configurable_language.collection', []['langcode' => 'fr']));

    // Check if a valid language prefix is added after changing the default
$this->submitForm($edit, 'Save');
    $this->drupalGet('admin/config/media/responsive-image-style/style_one');

    // Check the mapping for multipliers 1x and 2x for the mobile breakpoint.     $this->assertSession()->fieldValueEquals('keyed_styles[responsive_image_test_module.mobile][1x][image_style]', 'thumbnail');
    $this->assertSession()->fieldValueEquals('keyed_styles[responsive_image_test_module.mobile][1x][image_mapping_type]', 'image_style');
    $this->assertSession()->fieldValueEquals('keyed_styles[responsive_image_test_module.mobile][2x][image_mapping_type]', '_none');

    // Check the mapping for multipliers 1x and 2x for the narrow breakpoint.     $this->assertSession()->fieldValueEquals('keyed_styles[responsive_image_test_module.narrow][1x][image_mapping_type]', 'sizes');
    $this->assertSession()->fieldValueEquals('keyed_styles[responsive_image_test_module.narrow][1x][sizes]', '(min-resolution: 192dpi) and (min-width: 170px) 386px, (min-width: 170px) 193px, (min-width: 768px) 18vw, (min-width: 480px) 30vw, 48vw');
    $this->assertSession()->checkboxChecked('edit-keyed-styles-responsive-image-test-modulenarrow-1x-sizes-image-styles-large');
    $this->assertSession()->checkboxChecked('edit-keyed-styles-responsive-image-test-modulenarrow-1x-sizes-image-styles-medium');
    $this->assertSession()->checkboxNotChecked('edit-keyed-styles-responsive-image-test-modulenarrow-1x-sizes-image-styles-thumbnail');
    $this->assertSession()->fieldValueEquals('keyed_styles[responsive_image_test_module.narrow][2x][image_mapping_type]', '_none');

    // Check the mapping for multipliers 1x and 2x for the wide breakpoint.     $this->assertSession()->fieldValueEquals('keyed_styles[responsive_image_test_module.wide][1x][image_style]', 'large');
    $this->assertSession()->fieldValueEquals('keyed_styles[responsive_image_test_module.wide][1x][image_mapping_type]', 'image_style');
    $this->assertSession()->fieldValueEquals('keyed_styles[responsive_image_test_module.wide][2x][image_mapping_type]', '_none');

    // Delete the style.     $this->drupalGet('admin/config/media/responsive-image-style/style_one/delete');
    
// Set page revision setting 'create new revision'. This will mean new     // revisions are created by default when the node is edited.     $type = NodeType::load('page');
    $type->setNewRevision(TRUE);
    $type->save();

    // Create the node.     $node = $this->drupalCreateNode();

    // Verify the checkbox is checked on the node edit form.     $this->drupalGet('node/' . $node->id() . '/edit');
    $this->assertSession()->checkboxChecked('edit-revision');

    // Uncheck the create new revision checkbox and save the node.     $edit = ['revision' => FALSE];
    $this->drupalGet('node/' . $node->id() . '/edit');
    $this->submitForm($edit, 'Save');

    $this->assertSession()->addressEquals($node->toUrl());
    // Verify revisions exist.     $this->assertSession()->linkExists('Revisions');

    // Verify the checkbox is checked on the node edit form.
$this->assertSession()->pageTextContains('Not moderated Test has been created.');

    // Check that the 'Create new revision' is not disabled.     $this->drupalGet('/admin/structure/types/manage/not_moderated');
    $this->assertNull($this->assertSession()->fieldExists('options[revision]')->getAttribute('disabled'));

    // Now enable moderation state.     $this->enableModerationThroughUi('not_moderated');

    // Check that the 'Create new revision' checkbox is checked and disabled.     $this->drupalGet('/admin/structure/types/manage/not_moderated');
    $this->assertSession()->checkboxChecked('options[revision]');
    $this->assertSession()->fieldDisabled('options[revision]');

    // And make sure it works.     $nodes = \Drupal::entityTypeManager()->getStorage('node')
      ->loadByProperties(['title' => 'Test']);
    if (empty($nodes)) {
      $this->fail('Could not load node with title Test');
      return;
    }
    $node = reset($nodes);
    $this->drupalGet('node/' . $node->id());
    
$this->drupalGet("user/" . $user1->id() . "/edit");
    $this->submitForm($edit, 'Save');
    $this->assertSession()->responseNotContains("Password strength:");

    // Check that the user status field has the correct value and that it is     // properly displayed.     $admin_user = $this->drupalCreateUser(['administer users']);
    $this->drupalLogin($admin_user);

    $this->drupalGet('user/' . $user1->id() . '/edit');
    $this->assertSession()->checkboxNotChecked('edit-status-0');
    $this->assertSession()->checkboxChecked('edit-status-1');

    $edit = ['status' => 0];
    $this->drupalGet('user/' . $user1->id() . '/edit');
    $this->submitForm($edit, 'Save');
    $this->assertSession()->pageTextContains('The changes have been saved.');
    $this->assertSession()->checkboxChecked('edit-status-0');
    $this->assertSession()->checkboxNotChecked('edit-status-1');

    $edit = ['status' => 1];
    $this->drupalGet('user/' . $user1->id() . '/edit');
    $this->submitForm($edit, 'Save');
    
// Check that the vocabulary was actually created.     $this->drupalGet('admin/structure/taxonomy/manage/' . $edit['vid']);
    $this->assertSession()->statusCodeEquals(200);

    // Check that the language settings were saved.     $language_settings = ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', $edit['vid']);
    $this->assertEquals('bb', $language_settings->getDefaultLangcode(), 'The langcode was saved.');
    $this->assertTrue($language_settings->isLanguageAlterable(), 'The visibility setting was saved.');

    // Check that the correct options are selected in the interface.     $this->assertTrue($this->assertSession()->optionExists('edit-default-language-langcode', 'bb')->isSelected());
    $this->assertSession()->checkboxChecked('edit-default-language-language-alterable');

    // Edit the vocabulary and check that the new settings are updated.     $edit = [
      'default_language[langcode]' => 'aa',
      'default_language[language_alterable]' => FALSE,
    ];
    $this->drupalGet('admin/structure/taxonomy/manage/' . $vid);
    $this->submitForm($edit, 'Save');

    // And check again the settings and also the interface.     $language_settings = ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', $vid);
    
$assert_session->linkByHrefExists('admin/structure/media/manage/' . $this->testMediaType->id() . '/fields');
    $assert_session->linkByHrefExists('admin/structure/media/manage/' . $this->testMediaType->id() . '/form-display');
    $assert_session->linkByHrefExists('admin/structure/media/manage/' . $this->testMediaType->id() . '/display');

    // Assert that fields have expected values before editing.     $page->clickLink('Edit');
    $assert_session->fieldValueEquals('label', $name);
    $assert_session->fieldValueEquals('description', $description);
    $assert_session->fieldValueEquals('source', 'test');
    $assert_session->fieldValueEquals('label', $name);
    $assert_session->checkboxNotChecked('edit-options-new-revision');
    $assert_session->checkboxChecked('edit-options-status');
    $assert_session->checkboxNotChecked('edit-options-queue-thumbnail-downloads');
    $assert_session->pageTextContains('Create new revision');
    $assert_session->pageTextContains('Automatically create new revisions. Users with the "Administer media" permission will be able to override this option.');
    $assert_session->pageTextContains('Download thumbnails via a queue.');
    $assert_session->pageTextContains('Media will be automatically published when created.');
    $assert_session->pageTextContains('Media sources can provide metadata fields such as title, caption, size information, credits, etc. Media can automatically save this metadata information to entity fields, which can be configured below. Information will only be mapped if the entity field is empty.');

    // Try to change media type and check if new configuration sub-form appears.     $page->selectFieldOption('source', 'test');
    $result = $assert_session->waitForElementVisible('css', 'fieldset[data-drupal-selector="edit-source-configuration"]');
    $this->assertNotEmpty($result);
    
$this->submitForm($edit, 'Add custom language');
    $this->assertSession()->addressEquals(Url::fromRoute('entity.configurable_language.collection'));
    $this->assertSession()->responseContains('"edit-languages-' . $langcode . '-weight"');
    $this->assertSession()->pageTextContains($name);

    $language = \Drupal::service('language_manager')->getLanguage($langcode);
    $english = \Drupal::service('language_manager')->getLanguage('en');

    // Check if we can change the default language.     $path = 'admin/config/regional/language';
    $this->drupalGet($path);
    $this->assertSession()->checkboxChecked('edit-site-default-language-en');
    // Change the default language.     $edit = [
      'site_default_language' => $langcode,
    ];
    $this->submitForm($edit, 'Save configuration');
    $this->rebuildContainer();
    $this->assertSession()->checkboxNotChecked('edit-site-default-language-en');
    $this->assertSession()->addressEquals(Url::fromRoute('entity.configurable_language.collection', []['language' => $language]));

    // Ensure we can't delete the default language.     $this->drupalGet('admin/config/regional/language/delete/' . $langcode);
    
Home | Imprint | This part of the site doesn't use cookies.