diff --git a/core/modules/taxonomy/src/Tests/TaxonomyTestTrait.php b/core/modules/taxonomy/src/Tests/TaxonomyTestTrait.php index 744ab1b..1bac6c1 100644 --- a/core/modules/taxonomy/src/Tests/TaxonomyTestTrait.php +++ b/core/modules/taxonomy/src/Tests/TaxonomyTestTrait.php @@ -9,6 +9,9 @@ /** * Provides common helper methods for Taxonomy module tests. + * + * @deprecated Scheduled for removal in Drupal 9.0.0. + * Use \Drupal\Tests\taxonomy\Functional\TaxonomyTestTrait instead. */ trait TaxonomyTestTrait { diff --git a/core/modules/taxonomy/src/Tests/RssTest.php b/core/modules/taxonomy/tests/src/Functional/RssTest.php similarity index 98% rename from core/modules/taxonomy/src/Tests/RssTest.php rename to core/modules/taxonomy/tests/src/Functional/RssTest.php index 81a397d..be0d59d 100644 --- a/core/modules/taxonomy/src/Tests/RssTest.php +++ b/core/modules/taxonomy/tests/src/Functional/RssTest.php @@ -1,6 +1,6 @@ $this->randomMachineName(), + 'description' => $this->randomMachineName(), + 'vid' => Unicode::strtolower($this->randomMachineName()), + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, + 'weight' => mt_rand(0, 10), + ]); + $vocabulary->save(); + return $vocabulary; + } + + /** + * Returns a new term with random properties in vocabulary $vid. + * + * @param \Drupal\taxonomy\Entity\Vocabulary $vocabulary + * The vocabulary object. + * @param array $values + * (optional) An array of values to set, keyed by property name. If the + * entity type has bundles, the bundle key has to be specified. + * + * @return \Drupal\taxonomy\Entity\Term + * The new taxonomy term object. + */ + public function createTerm(Vocabulary $vocabulary, $values = []) { + $filter_formats = filter_formats(); + $format = array_pop($filter_formats); + $term = Term::create($values + [ + 'name' => $this->randomMachineName(), + 'description' => [ + 'value' => $this->randomMachineName(), + // Use the first available text format. + 'format' => $format->id(), + ], + 'vid' => $vocabulary->id(), + 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, + ]); + $term->save(); + return $term; + } + +} diff --git a/core/modules/taxonomy/src/Tests/TaxonomyTranslationTestTrait.php b/core/modules/taxonomy/tests/src/Functional/TaxonomyTranslationTestTrait.php similarity index 98% rename from core/modules/taxonomy/src/Tests/TaxonomyTranslationTestTrait.php rename to core/modules/taxonomy/tests/src/Functional/TaxonomyTranslationTestTrait.php index 3607fc6..fc3cea7 100644 --- a/core/modules/taxonomy/src/Tests/TaxonomyTranslationTestTrait.php +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyTranslationTestTrait.php @@ -1,6 +1,6 @@