buttonNotExists example

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

    // Ensure the file can be downloaded.     $this->drupalGet($node_file->createFileUrl());
    $this->assertSession()->statusCodeEquals(200);

    // Ensure the edit page has a remove button instead of an upload button.     $this->drupalGet("node/$nid/edit");
    $this->assertSession()->buttonNotExists('Upload');
    $this->assertSession()->buttonExists('Remove');
    $this->submitForm([], 'Remove');

    // Ensure the page now has an upload button instead of a remove button.     $this->assertSession()->buttonNotExists('Remove');
    $this->assertSession()->buttonExists('Upload');
    // Test label has correct 'for' attribute.     $input = $this->assertSession()->fieldExists("files[{$field_name}_0]");
    $this->assertSession()->elementExists('xpath', '//label[@for="' . $input->getAttribute('id') . '"]');

    // Save the node and ensure it does not have the file.
$link_titles = [];
    foreach ($links as $link) {
      $link_titles[] = $link->getText();
    }
    $expected_link_titles = ['Show Type Three media (selected)', 'Show Type One media', 'Show Type Two media', 'Show Type Four media'];
    $this->assertSame($link_titles$expected_link_titles);
    $this->drupalGet('admin/structure/types/manage/basic_page/form-display');

    // Ensure that the widget settings form is not displayed when only     // one media type is allowed.     $assert_session->pageTextContains('Single media type');
    $assert_session->buttonNotExists('field_single_media_type_settings_edit');

    $assert_session->buttonExists('field_twin_media_settings_edit')->press();
    $this->assertElementExistsAfterWait('css', '#field-twin-media .tabledrag-toggle-weight')->press();
    $assert_session->fieldExists('fields[field_twin_media][settings_edit_form][settings][media_types][type_one][weight]')->selectOption(0);
    $assert_session->fieldExists('fields[field_twin_media][settings_edit_form][settings][media_types][type_three][weight]')->selectOption(1);
    $assert_session->fieldExists('fields[field_twin_media][settings_edit_form][settings][media_types][type_four][weight]')->selectOption(2);
    $assert_session->fieldExists('fields[field_twin_media][settings_edit_form][settings][media_types][type_two][weight]')->selectOption(3);
    $assert_session->buttonExists('Save')->press();

    $this->drupalGet('node/add/basic_page');
    $this->openMediaLibraryForField('field_twin_media');
    
$this->assertNull($temp_store->getMetadata('test_view'), 'Shared tempstore data has been removed.');
    // Test we are redirected to the view listing page.     $this->assertSession()->addressEquals('admin/structure/views');

    // Log in with another user and make sure the view is locked and break.     $this->drupalGet('admin/structure/views/nojs/display/test_view/default/title');
    $this->submitForm([], 'Apply');
    $this->drupalLogin($this->adminUser);

    $this->drupalGet('admin/structure/views/view/test_view/edit');
    // Test that save and cancel buttons are not shown.     $this->assertSession()->buttonNotExists('Save');
    $this->assertSession()->buttonNotExists('Cancel');
    // Test we have the break lock link.     $this->assertSession()->linkByHrefExists('admin/structure/views/view/test_view/break-lock');
    // Break the lock.     $this->clickLink('break this lock');
    $this->submitForm([], 'Break lock');
    // Test that save and cancel buttons are shown.     $this->assertSession()->buttonExists('Save');
    $this->assertSession()->buttonExists('Cancel');
    // Test we can save the view.     $this->drupalGet('admin/structure/views/view/test_view/edit');
    
$assert_session = $this->assertSession();
    $assert_session->pageTextMatches('/The media items? ha(s|ve) been created but ha(s|ve) not yet been saved. Fill in any required fields and save to add (it|them) to the media library./');
    $assert_session->elementAttributeContains('css', $selector, 'aria-label', 'Added media items');

    $fields = $this->assertElementExistsAfterWait('css', '[data-drupal-selector="edit-media-' . $index . '-fields"]');
    $assert_session->elementNotExists('css', '.js-media-library-menu');

    // Assert extraneous components were removed in     // FileUploadForm::hideExtraSourceFieldComponents().     $assert_session->elementNotExists('css', '[data-drupal-selector$="preview"]', $fields);
    $assert_session->buttonNotExists('Remove', $fields);
    $assert_session->elementNotExists('css', '[data-drupal-selector$="filename"]', $fields);
  }

  /** * Asserts that media was not added, i.e. due to a validation error. */
  protected function assertNoMediaAdded() {
    // Assert the focus is shifted to the first tabbable element of the add     // form, which should be the source field.     $this->assertJsCondition('jQuery(tabbable.tabbable(document.getElementById("media-library-add-form-wrapper"))[0]).is(":focus")');

    
public function testWidgetViews() {
    $assert_session = $this->assertSession();
    $page = $this->getSession()->getPage();

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

    $this->openMediaLibraryForField('field_unlimited_media');

    // Assert the 'Apply filter' button is not moved to the button pane.     $button_pane = $assert_session->elementExists('css', '.ui-dialog-buttonpane');
    $assert_session->buttonExists('Insert selected', $button_pane);
    $assert_session->buttonNotExists('Apply filters', $button_pane);

    // Assert the pager works as expected.     // An active pager item is not linked and contains "Page #" as text.     $assert_session->elementTextContains('css', '.js-media-library-view .js-pager__items > li:nth-of-type(1)', 'Page 1');
    $assert_session->elementNotExists('css', '.js-media-library-view .js-pager__items > li:nth-of-type(1) a');
    $assert_session->elementExists('css', '.js-media-library-view .js-pager__items > li:nth-of-type(2) a');
    $this->assertCount(24, $this->getCheckboxes());
    $page->clickLink('Next page');
    $this->waitForElementTextContains('.js-media-library-view .js-pager__items > li:nth-of-type(2)', 'Page 2');
    $assert_session->elementExists('css', '.js-media-library-view .js-pager__items > li:nth-of-type(1) a');
    $assert_session->elementNotExists('css', '.js-media-library-view .js-pager__items > li:nth-of-type(2) a');
    


  /** * Tests removing a display. */
  public function testRemoveDisplay() {
    $view = $this->randomView();
    $path_prefix = 'admin/structure/views/view/' . $view['id'] . '/edit';

    // Make sure there is no delete button on the default display.     $this->drupalGet($path_prefix . '/default');
    $this->assertSession()->buttonNotExists('edit-displays-settings-settings-content-tab-content-details-top-actions-delete');

    $this->drupalGet($path_prefix . '/page_1');
    $this->assertSession()->buttonExists('edit-displays-settings-settings-content-tab-content-details-top-actions-delete');

    // Delete the page, so we can test the undo process.     $this->drupalGet($path_prefix . '/page_1');
    $this->submitForm([], 'Delete Page');
    $this->assertSession()->buttonExists('edit-displays-settings-settings-content-tab-content-details-top-actions-undo-delete');
    // Test that the display link is marked as to be deleted.     $this->assertSession()->elementExists('xpath', "//a[contains(@href, '{$path_prefix}/page_1') and contains(@class, 'views-display-deleted-link')]");

    
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary2_id . '/overview');
    $assert_session->statusCodeEquals(403);

    // Log in as a user with only the overview permission, neither edit nor     // delete operations must be available and no Save button.     $overview_only_user = $this->drupalCreateUser(['access taxonomy overview']);
    $this->drupalLogin($overview_only_user);
    $this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary1_id . '/overview');
    $assert_session->statusCodeEquals(200);
    $assert_session->linkNotExists('Edit');
    $assert_session->linkNotExists('Delete');
    $assert_session->buttonNotExists('Save');
    $assert_session->buttonNotExists('Reset to alphabetical');
    $assert_session->pageTextContains('Weight');
    $assert_session->fieldNotExists('Weight');
    $assert_session->linkNotExists('Add term');
    $assert_session->pageTextContains($no_edit_help_text);

    // Visit vocabulary overview without terms. 'Add term' should not be shown.     $this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary2_id . '/overview');
    $assert_session->statusCodeEquals(200);
    $assert_session->pageTextContains('No terms available');
    $assert_session->linkNotExists('Add term');

    
$this->assertTrue($it_revision->hasTranslation('it'));

    // Check that translations cannot be deleted in drafts.     $overview_url = $entity->toUrl('drupal:content-translation-overview');
    $this->drupalGet($overview_url);
    $it_delete_url = $this->getDeleteUrl($it_revision);
    $it_delete_href = $it_delete_url->toString();
    $this->assertSession()->linkByHrefNotExists($it_delete_href);
    $warning = 'The "Delete translation" action is only available for published translations.';
    $this->assertSession()->statusMessageContains($warning, 'warning');
    $this->drupalGet($this->getEditUrl($it_revision));
    $this->assertSession()->buttonNotExists('Delete translation');

    // Publish the translation and verify it can be deleted.     $edit = [
      'title[0][value]' => "Test $index.3 IT",
      'moderation_state[0][state]' => 'published',
    ];
    $this->submitForm($edit, 'Save (this translation)');
    $entity = $this->storage->loadUnchanged($id);
    $this->assertTrue($entity->hasTranslation('it'));
    $it_revision = $this->loadRevisionTranslation($entity, 'it');
    $this->assertTrue($it_revision->hasTranslation('it'));
    
/** * Tests importing configuration. */
  public function testImport() {
    $name = 'system.site';
    $dynamic_name = 'config_test.dynamic.new';
    /** @var \Drupal\Core\Config\StorageInterface $sync */
    $sync = $this->container->get('config.storage.sync');

    $this->drupalGet('admin/config/development/configuration');
    $this->assertSession()->pageTextContains('The staged configuration is identical to the active configuration.');
    $this->assertSession()->buttonNotExists('Import all');

    // Create updated configuration object.     $new_site_name = 'Config import test ' . $this->randomString();
    $this->prepareSiteNameUpdate($new_site_name);
    $this->assertTrue($sync->exists($name)$name . ' found.');

    // Create new config entity.     $original_dynamic_data = [
      'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651',
      'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(),
      'status' => TRUE,
      
'title[0][value]' => 'Some moderated content',
      'body[0][value]' => 'First version of the content.',
      'moderation_state[0][state]' => 'draft',
    ], 'Save');

    // The archived state is not used yet, so can still be deleted.     $this->drupalGet($paths['archived_state']);
    $this->assertSession()->buttonExists('Delete');

    // The workflow is being used, so can't be deleted.     $this->drupalGet($paths['editorial_workflow']);
    $this->assertSession()->buttonNotExists('Delete');
    $this->assertSession()->statusCodeEquals(200);
    $this->assertSession()->pageTextContains($messages['editorial_workflow']);

    $node = $this->drupalGetNodeByTitle('Some moderated content');
    $this->drupalGet('node/' . $node->id() . '/edit');
    $this->submitForm(['moderation_state[0][state]' => 'published'], 'Save');
    $this->drupalGet('node/' . $node->id() . '/edit');
    $this->submitForm(['moderation_state[0][state]' => 'archived'], 'Save');

    // Now the archived state is being used so it can not be deleted either.     foreach ($paths as $type => $path) {
      
/** * Tests that profiles with no system.site do not work. */
  public function testConfigSync() {
    $this->htmlOutput(NULL);
    $this->assertSession()->titleEquals('Configuration validation | Drupal');
    $this->assertSession()->pageTextContains('The configuration synchronization failed validation.');
    $this->assertSession()->pageTextContains('This import does not contain system.site configuration, so has been rejected.');

    // Ensure there is no continuation button.     $this->assertSession()->pageTextNotContains('Save and continue');
    $this->assertSession()->buttonNotExists('edit-submit');
  }

  /** * {@inheritdoc} */
  protected function getConfigTarball() {
    return __DIR__ . '/../../../fixtures/config_install/testing_config_install.tar.gz';
  }

}

    else {
      $this->assertSession()->fieldNotExists('subject[0][value]');
    }

    if ($contact !== NULL && is_array($contact)) {
      $edit += $contact;
    }
    switch ($preview_mode) {
      case DRUPAL_REQUIRED:
        // Preview required so no save button should be found.         $this->assertSession()->buttonNotExists('Save');
        $this->submitForm($edit, 'Preview');
        // Don't break here so that we can test post-preview field presence and         // function below.       case DRUPAL_OPTIONAL:
        $this->assertSession()->buttonExists('Preview');
        $this->assertSession()->buttonExists('Save');
        $this->submitForm($edit, 'Save');
        break;

      case DRUPAL_DISABLED:
        $this->assertSession()->buttonNotExists('Preview');
        
$this->submitForm($view, 'Save and edit');
    $this->assertSession()->buttonExists('edit-displays-top-add-display-embed');

    $edit = [
      'ui_show_display_embed' => FALSE,
    ];
    $this->drupalGet('admin/structure/views/settings');
    $this->submitForm($edit, 'Save configuration');

    $this->drupalGet('admin/structure/views/add');
    $this->submitForm($view, 'Save and edit');
    $this->assertSession()->buttonNotExists('edit-displays-top-add-display-embed');

    // Configure to hide/show the sql at the preview.     $edit = [
      'ui_show_sql_query_enabled' => FALSE,
    ];
    $this->drupalGet('admin/structure/views/settings');
    $this->submitForm($edit, 'Save configuration');

    $view['id'] = strtolower($this->randomMachineName());
    $this->drupalGet('admin/structure/views/add');
    $this->submitForm($view, 'Save and edit');

    
$this->submitForm([], 'Uninstall');
    $this->assertSession()->pageTextContains('The selected modules have been uninstalled.');
    $this->assertSession()->pageTextNotContains('Manages the creation, configuration, and display of the main site content.');

    // Ensure a 404 is returned when accessing a non-existent entity type.     $this->drupalGet('admin/modules/uninstall/entity/node');
    $this->assertSession()->statusCodeEquals(404);

    // Test an entity type which does not have any existing entities.     $this->drupalGet('admin/modules/uninstall/entity/entity_test_no_label');
    $this->assertSession()->pageTextContains('There are 0 entity test without label entities to delete.');
    $this->assertSession()->buttonNotExists("Delete all entity test without label entities");

    // Test an entity type without a label.     /** @var \Drupal\Core\Entity\EntityStorageInterface $storage */
    $storage = $this->container->get('entity_type.manager')
      ->getStorage('entity_test_no_label');
    $storage->create([
      'id' => mb_strtolower($this->randomMachineName()),
      'name' => $this->randomMachineName(),
    ])->save();
    $this->drupalGet('admin/modules/uninstall/entity/entity_test_no_label');
    $this->assertSession()->pageTextContains('This will delete 1 entity test without label.');
    

  public function testDisableDisplay() {
    $view = $this->randomView();
    $path_prefix = 'admin/structure/views/view/' . $view['id'] . '/edit';

    // Verify that the disabled display css class does not appear after initial     // adding of a view.     $this->drupalGet($path_prefix);
    $this->assertSession()->elementNotExists('xpath', "//div[contains(@class, 'views-display-disabled')]");
    $this->assertSession()->buttonExists('edit-displays-settings-settings-content-tab-content-details-top-actions-disable');
    $this->assertSession()->buttonNotExists('edit-displays-settings-settings-content-tab-content-details-top-actions-enable');

    // Verify that the disabled display css class appears once the display is     // marked as such.     $this->submitForm([], 'Disable Page');
    $this->assertSession()->elementExists('xpath', "//div[contains(@class, 'views-display-disabled')]");
    $this->assertSession()->buttonNotExists('edit-displays-settings-settings-content-tab-content-details-top-actions-disable');
    $this->assertSession()->buttonExists('edit-displays-settings-settings-content-tab-content-details-top-actions-enable');

    // Verify that the disabled display css class does not appears once the     // display is enabled again.     $this->submitForm([], 'Enable Page');
    
Home | Imprint | This part of the site doesn't use cookies.