reverted: --- b/core/modules/taxonomy/tests/modules/taxonomy_test/taxonomy_test.module +++ a/core/modules/taxonomy/tests/modules/taxonomy_test/taxonomy_test.module @@ -45,8 +45,4 @@ if (\Drupal::state()->get('taxonomy_test.disable_parent_form_element', FALSE)) { $form['relations']['parent']['#disabled'] = TRUE; } - - if (\Drupal::state()->get('taxonomy_test.disable_required_name', FALSE)) { - $form['name']['widget'][0]['value']['#required'] = FALSE; - } } reverted: --- b/core/modules/taxonomy/tests/src/Functional/TermTest.php +++ a/core/modules/taxonomy/tests/src/Functional/TermTest.php @@ -447,17 +447,6 @@ ])); $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add'); $this->assertSession()->pageTextNotContains('Save and go to list'); - - // Test empty name does not throw a PHP warning. - // Make field optional to force the scenario. - \Drupal::state()->set('taxonomy_test.disable_required_name', TRUE); - $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add'); - $edit = [ - 'description[0][value]' => $this->randomMachineName(100), - ]; - - $this->submitForm($edit, 'Save'); - $this->assertSession()->statusMessageContains('Name field is required.', 'error'); } /** only in patch2: unchanged: --- /dev/null +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyImageTest.php @@ -0,0 +1,95 @@ +vocabulary = $this->createVocabulary(); + $entity_type = 'taxonomy_term'; + $name = 'field_test'; + FieldStorageConfig::create([ + 'field_name' => $name, + 'entity_type' => $entity_type, + 'type' => 'image', + ])->save(); + FieldConfig::create([ + 'field_name' => $name, + 'entity_type' => $entity_type, + 'bundle' => $this->vocabulary->id(), + 'settings' => [], + ])->save(); + /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */ + $display_repository = \Drupal::service('entity_display.repository'); + $display_repository->getFormDisplay($entity_type, $this->vocabulary->id()) + ->setComponent($name, [ + 'type' => 'image_image', + 'settings' => [], + ]) + ->save(); + } + + public function testTaxonomyImageUpload() { + $user = $this->drupalCreateUser(['administer taxonomy']); + $this->drupalLogin($user); + + // Create a term and upload the image. + $files = $this->drupalGetTestFiles('image'); + $image = array_pop($files); + + // Ensure that file can be uploaded before taxonomy term has a name. + $edit = [ + 'files[field_test_0]' => \Drupal::service('file_system')->realpath($image->uri), + ]; + $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add'); + $this->submitForm($edit, 'Upload'); + + $edit = [ + 'name[0][value]' => $this->randomMachineName(), + 'field_test[0][alt]' => $this->randomMachineName(), + ]; + $this->submitForm($edit, 'Save'); + $terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadByProperties(['name' => $edit['name[0][value]']]); + $term = reset($terms); + $this->assertSession()->pageTextContains('Created new term ' . $term->getName() . '.'); + } + +}