fieldDisabled example

'new_storage_type' => 'text',
      'label' => 'Test',
      'field_name' => 'article_text',
    ];
    $this->drupalGet('admin/structure/types/manage/article/fields/add-field');
    $this->submitForm($edit, 'Save and continue');

    // Tests that field doesn't have translatable setting if bundle is not     // translatable.     $path = 'admin/structure/types/manage/article/fields/node.article.field_article_text';
    $this->drupalGet($path);
    $this->assertSession()->fieldDisabled('edit-translatable');
    $this->assertSession()->pageTextContains('To configure translation for this field, enable language support for this type.');

    // 'Users may translate this field' should be unchecked by default.     $this->assertSession()->checkboxNotChecked('translatable');

    // Tests that field has translatable setting if bundle is translatable.     // Note: this field is not translatable when enable bundle translatability.     $edit = [
      'entity_types[node]' => TRUE,
      'settings[node][article][settings][language][language_alterable]' => TRUE,
      'settings[node][article][translatable]' => TRUE,
      

  protected $profile = 'testing_install_profile_dependencies';

  /** * Tests that an install profile can require modules. */
  public function testUninstallingModules() {
    $user = $this->drupalCreateUser(['administer modules']);
    $this->drupalLogin($user);
    $this->drupalGet('admin/modules/uninstall');
    $this->assertSession()->fieldDisabled('uninstall[dblog]');
    $this->getSession()->getPage()->checkField('uninstall[ban]');
    $this->click('#edit-submit');
    // Click the confirm button.     $this->click('#edit-submit');
    $this->assertSession()->responseContains('The selected modules have been uninstalled.');
    // We've uninstalled a module therefore we need to rebuild the container in     // the test runner.     $this->rebuildContainer();
    $this->assertFalse($this->container->get('module_handler')->moduleExists('ban'));
    try {
      $this->container->get('module_installer')->uninstall(['dblog']);
      
'configure any layout',
      'administer node display',
      'administer node fields',
      'access contextual links',
    ]));

    $field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';

    // From the manage display page, go to manage the layout.     $this->drupalGet("$field_ui_prefix/display/default");
    $assert_session->linkNotExists('Manage layout');
    $assert_session->fieldDisabled('layout[allow_custom]');

    $this->submitForm(['layout[enabled]' => TRUE], 'Save');
    $assert_session->linkExists('Manage layout');
    $this->clickLink('Manage layout');

    // Add a new block.     $assert_session->linkExists('Add block');
    $this->clickLink('Add block');
    $assert_session->linkExists('Powered by Drupal');
    $this->clickLink('Powered by Drupal');
    $page->fillField('settings[label]', 'This is the label');
    

  public function testUninstallDependents() {
    // Enable the forum module.     $edit = ['modules[forum][enable]' => 'forum'];
    $this->drupalGet('admin/modules');
    $this->submitForm($edit, 'Install');
    $this->submitForm([], 'Continue');
    $this->assertModules(['forum'], TRUE);

    // Check that the comment module cannot be uninstalled.     $this->drupalGet('admin/modules/uninstall');
    $this->assertSession()->fieldDisabled('uninstall[comment]');

    // Delete any forum terms.     $vid = $this->config('forum.settings')->get('vocabulary');
    // Ensure taxonomy has been loaded into the test-runner after forum was     // enabled.     \Drupal::moduleHandler()->load('taxonomy');
    $storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
    $terms = $storage->loadByProperties(['vid' => $vid]);
    $storage->delete($terms);

    // Uninstall the forum module, and check that taxonomy now can also be
$this->submitForm([], 'Save');
    $this->assertParentsUnchanged($term_6);
  }

  /** * Tests specifying parents when creating terms and a disabled parent form. */
  public function testEditingParentsWithDisabledFormElement() {
    // Disable the parent form element.     $this->state->set('taxonomy_test.disable_parent_form_element', TRUE);
    $this->drupalGet("/admin/structure/taxonomy/manage/{$this->vocabularyId}/add");
    $this->assertSession()->fieldDisabled('Parent terms');

    $terms = $this->doTestEditingSingleParent();
    $term_5 = array_pop($terms);
    $term_4 = array_pop($terms);

    // Create a term with multiple parents.     $term_6 = $this->createTerm('Test term 6', [
      // When the parent form element is disabled, its default value is used as       // the value which gets populated in ascending order of term IDs.       $term_4->id(),
      $term_5->id(),
    ]);
$this->assertSession()->pageTextContains('The changes have been saved.');
    $storage->resetCache();
    $this->assertTrue($account->hasPermission('access user profiles'), 'User again has "access user profiles" permission.');
    $current_permissions_hash = $permissions_hash_generator->generate($account);
    $this->assertSame($current_permissions_hash$permissions_hash_generator->generate($this->loggedInUser));
    $this->assertEquals($previous_permissions_hash$current_permissions_hash, 'Permissions hash has reverted.');

    // Ensure that the admin role doesn't have any checkboxes.     $this->drupalGet('admin/people/permissions');
    foreach (array_keys($this->container->get('user.permissions')->getPermissions()) as $permission) {
      $this->assertSession()->checkboxChecked('administrator[' . $permission . ']');
      $this->assertSession()->fieldDisabled('administrator[' . $permission . ']');
    }
  }

  /** * Tests assigning of permissions for the administrator role. */
  public function testAdministratorRole() {
    $this->drupalLogin($this->adminUser);
    $this->drupalGet('admin/people/role-settings');

    // Verify that the administration role is none by default.

    ]);

    // The untrusted user tries to edit content that is written in a text format     // that they are not allowed to use. The editor is still loaded. CKEditor,     // for example, supports being loaded in a disabled state.     $this->drupalGet('node/1/edit');
    [$editor_settings_present$editor_js_present$body] = $this->getThingsToCheck('body');
    $this->assertTrue($editor_settings_present, 'Text Editor module settings.');
    $this->assertTrue($editor_js_present, 'Text Editor JavaScript.');
    $this->assertSession()->elementsCount('xpath', $body, 1);
    $this->assertSession()->fieldDisabled("edit-body-0-value");
    $this->assertSession()->fieldValueEquals("edit-body-0-value", 'This field has been disabled because you do not have sufficient permissions to edit it.');
    $this->assertSession()->elementNotExists('css', 'select.js-filter-list');
    // Verify that no single text format hidden input exists on the page.     $this->assertSession()->elementNotExists('xpath', '//input[@type="hidden" and contains(@class, "editor")]');
  }

  /** * Tests supported element types. */
  public function testSupportedElementTypes() {
    // Associate the unicorn text editor with the "Full HTML" text format.
// Check there is a link to delete a default transition.     $session->linkByHrefExists('/admin/config/workflow/workflows/manage/test/transition/publish/delete');
    // Delete the transition.     $this->drupalGet('/admin/config/workflow/workflows/manage/test/transition/publish/delete');
    $this->submitForm([], 'Delete');
    // The link to delete the transition should now be gone.     $session->linkByHrefNotExists('/admin/config/workflow/workflows/manage/test/transition/publish/delete');

    // Ensure that the published settings cannot be changed.     $this->drupalGet('admin/config/workflow/workflows/manage/test/state/published');
    $session->fieldDisabled('type_settings[published]');
    $session->fieldDisabled('type_settings[default_revision]');

    // Ensure that the draft settings cannot be changed.     $this->drupalGet('admin/config/workflow/workflows/manage/test/state/draft');
    $session->fieldDisabled('type_settings[published]');
    $session->fieldDisabled('type_settings[default_revision]');

    $this->drupalGet('admin/config/workflow/workflows/manage/test/type/node');
    $session->pageTextContains('Select the content types for the Test workflow');
    foreach ($types as $type) {
      $session->pageTextContains($type->label());
      


  /** * Tests enabling a module with an incompatible dependency version. */
  public function testIncompatibleModuleVersionDependency() {
    // Test that the system_incompatible_module_version_dependencies_test is     // marked as having an incompatible dependency.     $this->drupalGet('admin/modules');
    $this->assertSession()->pageTextContains('System incompatible module version test (>2.0) (incompatible with version 1.0)');
    $this->assertSession()->elementTextEquals('xpath', '//tr[@data-drupal-selector="edit-modules-system-incompatible-module-version-dependencies-test"]//span[@class="admin-missing"]', 'incompatible with');
    $this->assertSession()->fieldDisabled('modules[system_incompatible_module_version_dependencies_test][enable]');
  }

  /** * Tests enabling a module that depends on a module with an incompatible core version. */
  public function testIncompatibleCoreVersionDependency() {
    // Test that the system_incompatible_core_version_dependencies_test is     // marked as having an incompatible dependency.     $this->drupalGet('admin/modules');
    $this->assertSession()->pageTextContains('System core incompatible semver test (incompatible with this version of Drupal core)');
    $this->assertSession()->elementTextEquals('xpath', '//tr[@data-drupal-selector="edit-modules-system-incompatible-core-version-dependencies-test"]//span[@class="admin-missing"]', 'incompatible with');
    
'parent' => '',
    ]);

    $this->drupalGet($node->toUrl());
    // Publish the node. Revision count: 2.     $page->fillField('new_state', 'published');
    $page->pressButton('Apply');

    // Modify the layout.     $page->clickLink('Layout');
    $assert_session->checkboxChecked('revision');
    $assert_session->fieldDisabled('revision');

    $page->clickLink('Add block');
    $page->clickLink('Powered by Drupal');
    $page->pressButton('Add block');
    // Save the node as a draft. Revision count: 3.     $page->fillField('moderation_state[0][state]', 'draft');
    $page->pressButton('Save layout');

    // Block is visible on the revision page.     $assert_session->addressEquals("node/{$node->id()}/latest");
    $assert_session->pageTextContains('Powered by Drupal');

    
// 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->assertSession()->statusCodeEquals(200);
    
$this->submitForm($edit$this->getFormSubmitAction($entity$langcode));
        $storage = $this->container->get('entity_type.manager')
          ->getStorage($this->entityTypeId);
        $storage->resetCache([$this->entityId]);
        $entity = $storage->load($this->entityId);
        $this->assertFalse($this->manager->getTranslationMetadata($entity->getTranslation($langcode))->isPublished(), 'The translation has been correctly unpublished.');
      }
    }

    // Check that the last published translation cannot be unpublished.     $this->drupalGet($entity->toUrl('edit-form'));
    $this->assertSession()->fieldDisabled('content_translation[status]');
    $this->assertSession()->fieldValueEquals('content_translation[status]', TRUE);
  }

  /** * Tests the translation authoring information. */
  protected function doTestAuthoringInfo() {
    $storage = $this->container->get('entity_type.manager')
      ->getStorage($this->entityTypeId);
    $storage->resetCache([$this->entityId]);
    $entity = $storage->load($this->entityId);
    
// 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);
    $assert_session->fieldExists('Test config value');
    $assert_session->fieldValueEquals('Test config value', 'This is default value.');
    $assert_session->fieldExists('Attribute 1');
    $assert_session->fieldExists('Attribute 2');

    // Test if the edit machine name is not editable.     $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]');
    
// Navigate to home page and check that the pending revision is now the     // default revision and therefore visible.     $this->drupalGet('');
    $this->assertSession()->pageTextContains($pending_revision_body);

    // Check that revision is checked by default when content moderation is     // enabled.     $this->drupalGet('/admin/content/block/' . $block->id());
    $this->assertSession()->checkboxChecked('revision');
    $this->assertSession()->pageTextContains('Revisions must be required when moderation is enabled.');
    $this->assertSession()->fieldDisabled('revision');
  }

}
$node = $node_storage->loadUnchanged($nid);
    $node_file = File::load($node->{$field_name}->target_id);
    $this->assertFileExists($node_file->getFileUri());

    // Ensure the private file is available to the user who uploaded it.     $this->drupalGet($node_file->createFileUrl());
    $this->assertSession()->statusCodeEquals(200);

    // Ensure we can't change 'uri_scheme' field settings while there are some     // entities with uploaded files.     $this->drupalGet("admin/structure/types/manage/$type_name/fields/$field_id/storage");
    $this->assertSession()->fieldDisabled("edit-settings-uri-scheme-public");

    // Delete node and confirm that setting could be changed.     $node->delete();
    $this->drupalGet("admin/structure/types/manage/$type_name/fields/$field_id/storage");
    $this->assertSession()->fieldEnabled("edit-settings-uri-scheme-public");
  }

  /** * Tests that download restrictions on private files work on comments. */
  public function testPrivateFileComment() {
    
Home | Imprint | This part of the site doesn't use cookies.