fieldEnabled example

    // is still disabled, since the less privileged user should not be able to     // edit content that does not have an assigned format.     $this->drupalLogin($this->webUser);
    $this->drupalGet('node/' . $node->id() . '/edit');
    $this->assertSession()->fieldDisabled($body_value_key);
    $this->assertSession()->fieldValueEquals($body_value_key, 'This field has been disabled because you do not have sufficient permissions to edit it.');

    // Log back in as the filter administrator and verify that the body field     // can be edited.     $this->drupalLogin($this->filterAdminUser);
    $this->drupalGet('node/' . $node->id() . '/edit');
    $this->assertSession()->fieldEnabled($body_value_key);
    $this->assertSession()->fieldExists($body_format_key);

    // Verify that trying to save the node without selecting a new text format     // produces an error message, and does not result in the node being saved.     $old_title = $new_edit['title[0][value]'];
    $new_title = $this->randomMachineName(8);
    $edit = [];
    $edit['title[0][value]'] = $new_title;
    $this->drupalGet('node/' . $node->id() . '/edit');
    $this->submitForm($edit, 'Save');
    $this->assertSession()->statusMessageContains('Text format field is required.', 'error');
    
    $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() {
    $user = $this->drupalCreateUser(['access comments']);

    // Grant the admin user required comment permissions.     $roles = $this->adminUser->getRoles();
    user_role_grant_permissions($roles[1]['administer comment fields', 'administer comments']);

    
// 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,
      'settings[node][article][fields][field_article_text]' => TRUE,
    ];
    $this->assertSettings('node', 'article', TRUE, $edit);
    $this->drupalGet($path);
    $this->assertSession()->fieldEnabled('edit-translatable');
    $this->assertSession()->checkboxChecked('edit-translatable');
    $this->assertSession()->pageTextNotContains('To enable translation of this field, enable language support for this type.');
  }

  /** * Tests the translatable settings checkbox for untranslatable entities. */
  public function testNonTranslatableTranslationSettingsUI() {
    $this->drupalGet('admin/config/regional/content-language');
    $this->assertSession()->fieldNotExists('settings[entity_test][entity_test][translatable]');
  }

}


  /** * Asserts that a textarea with a given ID exists and is not disabled. * * @param string $id * The HTML ID of the textarea. * * @internal */
  protected function assertEnabledTextarea(string $id): void {
    $textarea = $this->assertSession()->fieldEnabled($id);
    $this->assertSame('textarea', $textarea->getTagName());
  }

  /** * Asserts that a textarea with a given ID has been disabled from editing. * * @param string $id * The HTML ID of the textarea. * * @internal */
  
      'common_test (<=2.4-beta2)',
      // Testing extra version. Compatible.       'common_test (>2.4-beta2)',
      // Testing extra version. Incompatible.       'common_test (>2.4-rc0)',
    ];
    \Drupal::state()->set('system_test.dependencies', $dependencies);
    $n = count($dependencies);
    for ($i = 0; $i < $n$i++) {
      $this->drupalGet('admin/modules');
      if ($i % 2 == 0) {
        $this->assertSession()->fieldEnabled('edit-modules-module-test-enable');
      }
      else {
        $this->assertSession()->fieldDisabled('edit-modules-module-test-enable');
      }
    }
  }

}
'name' => 'System no module version test',
      'dependencies' => ['system_no_module_version_dependency_test(>1.x)'],
    ];
    $path = $this->siteDirectory . '/modules/system_no_module_version_test';
    mkdir($path, 0777, TRUE);
    file_put_contents("$path/system_no_module_version_test.info.yml", Yaml::encode($info));

    // Ensure that the module list page is displayed without errors.     $this->drupalGet('admin/modules');
    $this->assertSession()->pageTextContains('System no module version test');
    $this->assertSession()->pageTextContains('System no module version dependency test (>1.x) (incompatible with version');
    $this->assertSession()->fieldEnabled('modules[system_no_module_version_dependency_test][enable]');
    $this->assertSession()->fieldDisabled('modules[system_no_module_version_test][enable]');

    // Remove the version requirement from the the dependency definition     $info = [
      'type' => 'module',
      'core_version_requirement' => '*',
      'name' => 'System no module version test',
      'dependencies' => ['system_no_module_version_dependency_test'],
    ];

    $path = $this->siteDirectory . '/modules/system_no_module_version_test';
    
Home | Imprint | This part of the site doesn't use cookies.