diff --git a/core/modules/rdf/tests/src/Functional/EntityReferenceFieldAttributesTest.php b/core/modules/rdf/tests/src/Functional/EntityReferenceFieldAttributesTest.php index 41a03657af9f1d8b4d22acc507fe8ea660782d1c..629c4aa810155475847ba92190839e18b221957a 100644 --- a/core/modules/rdf/tests/src/Functional/EntityReferenceFieldAttributesTest.php +++ b/core/modules/rdf/tests/src/Functional/EntityReferenceFieldAttributesTest.php @@ -3,7 +3,7 @@ namespace Drupal\Tests\rdf\Functional; use Drupal\Core\Field\FieldStorageDefinitionInterface; -use Drupal\taxonomy\Tests\TaxonomyTestBase; +use Drupal\Tests\taxonomy\Functional\TaxonomyTestBase; /** * Tests RDFa markup generation for taxonomy term fields. diff --git a/core/modules/rdf/tests/src/Functional/TaxonomyAttributesTest.php b/core/modules/rdf/tests/src/Functional/TaxonomyAttributesTest.php index ea74ce5c27b060784411a78722b622857903f4be..346ffb7eb9dca78586822d796ce4737117df870d 100644 --- a/core/modules/rdf/tests/src/Functional/TaxonomyAttributesTest.php +++ b/core/modules/rdf/tests/src/Functional/TaxonomyAttributesTest.php @@ -2,7 +2,7 @@ namespace Drupal\Tests\rdf\Functional; -use Drupal\taxonomy\Tests\TaxonomyTestBase; +use Drupal\Tests\taxonomy\Functional\TaxonomyTestBase; /** * Tests the RDFa markup of Taxonomy terms. diff --git a/core/modules/taxonomy/src/Tests/TaxonomyTestBase.php b/core/modules/taxonomy/src/Tests/TaxonomyTestBase.php index 838a9b02c90f0c121be860b5511bf359f5afaf25..b4f941da5b666d7f62dc15e9ebaea37b9224f4f3 100644 --- a/core/modules/taxonomy/src/Tests/TaxonomyTestBase.php +++ b/core/modules/taxonomy/src/Tests/TaxonomyTestBase.php @@ -2,8 +2,11 @@ namespace Drupal\taxonomy\Tests; +@trigger_error(__NAMESPACE__ . '\TaxonomyTestBase is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\taxonomy\Functional\TaxonomyTestBase', E_USER_DEPRECATED); + use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait; use Drupal\simpletest\WebTestBase; +use Drupal\Tests\taxonomy\Functional\TaxonomyTestTrait; /** * Provides common helper methods for Taxonomy module tests. diff --git a/core/modules/taxonomy/src/Tests/TaxonomyTestTrait.php b/core/modules/taxonomy/src/Tests/TaxonomyTestTrait.php index 744ab1b28b497c5a8feb6ff9cb0b65ce912370fb..8c4a6672703d8f542353fd57520c02cd3abb7fb4 100644 --- a/core/modules/taxonomy/src/Tests/TaxonomyTestTrait.php +++ b/core/modules/taxonomy/src/Tests/TaxonomyTestTrait.php @@ -2,6 +2,8 @@ namespace Drupal\taxonomy\Tests; +@trigger_error(__NAMESPACE__ . '\TaxonomyTestTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\taxonomy\Functional\TaxonomyTestTrait', E_USER_DEPRECATED); + use Drupal\Component\Utility\Unicode; use Drupal\Core\Language\LanguageInterface; use Drupal\taxonomy\Entity\Vocabulary; @@ -9,6 +11,9 @@ /** * Provides common helper methods for Taxonomy module tests. + * + * @deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. + * Use \Drupal\Tests\taxonomy\Functional\TaxonomyTestTrait */ trait TaxonomyTestTrait { diff --git a/core/modules/taxonomy/src/Tests/TaxonomyTranslationTestTrait.php b/core/modules/taxonomy/src/Tests/TaxonomyTranslationTestTrait.php index 3607fc6b0a52233df654f45849b365e0cc133f0c..644211714ac45d7b10575b81575a792426c407ba 100644 --- a/core/modules/taxonomy/src/Tests/TaxonomyTranslationTestTrait.php +++ b/core/modules/taxonomy/src/Tests/TaxonomyTranslationTestTrait.php @@ -2,6 +2,8 @@ namespace Drupal\taxonomy\Tests; +@trigger_error(__NAMESPACE__ . '\TaxonomyTranslationTestTrait is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\taxonomy\Functional\TaxonomyTranslationTestTrait', E_USER_DEPRECATED); + use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait; use Drupal\field\Entity\FieldStorageConfig; @@ -9,6 +11,9 @@ /** * Provides common testing base for translated taxonomy terms. + * + * @deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. + * Use \Drupal\Tests\taxonomy\Functional\TaxonomyTranslationTestTrait */ trait TaxonomyTranslationTestTrait { diff --git a/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php b/core/modules/taxonomy/tests/src/Functional/TaxonomyImageTest.php similarity index 94% rename from core/modules/taxonomy/src/Tests/TaxonomyImageTest.php rename to core/modules/taxonomy/tests/src/Functional/TaxonomyImageTest.php index 7d2ee2b639d3a83cccd18ef09947b1c40dcd4aae..504c0da6c411f17d4702399ab96f76bea26c0319 100644 --- a/core/modules/taxonomy/src/Tests/TaxonomyImageTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyImageTest.php @@ -1,8 +1,9 @@ $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/tests/src/Functional/TaxonomyTranslationTestTrait.php b/core/modules/taxonomy/tests/src/Functional/TaxonomyTranslationTestTrait.php new file mode 100644 index 0000000000000000000000000000000000000000..fc3cea75eccd267760c8f1036eb12e221558d520 --- /dev/null +++ b/core/modules/taxonomy/tests/src/Functional/TaxonomyTranslationTestTrait.php @@ -0,0 +1,105 @@ +translateToLangcode)->save(); + $this->rebuildContainer(); + } + + /** + * Enables translations where it needed. + */ + protected function enableTranslation() { + // Enable translation for the current entity type and ensure the change is + // picked up. + \Drupal::service('content_translation.manager')->setEnabled('node', 'article', TRUE); + \Drupal::service('content_translation.manager')->setEnabled('taxonomy_term', $this->vocabulary->id(), TRUE); + drupal_static_reset(); + \Drupal::entityManager()->clearCachedDefinitions(); + \Drupal::service('router.builder')->rebuild(); + \Drupal::service('entity.definition_update_manager')->applyUpdates(); + } + + /** + * Adds term reference field for the article content type. + * + * @param bool $translatable + * (optional) If TRUE, create a translatable term reference field. Defaults + * to FALSE. + */ + protected function setUpTermReferenceField() { + $handler_settings = [ + 'target_bundles' => [ + $this->vocabulary->id() => $this->vocabulary->id(), + ], + 'auto_create' => TRUE, + ]; + $this->createEntityReferenceField('node', 'article', $this->termFieldName, NULL, 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED); + $field_storage = FieldStorageConfig::loadByName('node', $this->termFieldName); + $field_storage->setTranslatable(FALSE); + $field_storage->save(); + + entity_get_form_display('node', 'article', 'default') + ->setComponent($this->termFieldName, [ + 'type' => 'entity_reference_autocomplete_tags', + ]) + ->save(); + entity_get_display('node', 'article', 'default') + ->setComponent($this->termFieldName, [ + 'type' => 'entity_reference_label', + ]) + ->save(); + } + +} diff --git a/core/modules/taxonomy/tests/src/Functional/TermTranslationFieldViewTest.php b/core/modules/taxonomy/tests/src/Functional/TermTranslationFieldViewTest.php index c5df74dadea2d8362829ab76a611c7136ea2b05e..dfd5e51f0b40e9b61055a9f0a6ddf7072b93cfa0 100644 --- a/core/modules/taxonomy/tests/src/Functional/TermTranslationFieldViewTest.php +++ b/core/modules/taxonomy/tests/src/Functional/TermTranslationFieldViewTest.php @@ -3,7 +3,6 @@ namespace Drupal\Tests\taxonomy\Functional; use Drupal\node\Entity\Node; -use Drupal\taxonomy\Tests\TaxonomyTranslationTestTrait; /** * Tests the translation of taxonomy terms field on nodes. diff --git a/core/modules/taxonomy/src/Tests/TermTranslationUITest.php b/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php similarity index 97% rename from core/modules/taxonomy/src/Tests/TermTranslationUITest.php rename to core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php index 43edc156bb4a064ba393d3e650a13f93dd9e4070..0d24b6990e7bf9af33618ff5f3cedafbba3a6970 100644 --- a/core/modules/taxonomy/src/Tests/TermTranslationUITest.php +++ b/core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php @@ -1,8 +1,8 @@ xpath('//a[@href="' . $this->term1->url() . '"]'); $this->assertEqual(count($actual), 2, 'Correct number of taxonomy term1 links'); - $this->assertEqual($actual[0]->__toString(), $this->term1->label()); - $this->assertEqual($actual[1]->__toString(), $this->term1->label()); + $this->assertEqual($actual[0]->getText(), $this->term1->label()); + $this->assertEqual($actual[1]->getText(), $this->term1->label()); $this->assertEscaped($this->term1->label()); $actual = $this->xpath('//a[@href="' . $this->term2->url() . '"]'); $this->assertEqual(count($actual), 2, 'Correct number of taxonomy term2 links'); - $this->assertEqual($actual[0]->__toString(), $this->term2->label()); - $this->assertEqual($actual[1]->__toString(), $this->term2->label()); + $this->assertEqual($actual[0]->getText(), $this->term2->label()); + $this->assertEqual($actual[1]->getText(), $this->term2->label()); } /** diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldFilterTest.php similarity index 96% rename from core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php rename to core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldFilterTest.php index 86f67ff3de89f14af915405f05d597a90474ecc0..1b8bbcaa517e9af1dbb38d4db2f97ea9a73bf32a 100644 --- a/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldFilterTest.php +++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldFilterTest.php @@ -1,11 +1,11 @@ save(); diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldTidTest.php b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldTidTest.php similarity index 94% rename from core/modules/taxonomy/src/Tests/Views/TaxonomyFieldTidTest.php rename to core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldTidTest.php index b068f083a1f676c1a4d5944514b6f4b436a30210..0a44d4cb2ea15aa55f479875de890c9ab16bc1c5 100644 --- a/core/modules/taxonomy/src/Tests/Views/TaxonomyFieldTidTest.php +++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyFieldTidTest.php @@ -1,6 +1,6 @@ term1->set('parent', $this->term2->id()); diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyTermArgumentDepthTest.php b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTermArgumentDepthTest.php similarity index 89% rename from core/modules/taxonomy/src/Tests/Views/TaxonomyTermArgumentDepthTest.php rename to core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTermArgumentDepthTest.php index 311118dfea0a532771aa801da42889ca3425fc5f..3505784a078599c9455b31dbb5e06280ed982ff9 100644 --- a/core/modules/taxonomy/src/Tests/Views/TaxonomyTermArgumentDepthTest.php +++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTermArgumentDepthTest.php @@ -1,6 +1,6 @@ createTerm(['name' => 'First']); diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyTermFilterDepthTest.php b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTermFilterDepthTest.php similarity index 96% rename from core/modules/taxonomy/src/Tests/Views/TaxonomyTermFilterDepthTest.php rename to core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTermFilterDepthTest.php index 10ccad260ef4199c22e0a074ac95f1ad0268871a..4d7a4fdf03c69cab15c92409f959c88f4cd1cb2f 100644 --- a/core/modules/taxonomy/src/Tests/Views/TaxonomyTermFilterDepthTest.php +++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTermFilterDepthTest.php @@ -1,6 +1,6 @@ adminUser = $this->drupalCreateUser(['administer taxonomy', 'bypass node access']); diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTestBase.php similarity index 97% rename from core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php rename to core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTestBase.php index 6ff5514188e9d6453389ca2c9a301aaf04c0e4af..a2d8ec14a380545f77b3c81c98bfdd5122b9a215 100644 --- a/core/modules/taxonomy/src/Tests/Views/TaxonomyTestBase.php +++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyTestBase.php @@ -1,11 +1,11 @@ vocabularies[] = $this->vocabulary; diff --git a/core/modules/taxonomy/src/Tests/Views/TermNameFieldTest.php b/core/modules/taxonomy/tests/src/Functional/Views/TermNameFieldTest.php similarity index 96% rename from core/modules/taxonomy/src/Tests/Views/TermNameFieldTest.php rename to core/modules/taxonomy/tests/src/Functional/Views/TermNameFieldTest.php index 98d1ab4b48f435bd2047fecdc91236021da2408d..6fbe0c0b2b5d33efdb17f47a1cb7373eacb53fc2 100644 --- a/core/modules/taxonomy/src/Tests/Views/TermNameFieldTest.php +++ b/core/modules/taxonomy/tests/src/Functional/Views/TermNameFieldTest.php @@ -1,6 +1,6 @@ config('system.site')->get('name'); $this->assertTitle(t('Don\'t Panic | @site-name', ['@site-name' => $site_name]), 'The page title contains the escaped character.'); - $this->assertNoTitle(t('Don't Panic | @site-name', ['@site-name' => $site_name]), 'The page title does not contain an encoded character.'); } /** diff --git a/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php b/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php index 0d70d840dabcc216cd4cefc15373dafed8a0a2df..832e5111bf187002254e29ef2baf9682344c98d8 100644 --- a/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php @@ -4,7 +4,7 @@ use Drupal\taxonomy\Entity\Term; use Drupal\KernelTests\KernelTestBase; -use Drupal\taxonomy\Tests\TaxonomyTestTrait; +use Drupal\Tests\taxonomy\Functional\TaxonomyTestTrait; /** * Kernel tests for taxonomy term functions. diff --git a/core/modules/views/tests/src/Functional/TaxonomyGlossaryTest.php b/core/modules/views/tests/src/Functional/TaxonomyGlossaryTest.php index c34e6f2a02a389903b09f7017ded8ee85d613e98..fbf5f414588f9cdffe5a982c5556338153ddac04 100644 --- a/core/modules/views/tests/src/Functional/TaxonomyGlossaryTest.php +++ b/core/modules/views/tests/src/Functional/TaxonomyGlossaryTest.php @@ -2,7 +2,7 @@ namespace Drupal\Tests\views\Functional; -use Drupal\taxonomy\Tests\TaxonomyTestTrait; +use Drupal\Tests\taxonomy\Functional\TaxonomyTestTrait; /** * Tests glossary functionality of taxonomy views.