fillField example

public function testFileMediaRevision() {
    $assert = $this->assertSession();

    $uri = 'temporary://foo.txt';
    file_put_contents($uri$this->randomString(128));

    $this->createMediaType('file', ['id' => 'document', 'new_revision' => TRUE]);

    // Create a media item.     $this->drupalGet('/media/add/document');
    $page = $this->getSession()->getPage();
    $page->fillField('Name', 'Foobar');
    $page->attachFileToField('File', $this->container->get('file_system')->realpath($uri));
    $page->pressButton('Save');
    $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);

    
$path = $file_system->copy($this->image->uri, 'public://');
      $path = $file_system->realpath($path);
      $this->assertNotEmpty($path);
      $this->assertFileExists($path);

      $filenames[] = $file_system->basename($path);
      $remote_paths[] = $this->getSession()
        ->getDriver()
        ->uploadFileAndGetRemoteFilePath($path);
    }
    $page = $this->getSession()->getPage();
    $page->fillField('Add files', implode("\n", $remote_paths));
    $this->assertMediaAdded();
    $assert_session = $this->assertSession();
    foreach ($filenames as $i => $filename) {
      $assert_session->fieldValueEquals("media[$i][fields][name][0][value]", $filename);
      $page->fillField("media[$i][fields][field_media_test_image][0][alt]", $filename);
    }
  }

  /** * Tests that the Media Library constrains the number of selected items. * * @param string|null $selected_operation * The operation of the button to click. For example, if this is "insert", * the "Save and insert" button will be pressed. If NULL, the "Save" button * will be pressed. * * @dataProvider providerWidgetOverflow */

  public function testCopyFieldValue() {
    $this->drupalGet('/system-test/copy-field-value-test-form');
    $page = $this->getSession()->getPage();
    $source_field_selector = 'edit-source-field';
    $target_field = $page->find('css', '#edit-target-field');

    $random_string = $this->randomString();
    // Ensure that after source field has been filled, target field is filled     // with the same value.     $page->fillField($source_field_selector$random_string);
    $target_field->focus();
    $this->assertEquals($target_field->getValue()$random_string);

    // Ensure that the target value doesn't change after it has been focused.     $page->fillField($source_field_selector, '');
    $target_field->focus();
    $this->assertEquals($target_field->getValue()$random_string);
  }

}
Yaml::parseFile('core/profiles/standard/config/install/filter.format.full_html.yml')
    )->save();
    FilterFormat::create(
      Yaml::parseFile('core/profiles/standard/config/install/filter.format.basic_html.yml')
    )->save();

    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();

    // Add a node with text rendered via the Plain Text format.     $this->drupalGet('node/add');
    $page->fillField('title[0][value]', 'My test content');
    $page->fillField('body[0][value]', '<foo bar="baz">⬅️✌️➡️</foo><p><a style="color:#ff0000;" foo="bar" hreflang="en" href="https://example.com"><abbr title="National Aeronautics and Space Administration">NASA</abbr> is an acronym.</a></p>');
    $page->pressButton('Save');

    // Configure Full HTML text format to use CKEditor 5.     $this->drupalGet('admin/config/content/formats/manage/full_html');
    $page->checkField('roles[authenticated]');
    $page->selectFieldOption('editor[editor]', 'ckeditor5');
    $assert_session->assertWaitOnAjaxRequest();
    $page->pressButton('Save configuration');
    $this->assertTrue($assert_session->waitForText('The text format Full HTML has been updated.'));

    
$media_type = $this->createMediaType('test', [
      'queue_thumbnail_downloads' => FALSE,
    ]);

    $this->drupalGet('media/add');
    $assert_session->statusCodeEquals(200);
    $assert_session->addressEquals('media/add/' . $media_type->id());
    $assert_session->elementNotExists('css', '#edit-revision');

    // Tests media add form.     $media_name = $this->randomMachineName();
    $page->fillField('name[0][value]', $media_name);
    $revision_log_message = $this->randomString();
    $page->fillField('revision_log_message[0][value]', $revision_log_message);
    $source_field = $this->randomString();
    $page->fillField('field_media_test[0][value]', $source_field);
    $page->pressButton('Save');
    $media_id = $this->container->get('entity_type.manager')
      ->getStorage('media')
      ->getQuery()
      ->accessCheck(FALSE)
      ->execute();
    $media_id = reset($media_id);
    
$page = $session->getPage();
    $assert_session = $this->assertSession();

    $this->drupalGet('admin/structure/media');
    $assert_session->pageTextContains('No media types available. Add media type.');
    $assert_session->linkExists('Add media type');

    // Test the creation of a media type using the UI.     $name = $this->randomMachineName();
    $description = $this->randomMachineName();
    $this->drupalGet('admin/structure/media/add');
    $page->fillField('label', $name);
    $machine_name = strtolower($name);
    $this->assertJsCondition("jQuery('.machine-name-value').html() == '$machine_name'");
    $page->selectFieldOption('source', 'test');
    $this->assertJsCondition("jQuery('.form-item-source-configuration-test-config-value').length > 0");
    $page->fillField('description', $description);
    $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 ' . $name . ' has been added.');
    
$url = '/admin/structure/views/view/content';
    $this->drupalGet($url);

    $page = $this->getSession()->getPage();

    // Open the 'Add filter dialog'.     $page->clickLink('views-add-filter');

    // Test filtering by type.     $web_assert->waitForField('override[controls][group]');
    $page->fillField('override[controls][group]', 'content');
    $only_content_rows = $this->waitForOnlyContentRows();
    $this->assertTrue($only_content_rows);

    // Search for a specific title and test that this is now the only one shown.     $page->fillField('override[controls][options_search]', 'body (body)');
    $filtering_done = $this->waitForVisibleElementCount(1, 'tr.filterable-option');
    $this->assertTrue($filtering_done);

    // Select the body field and apply the choice.     $page->checkField('name[node__body.body_value]');
    $page->find('css', '.ui-dialog .ui-dialog-buttonpane')->pressButton('Add and configure filter criteria');
    
$media_type = $this->createMediaType('file');
    $media_type_id = $media_type->id();
    $this->assertSame('txt doc docx pdf', FieldConfig::load("media.$media_type_id.field_media_file")->get('settings')['file_extensions']);

    $this->drupalGet("admin/structure/media/manage/$media_type_id/fields/media.$media_type_id.field_media_file");

    // File extension field exists.     $assert_session->fieldExists('Allowed file extensions');

    // Add another extension.     $page->fillField('settings[file_extensions]', 'txt, doc, docx, pdf, odt');

    $page->pressButton('Save settings');
    $this->drupalGet("admin/structure/media/manage/$media_type_id/fields/media.$media_type_id.field_media_file");

    // Verify that new extension is present.     $assert_session->fieldValueEquals('settings[file_extensions]', 'txt, doc, docx, pdf, odt');
    $this->assertSame('txt doc docx pdf odt', FieldConfig::load("media.$media_type_id.field_media_file")->get('settings')['file_extensions']);
  }

  /** * Ensure source field deletion is not possible. */
$assert->elementExists('named', ['link', 'Administer content'])->click();
    $dialog = $assert->waitForElementVisible('css', '.views-test-modal');

    $session = $this->getSession();
    // Ensure that the Content we're testing for is present.     $html = $session->getPage()->getHtml();
    $this->assertStringContainsString('Page One', $html);
    $this->assertStringContainsString('Page Two', $html);

    // Search for "Page One".     $session->getPage()->fillField('title', 'Page One');
    $assert->elementExists('css', '.ui-dialog-buttonpane')->pressButton('Filter');
    $this->assertSession()->assertWaitOnAjaxRequest();

    // Verify that only the "Page One" Node is present.     $html = $session->getPage()->getHtml();
    $this->assertStringContainsString('Page One', $html);
    $this->assertStringNotContainsString('Page Two', $html);

    // Close and re-open the modal.     $assert->buttonExists('Close', $dialog)->press();
    $assert->elementExists('named', ['link', 'Administer content'])->click();
    
    $this->drupalGet('admin/config/content/formats/manage/unicorn');

    // Enable media embed to confirm a format not using CKEditor 5 will not     // trigger an AJAX rebuild.     $this->assertTrue($page->hasUncheckedField('filters[media_embed][status]'));
    $page->checkField('filters[media_embed][status]');
    $this->assertSame(0, $this->getAjaxResponseCount());

    // Confirm that AJAX updates happen when attempting to switch to CKEditor 5,     // even if prevented from doing so by validation.     $this->drupalGet('admin/config/content/formats/add');
    $page->fillField('name', 'trigger validator');
    $assert_session->waitForText('Machine name');
    $page->checkField('roles[authenticated]');

    // Enable a filter that is incompatible with CKEditor 5, so validation is     // triggered when attempting to switch.     $incompatible_filter_name = 'filters[filter_incompatible][status]';
    $this->assertTrue($page->hasUncheckedField($incompatible_filter_name));
    $page->checkField($incompatible_filter_name);
    $this->assertSame(0, $this->getAjaxResponseCount());

    $page->selectFieldOption('editor[editor]', 'ckeditor5');
    
->set('default', 'views_ui_test_theme')
      ->save();

    $page = $this->getSession()->getPage();
    $assert_session = $this->assertSession();

    $this->drupalGet('admin/structure/views/view/user_admin_people');
    $assert_session->pageTextContains('This is text added to the display tabs at the top');
    $assert_session->pageTextContains('This is text added to the display edit form');
    $page->clickLink('User: Name (Username)');
    $assert_session->waitForElementVisible('css', '.views-ui-dialog');
    $page->fillField('Label', 'New Title');
    $page->find('css', '.ui-dialog-buttonset button:contains("Apply")')->press();
    $assert_session->waitForElementRemoved('css', '.views-ui-dialog');
    $assert_session->pageTextContains('This is text added to the display tabs at the top');
    $assert_session->pageTextContains('This is text added to the display edit form');
  }

}
$page = $this->getSession()->getPage();
    $page->pressButton("{$float_field}_settings_edit");
    $assert_session->waitForElement('css', '.ajax-new-content');
    $edit = [
      "fields[{$float_field}][settings_edit_form][settings][prefix_suffix]" => TRUE,
      "fields[{$float_field}][settings_edit_form][settings][scale]" => $scale,
      "fields[{$float_field}][settings_edit_form][settings][decimal_separator]" => $decimal_separator,
      "fields[{$float_field}][settings_edit_form][settings][thousand_separator]" => $thousand_separator,
    ];
    foreach ($edit as $name => $value) {
      $page->fillField($name$value);
    }
    $page->pressButton("{$float_field}_plugin_settings_update");
    $assert_session->waitForElement('css', '.field-plugin-summary-cell > .ajax-new-content');
    $this->submitForm([], 'Save');

    // Check number_decimal and number_unformatted formatters behavior.     $this->drupalGet('node/' . $node->id());
    $float_formatted = number_format($random_float$scale$decimal_separator$thousand_separator);
    $this->assertSession()->responseContains("$prefix$float_formatted$suffix");
    $this->assertSession()->responseContains((string) $random_integer);

    
/** * Tests the exposed form with a pager. */
  public function testExposedFilterPagination() {
    $this->drupalCreateContentType(['type' => 'post']);
    // Create some random nodes.     for ($i = 0; $i < 5; $i++) {
      $this->drupalCreateNode(['type' => 'post']);
    }

    $this->drupalGet('test_exposed_form_pager');
    $this->getSession()->getPage()->fillField('type[]', 'post');
    $this->getSession()->getPage()->fillField('created[min]', '-1 month');
    $this->getSession()->getPage()->fillField('created[max]', '+1 month');

    // Ensure the filters can be applied.     $this->getSession()->getPage()->pressButton('Apply');
    $this->assertTrue($this->assertSession()->optionExists('type[]', 'post')->isSelected());
    $this->assertSession()->fieldValueEquals('created[min]', '-1 month');
    $this->assertSession()->fieldValueEquals('created[max]', '+1 month');

    // Ensure the filters are still applied after pressing next.     $this->clickLink('Next ›');
    
'access content',
      'administer content types',
      'administer node fields',
      'administer node form display',
      'create page content',
    ]));
    $this->drupalGet('/admin/structure/types/manage/page/form-display');
    $assert_session->pageTextContains('Autocomplete suggestion list size: 1');
    // Click on the widget settings button to open the widget settings form.     $this->submitForm([]$field_name . "_settings_edit");
    $this->assertSession()->waitForElement('css', sprintf('[name="fields[%s][settings_edit_form][settings][match_limit]"]', $field_name));
    $page->fillField('Number of results', 2);
    $page->pressButton('Save');
    $assert_session->pageTextContains('Your settings have been saved.');
    $assert_session->pageTextContains('Autocomplete suggestion list size: 2');

    $this->drupalGet('node/add/page');

    $this->doAutocomplete($field_name);
    $this->assertCount(2, $page->findAll('css', '.ui-autocomplete li'));
  }

  /** * Tests that the autocomplete widget knows about the entity its attached to. * * Ensures that the entity the autocomplete widget stores the entity it is * rendered on, and is available in the autocomplete results' AJAX request. */
'administer blocks',
      'configure any layout',
      'administer node display',
      'configure all bundle_with_section_field node layout overrides',
    ]));

    // Add a block to the defaults.     $this->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default');
    $page->clickLink('Manage layout');
    $page->clickLink('Add block');
    $page->clickLink('Powered by Drupal');
    $page->fillField('settings[label]', 'Default block title');
    $page->checkField('settings[label_display]');
    $page->pressButton('Add block');
    $page->pressButton('Save layout');

    // Check the block is on the node page.     $this->drupalGet('node/1');
    $assert_session->pageTextContains('Default block title');

    // When we edit the layout, it gets the static blocks.     $this->drupalGet('node/1/layout');
    $assert_session->pageTextContains('Test static block title');
    
Home | Imprint | This part of the site doesn't use cookies.