diff --git a/core/modules/comment/src/CommentLinkBuilder.php b/core/modules/comment/src/CommentLinkBuilder.php index c7cbc18d376b32381eb55dc7a311e403bc1c2141..60be27082ab3989cb392cc03a13eb451b1b3f1a9 100644 --- a/core/modules/comment/src/CommentLinkBuilder.php +++ b/core/modules/comment/src/CommentLinkBuilder.php @@ -107,7 +107,7 @@ public function buildCommentedEntityLinks(FieldableEntityInterface $entity, arra 'title' => $this->formatPlural($entity->get($field_name)->comment_count, '1 comment', '@count comments'), 'attributes' => ['title' => $this->t('Jump to the first comment.')], 'fragment' => 'comments', - 'url' => $entity->urlInfo(), + 'url' => $entity->toUrl(), ]; if ($this->moduleHandler->moduleExists('history')) { $links['comment-new-comments'] = [ @@ -141,7 +141,7 @@ public function buildCommentedEntityLinks(FieldableEntityInterface $entity, arra ]); } else { - $links['comment-add'] += ['url' => $entity->urlInfo()]; + $links['comment-add'] += ['url' => $entity->toUrl()]; } } elseif ($this->currentUser->isAnonymous()) { @@ -174,7 +174,7 @@ public function buildCommentedEntityLinks(FieldableEntityInterface $entity, arra ]); } else { - $links['comment-add']['url'] = $entity->urlInfo(); + $links['comment-add']['url'] = $entity->toUrl(); } } } diff --git a/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php b/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php index 662f5f332e25cf3d0459db9822f902179293969f..e2ddf8ab0eee4823f28c735805337cd2414ee202 100644 --- a/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php +++ b/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php @@ -310,7 +310,7 @@ protected function getMockNode($has_field, $comment_status, $form_location, $com $url = Url::fromRoute('node.view'); $node->expects($this->any()) - ->method('urlInfo') + ->method('toUrl') ->willReturn($url); $node->expects($this->any()) ->method('url') diff --git a/core/modules/contact/src/MailHandler.php b/core/modules/contact/src/MailHandler.php index b57864c0596a4f19c419c081b8b15d0cf8d5f2d0..aae2793755c8b94c7e4ca43050828e2ad49252a7 100644 --- a/core/modules/contact/src/MailHandler.php +++ b/core/modules/contact/src/MailHandler.php @@ -134,16 +134,16 @@ public function sendMailMessages(MessageInterface $message, AccountInterface $se if (!$message->isPersonal()) { $this->logger->notice('%sender-name (@sender-from) sent an email regarding %contact_form.', [ - '%sender-name' => $sender_cloned->getUsername(), + '%sender-name' => $sender_cloned->getAccountName(), '@sender-from' => $sender_cloned->getEmail(), '%contact_form' => $contact_form->label(), ]); } else { $this->logger->notice('%sender-name (@sender-from) sent %recipient-name an email.', [ - '%sender-name' => $sender_cloned->getUsername(), + '%sender-name' => $sender_cloned->getAccountName(), '@sender-from' => $sender_cloned->getEmail(), - '%recipient-name' => $message->getPersonalRecipient()->getUsername(), + '%recipient-name' => $message->getPersonalRecipient()->getAccountName(), ]); } } diff --git a/core/modules/forum/src/Breadcrumb/ForumBreadcrumbBuilderBase.php b/core/modules/forum/src/Breadcrumb/ForumBreadcrumbBuilderBase.php index 63d2d86e706f95fa7dfa8315f4880de1a41b76de..04ce07ab3a7b23c17295b6c9af497c54db7e410a 100644 --- a/core/modules/forum/src/Breadcrumb/ForumBreadcrumbBuilderBase.php +++ b/core/modules/forum/src/Breadcrumb/ForumBreadcrumbBuilderBase.php @@ -42,6 +42,13 @@ abstract class ForumBreadcrumbBuilderBase implements BreadcrumbBuilderInterface */ protected $forumManager; + /** + * The taxonomy term storage. + * + * @var \Drupal\taxonomy\TermStorageInterface + */ + protected $termStorage; + /** * Constructs a forum breadcrumb builder object. * @@ -59,6 +66,7 @@ public function __construct(EntityManagerInterface $entity_manager, ConfigFactor $this->config = $config_factory->get('forum.settings'); $this->forumManager = $forum_manager; $this->setStringTranslation($string_translation); + $this->termStorage = $entity_manager->getStorage('taxonomy_term'); } /** diff --git a/core/modules/forum/src/Breadcrumb/ForumListingBreadcrumbBuilder.php b/core/modules/forum/src/Breadcrumb/ForumListingBreadcrumbBuilder.php index 93e5dd595f97b5950bb935f71827c9c50e50347c..91ea1a01c36c20d441affebc10d8ba3770950ef2 100644 --- a/core/modules/forum/src/Breadcrumb/ForumListingBreadcrumbBuilder.php +++ b/core/modules/forum/src/Breadcrumb/ForumListingBreadcrumbBuilder.php @@ -30,7 +30,7 @@ public function build(RouteMatchInterface $route_match) { $term_id = $term->id(); $breadcrumb->addCacheableDependency($term); - $parents = $this->forumManager->getParents($term_id); + $parents = $this->termStorage->loadAllParents($term_id); if ($parents) { foreach (array_reverse($parents) as $parent) { if ($parent->id() != $term_id) { diff --git a/core/modules/forum/src/Breadcrumb/ForumNodeBreadcrumbBuilder.php b/core/modules/forum/src/Breadcrumb/ForumNodeBreadcrumbBuilder.php index 1a359010a85bd6e3d0bcdbc134f6c50060435399..007fb9a63c739812a47f73855eafe1148fceb555 100644 --- a/core/modules/forum/src/Breadcrumb/ForumNodeBreadcrumbBuilder.php +++ b/core/modules/forum/src/Breadcrumb/ForumNodeBreadcrumbBuilder.php @@ -26,7 +26,7 @@ public function build(RouteMatchInterface $route_match) { $breadcrumb = parent::build($route_match); $breadcrumb->addCacheContexts(['route']); - $parents = $this->forumManager->getParents($route_match->getParameter('node')->forum_tid); + $parents = $this->termStorage->loadAllParents($route_match->getParameter('node')->forum_tid); if ($parents) { $parents = array_reverse($parents); foreach ($parents as $parent) { diff --git a/core/modules/forum/src/ForumUninstallValidator.php b/core/modules/forum/src/ForumUninstallValidator.php index 24ae880264a78d1830fa7658adbc037fd2a68b4c..face3cbf459c363d8b3be1cae276f53c11ee81ac 100644 --- a/core/modules/forum/src/ForumUninstallValidator.php +++ b/core/modules/forum/src/ForumUninstallValidator.php @@ -62,7 +62,7 @@ public function validate($module) { if ($vocabulary->access('view')) { $reasons[] = $this->t('To uninstall Forum, first delete all <a href=":url">%vocabulary</a> terms', [ '%vocabulary' => $vocabulary->label(), - ':url' => $vocabulary->url('overview-form'), + ':url' => $vocabulary->toUrl('overview-form')->toString(), ]); } else { diff --git a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php index 45566f2afe6d1f849060f808bf34e87354a83315..47a0113d1f8874a26e2688234eaa0b8983e7344b 100644 --- a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php +++ b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumListingBreadcrumbBuilderTest.php @@ -4,6 +4,7 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Link; +use Drupal\taxonomy\TermStorageInterface; use Drupal\Tests\UnitTestCase; use Symfony\Component\DependencyInjection\Container; @@ -138,12 +139,12 @@ public function testBuild() { $prophecy->getCacheMaxAge()->willReturn(Cache::PERMANENT); $term2 = $prophecy->reveal(); - $forum_manager = $this->getMock('Drupal\forum\ForumManagerInterface'); - $forum_manager->expects($this->at(0)) - ->method('getParents') + $term_storage = $this->getMockBuilder(TermStorageInterface::class)->getMock(); + $term_storage->expects($this->at(0)) + ->method('loadAllParents') ->will($this->returnValue([$term1])); - $forum_manager->expects($this->at(1)) - ->method('getParents') + $term_storage->expects($this->at(1)) + ->method('loadAllParents') ->will($this->returnValue([$term1, $term2])); // The root forum. @@ -167,6 +168,7 @@ public function testBuild() { ->method('getStorage') ->will($this->returnValueMap([ ['taxonomy_vocabulary', $vocab_storage], + ['taxonomy_term', $term_storage], ])); $config_factory = $this->getConfigFactoryStub( @@ -177,6 +179,8 @@ public function testBuild() { ] ); + $forum_manager = $this->getMock('Drupal\forum\ForumManagerInterface'); + // Build a breadcrumb builder to test. $breadcrumb_builder = $this->getMock( 'Drupal\forum\Breadcrumb\ForumListingBreadcrumbBuilder', NULL, [ diff --git a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php index f4d3797155d028e09139fc8c70a484ea0125232c..33acddff3c0870d779f47eae0a3e4f8c01820b53 100644 --- a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php +++ b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumNodeBreadcrumbBuilderTest.php @@ -4,6 +4,7 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Link; +use Drupal\taxonomy\TermStorageInterface; use Drupal\Tests\UnitTestCase; use Symfony\Component\DependencyInjection\Container; @@ -149,11 +150,12 @@ public function testBuild() { $forum_manager = $this->getMockBuilder('Drupal\forum\ForumManagerInterface') ->disableOriginalConstructor() ->getMock(); - $forum_manager->expects($this->at(0)) - ->method('getParents') + $term_storage = $this->getMockBuilder(TermStorageInterface::class)->getMock(); + $term_storage->expects($this->at(0)) + ->method('loadAllParents') ->will($this->returnValue([$term1])); - $forum_manager->expects($this->at(1)) - ->method('getParents') + $term_storage->expects($this->at(1)) + ->method('loadAllParents') ->will($this->returnValue([$term1, $term2])); $prophecy = $this->prophesize('Drupal\taxonomy\VocabularyInterface'); @@ -176,6 +178,7 @@ public function testBuild() { ->method('getStorage') ->will($this->returnValueMap([ ['taxonomy_vocabulary', $vocab_storage], + ['taxonomy_term', $term_storage], ])); $config_factory = $this->getConfigFactoryStub( diff --git a/core/modules/forum/tests/src/Unit/ForumUninstallValidatorTest.php b/core/modules/forum/tests/src/Unit/ForumUninstallValidatorTest.php index fa1b0c1ec76a24de94e264841560a3a5823e2878..4969ad7dd34e9e06bb3758ccbe4cecb587b043cd 100644 --- a/core/modules/forum/tests/src/Unit/ForumUninstallValidatorTest.php +++ b/core/modules/forum/tests/src/Unit/ForumUninstallValidatorTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\forum\Unit; +use Drupal\Core\Url; use Drupal\simpletest\AssertHelperTrait; use Drupal\Tests\UnitTestCase; @@ -103,13 +104,16 @@ public function testValidateHasTermsForVocabularyWithNodesAccess() { ->method('hasForumNodes') ->willReturn(TRUE); + $url = $this->prophesize(Url::class); + $url->toString()->willReturn('/path/to/vocabulary/overview'); + $vocabulary = $this->getMock('Drupal\taxonomy\VocabularyInterface'); $vocabulary->expects($this->once()) ->method('label') ->willReturn('Vocabulary label'); $vocabulary->expects($this->once()) - ->method('url') - ->willReturn('/path/to/vocabulary/overview'); + ->method('toUrl') + ->willReturn($url->reveal()); $vocabulary->expects($this->once()) ->method('access') ->willReturn(TRUE); @@ -143,7 +147,7 @@ public function testValidateHasTermsForVocabularyWithNodesNoAccess() { ->method('label') ->willReturn('Vocabulary label'); $vocabulary->expects($this->never()) - ->method('url'); + ->method('toUrl'); $vocabulary->expects($this->once()) ->method('access') ->willReturn(FALSE); @@ -172,10 +176,13 @@ public function testValidateHasTermsForVocabularyAccess() { ->method('hasForumNodes') ->willReturn(FALSE); + $url = $this->prophesize(Url::class); + $url->toString()->willReturn('/path/to/vocabulary/overview'); + $vocabulary = $this->getMock('Drupal\taxonomy\VocabularyInterface'); $vocabulary->expects($this->once()) - ->method('url') - ->willReturn('/path/to/vocabulary/overview'); + ->method('toUrl') + ->willReturn($url->reveal()); $vocabulary->expects($this->once()) ->method('label') ->willReturn('Vocabulary label'); @@ -211,7 +218,7 @@ public function testValidateHasTermsForVocabularyNoAccess() { ->method('label') ->willReturn('Vocabulary label'); $vocabulary->expects($this->never()) - ->method('url'); + ->method('toUrl'); $vocabulary->expects($this->once()) ->method('access') ->willReturn(FALSE); diff --git a/core/modules/migrate/src/MigrateExecutable.php b/core/modules/migrate/src/MigrateExecutable.php index d5b9d1ac266026175e4a9c8de71b2e90f08585d0..15abe8b729f591cf4e007230291d279d96dadbb3 100644 --- a/core/modules/migrate/src/MigrateExecutable.php +++ b/core/modules/migrate/src/MigrateExecutable.php @@ -221,7 +221,9 @@ public function import() { if ($save) { try { $this->getEventDispatcher()->dispatch(MigrateEvents::PRE_ROW_SAVE, new MigratePreRowSaveEvent($this->migration, $this->message, $row)); - $destination_id_values = $destination->import($row, $id_map->lookupDestinationId($this->sourceIdValues)); + $destination_ids = $id_map->lookupDestinationIds($this->sourceIdValues); + $destination_id_values = $destination_ids ? reset($destination_ids) : []; + $destination_id_values = $destination->import($row, $destination_id_values); $this->getEventDispatcher()->dispatch(MigrateEvents::POST_ROW_SAVE, new MigratePostRowSaveEvent($this->migration, $this->message, $row, $destination_id_values)); if ($destination_id_values) { // We do not save an idMap entry for config. diff --git a/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php index 8f33ba6db1506d67c9a9af9376e88051786fea40..957da811c86bd0e9ba9dffc7d93cdaa43404b3f2 100644 --- a/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php +++ b/core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php @@ -95,9 +95,9 @@ public function testImportWithValidRow() { ->will($this->returnValue(['id' => 'test'])); $this->idMap->expects($this->once()) - ->method('lookupDestinationId') + ->method('lookupDestinationIds') ->with(['id' => 'test']) - ->will($this->returnValue(['test'])); + ->will($this->returnValue([['test']])); $source->expects($this->once()) ->method('current') @@ -137,9 +137,9 @@ public function testImportWithValidRowWithoutDestinationId() { ->will($this->returnValue(['id' => 'test'])); $this->idMap->expects($this->once()) - ->method('lookupDestinationId') + ->method('lookupDestinationIds') ->with(['id' => 'test']) - ->will($this->returnValue(['test'])); + ->will($this->returnValue([['test']])); $source->expects($this->once()) ->method('current') @@ -213,9 +213,9 @@ public function testImportWithValidRowNoDestinationValues() { ->method('saveMessage'); $this->idMap->expects($this->once()) - ->method('lookupDestinationId') + ->method('lookupDestinationIds') ->with(['id' => 'test']) - ->will($this->returnValue(['test'])); + ->will($this->returnValue([['test']])); $this->message->expects($this->once()) ->method('display') @@ -269,9 +269,9 @@ public function testImportWithValidRowWithDestinationMigrateException() { ->method('saveMessage'); $this->idMap->expects($this->once()) - ->method('lookupDestinationId') + ->method('lookupDestinationIds') ->with(['id' => 'test']) - ->will($this->returnValue(['test'])); + ->will($this->returnValue([['test']])); $this->assertSame(MigrationInterface::RESULT_COMPLETED, $this->executable->import()); } @@ -319,7 +319,7 @@ public function testImportWithValidRowWithProcesMigrateException() { ->method('saveMessage'); $this->idMap->expects($this->never()) - ->method('lookupDestinationId'); + ->method('lookupDestinationIds'); $this->assertSame(MigrationInterface::RESULT_COMPLETED, $this->executable->import()); } @@ -367,9 +367,9 @@ public function testImportWithValidRowWithException() { ->method('saveMessage'); $this->idMap->expects($this->once()) - ->method('lookupDestinationId') + ->method('lookupDestinationIds') ->with(['id' => 'test']) - ->will($this->returnValue(['test'])); + ->will($this->returnValue([['test']])); $this->message->expects($this->once()) ->method('display') diff --git a/core/modules/serialization/serialization.services.yml b/core/modules/serialization/serialization.services.yml index dca60947870859388228ad50dd2049ba43b6b33f..942ee05c6d6119d9dcc40a79767754d23ef34177 100644 --- a/core/modules/serialization/serialization.services.yml +++ b/core/modules/serialization/serialization.services.yml @@ -85,7 +85,7 @@ services: class: Drupal\serialization\EntityResolver\UuidResolver tags: - { name: entity_resolver} - arguments: ['@entity.manager'] + arguments: ['@entity.repository'] serialization.entity_resolver.target_id: class: Drupal\serialization\EntityResolver\TargetIdResolver tags: diff --git a/core/modules/serialization/src/EntityResolver/UuidResolver.php b/core/modules/serialization/src/EntityResolver/UuidResolver.php index 4a3b0a20591d3bc69f3a4a1b10134445e404ead3..561b4f7fdbd873f78b1f969435dc65f9e6f1fb21 100644 --- a/core/modules/serialization/src/EntityResolver/UuidResolver.php +++ b/core/modules/serialization/src/EntityResolver/UuidResolver.php @@ -2,7 +2,7 @@ namespace Drupal\serialization\EntityResolver; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityRepositoryInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; /** @@ -11,20 +11,20 @@ class UuidResolver implements EntityResolverInterface { /** - * The entity manager. + * The entity repository. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityRepositoryInterface */ - protected $entityManager; + protected $entityRepository; /** * Constructs a UuidResolver object. * - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository + * The entity repository. */ - public function __construct(EntityManagerInterface $entity_manager) { - $this->entityManager = $entity_manager; + public function __construct(EntityRepositoryInterface $entity_repository) { + $this->entityRepository = $entity_repository; } /** @@ -35,7 +35,7 @@ public function resolve(NormalizerInterface $normalizer, $data, $entity_type) { // deserialized. If it can return a UUID from that data, and if there's an // entity with that UUID, then return its ID. if (($normalizer instanceof UuidReferenceInterface) && ($uuid = $normalizer->getUuid($data))) { - if ($entity = $this->entityManager->loadEntityByUuid($entity_type, $uuid)) { + if ($entity = $this->entityRepository->loadEntityByUuid($entity_type, $uuid)) { return $entity->id(); } } diff --git a/core/modules/serialization/src/Normalizer/EntityNormalizer.php b/core/modules/serialization/src/Normalizer/EntityNormalizer.php index 4103d1dd7a5038fccc119fd7b644c28e5318e761..ef746a58998765afdda8419d92d8bbc76d5f5809 100644 --- a/core/modules/serialization/src/Normalizer/EntityNormalizer.php +++ b/core/modules/serialization/src/Normalizer/EntityNormalizer.php @@ -40,7 +40,7 @@ public function denormalize($data, $class, $format = NULL, array $context = []) // The bundle property will be required to denormalize a bundleable // fieldable entity. - if ($entity_type_definition->isSubclassOf(FieldableEntityInterface::class)) { + if ($entity_type_definition->entityClassImplements(FieldableEntityInterface::class)) { // Extract bundle data to pass into entity creation if the entity type uses // bundles. if ($entity_type_definition->hasKey('bundle')) { diff --git a/core/modules/serialization/tests/src/Unit/EntityResolver/UuidResolverTest.php b/core/modules/serialization/tests/src/Unit/EntityResolver/UuidResolverTest.php index 812392568a6f47bdf5669ebd5d2f25080a3cdfe5..4abd9ff384b77e4e62c32a0eb2f39d6c10098594 100644 --- a/core/modules/serialization/tests/src/Unit/EntityResolver/UuidResolverTest.php +++ b/core/modules/serialization/tests/src/Unit/EntityResolver/UuidResolverTest.php @@ -2,6 +2,7 @@ namespace Drupal\Tests\serialization\Unit\EntityResolver; +use Drupal\Core\Entity\EntityRepositoryInterface; use Drupal\Tests\UnitTestCase; use Drupal\serialization\EntityResolver\UuidResolver; @@ -29,7 +30,7 @@ class UuidResolverTest extends UnitTestCase { * {@inheritdoc} */ protected function setUp() { - $this->entityManager = $this->getMockBuilder('Drupal\Core\Entity\EntityManager') + $this->entityManager = $this->getMockBuilder(EntityRepositoryInterface::class) ->disableOriginalConstructor() ->getMock(); diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php index 689d654bd9e9d4e82ec52f72259c25a11417b5dc..a5b0000b4f06284eb2c4d9651c445f060c991b92 100644 --- a/core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php +++ b/core/modules/serialization/tests/src/Unit/Normalizer/EntityNormalizerTest.php @@ -119,7 +119,7 @@ public function testDenormalizeWithValidBundle() { ->with('bundle') ->will($this->returnValue('test_type')); $entity_type->expects($this->once()) - ->method('isSubClassOf') + ->method('entityClassImplements') ->with(FieldableEntityInterface::class) ->willReturn(TRUE); @@ -240,7 +240,7 @@ public function testDenormalizeWithInvalidBundle() { ->with('bundle') ->will($this->returnValue('test_type')); $entity_type->expects($this->once()) - ->method('isSubClassOf') + ->method('entityClassImplements') ->with(FieldableEntityInterface::class) ->willReturn(TRUE); @@ -303,7 +303,7 @@ public function testDenormalizeWithNoBundle() { $entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface'); $entity_type->expects($this->once()) - ->method('isSubClassOf') + ->method('entityClassImplements') ->with(FieldableEntityInterface::class) ->willReturn(TRUE); $entity_type->expects($this->once()) @@ -376,7 +376,7 @@ public function testDenormalizeWithNoFieldableEntityType() { $entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface'); $entity_type->expects($this->once()) - ->method('isSubClassOf') + ->method('entityClassImplements') ->with(FieldableEntityInterface::class) ->willReturn(FALSE); diff --git a/core/modules/user/tests/src/Unit/Views/Argument/RolesRidTest.php b/core/modules/user/tests/src/Unit/Views/Argument/RolesRidTest.php index efcead4fbaa3164c9a2eb8847dafb4bcdab620eb..e61901166a13e4bf7ea69bcec7a27a48758e7ebf 100644 --- a/core/modules/user/tests/src/Unit/Views/Argument/RolesRidTest.php +++ b/core/modules/user/tests/src/Unit/Views/Argument/RolesRidTest.php @@ -19,6 +19,13 @@ class RolesRidTest extends UnitTestCase { * Tests the titleQuery method. * * @covers ::titleQuery + * + * @group legacy + * + * Note this is only a legacy test because it triggers a call to + * \Drupal\Core\Entity\EntityTypeInterface::getLabelCallback() which is mocked + * and triggers a deprecation error. Remove when ::getLabelCallback() is + * removed. */ public function testTitleQuery() { $role1 = new Role([ diff --git a/core/modules/views/src/ViewsData.php b/core/modules/views/src/ViewsData.php index e5281abf364516221efc3f5ccf6f2c4310c11966..09522b984f5a6fc22a242bcaf89c05bb6e2bd64a 100644 --- a/core/modules/views/src/ViewsData.php +++ b/core/modules/views/src/ViewsData.php @@ -133,10 +133,8 @@ public function getAll() { * * @param string|null $key * The key of the cache entry to retrieve. Defaults to NULL, this will - * return all table data. - * - * @deprecated NULL $key deprecated in Drupal 8.2.x and will be removed in - * 9.0.0. Use getAll() instead. + * return all table data. NULL $key deprecated in Drupal 8.2.x and will be + * removed in 9.0.0. Use getAll() instead. * * @see https://www.drupal.org/node/2723553 * diff --git a/core/phpunit.xml.dist b/core/phpunit.xml.dist index 4c56583f36d8b2930fa1296083b97b8a7727e90a..7819f99f297a5dfeabc583c0fa7a7b587ef14d65 100644 --- a/core/phpunit.xml.dist +++ b/core/phpunit.xml.dist @@ -28,8 +28,8 @@ <env name="SIMPLETEST_DB" value=""/> <!-- Example BROWSERTEST_OUTPUT_DIRECTORY value: /path/to/webroot/sites/simpletest/browser_output --> <env name="BROWSERTEST_OUTPUT_DIRECTORY" value=""/> - <!-- To disable deprecation testing completely set SYMFONY_DEPRECATIONS_HELPER value: 'disabled' --> - <env name="SYMFONY_DEPRECATIONS_HELPER" value="weak_vendors"/> + <!-- To disable deprecation testing completely uncomment the next line. --> + <!-- <env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/> --> <!-- Example for changing the driver class for mink tests MINK_DRIVER_CLASS value: 'Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver' --> <!-- Example for changing the driver args to mink tests MINK_DRIVER_ARGS value: '["http://127.0.0.1:8510"]' --> <!-- Example for changing the driver args to phantomjs tests MINK_DRIVER_ARGS_PHANTOMJS value: '["http://127.0.0.1:8510"]' --> diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh index 3462fcfc7ce3d9f710e05d68e27b254e9df9846d..5dc391e6d5ce22d0e8282c68ca4208685db28035 100644 --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -310,7 +310,12 @@ function simpletest_script_help() { --suppress-deprecations - Stops tests from failing if deprecation errors are triggered. + Stops tests from failing if deprecation errors are triggered. If + this is not set the value specified in the + SYMFONY_DEPRECATIONS_HELPER environment variable, or the value + specified in core/phpunit.xml (if it exists), or the default value + will be used. The default is that any unexpected silenced + deprecation error will fail tests. <test1>[,<test2>[,<test3> ...]] @@ -825,13 +830,6 @@ function simpletest_script_run_one_test($test_id, $test_class) { if ($args['suppress-deprecations']) { putenv('SYMFONY_DEPRECATIONS_HELPER=disabled'); } - else { - // Prevent deprecations caused by vendor code calling deprecated code. - // This also prevents mock objects in PHPUnit 6 triggering silenced - // deprecations from breaking the test suite. We should consider changing - // this to 'strict' once PHPUnit 4 is no longer used. - putenv('SYMFONY_DEPRECATIONS_HELPER=weak_vendors'); - } if (is_subclass_of($test_class, TestCase::class)) { $status = simpletest_script_run_phpunit($test_id, $test_class); } diff --git a/core/tests/Drupal/Tests/Core/Asset/AssetResolverTest.php b/core/tests/Drupal/Tests/Core/Asset/AssetResolverTest.php index 99ba0a5ef9c4d1e60677a82c8e0a9102909f1bc4..05aff5e93c018124cb38c1dc213857670c6fadc1 100644 --- a/core/tests/Drupal/Tests/Core/Asset/AssetResolverTest.php +++ b/core/tests/Drupal/Tests/Core/Asset/AssetResolverTest.php @@ -114,6 +114,12 @@ protected function setUp() { /** * @covers ::getCssAssets * @dataProvider providerAttachedAssets + * @group legacy + * + * Note the legacy group is used here because + * ActiveTheme::getStyleSheetsRemove() is called and is deprecated. As this + * code path will still be triggered until Drupal 9 we have to add the group. + * We do not trigger a silenced deprecation. */ public function testGetCssAssets(AttachedAssetsInterface $assets_a, AttachedAssetsInterface $assets_b, $expected_cache_item_count) { $this->assetResolver->getCssAssets($assets_a, FALSE); diff --git a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php index 0d56516dd231ad80d62c040bb6b84fd967271a55..52cdd7621fc49be936ae46ba457a24d796048534 100644 --- a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php @@ -483,6 +483,8 @@ public function testAccess() { /** * @covers ::label + * + * @group legacy */ public function testLabel() { // Make a mock with one method that we use as the entity's label callback. diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityLinkTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityLinkTest.php index 38e9502e99a3f36b78f9f0b4a88cd1ffdb78d9b2..c606cb0d1b38a7a764d5763948d02c1bc5c09aa5 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityLinkTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityLinkTest.php @@ -58,6 +58,13 @@ protected function setUp() { * @covers ::link * * @dataProvider providerTestLink + * + * @group legacy + * + * Note this is only a legacy test because it triggers a call to + * \Drupal\Core\Entity\EntityTypeInterface::getLabelCallback() which is mocked + * and triggers a deprecation error. Remove when ::getLabelCallback() is + * removed. */ public function testLink($entity_label, $link_text, $expected_text, $link_rel = 'canonical', array $link_options = []) { $language = new Language(['id' => 'es']); @@ -120,6 +127,13 @@ public function testLink($entity_label, $link_text, $expected_text, $link_rel = * @covers ::toLink * * @dataProvider providerTestLink + * + * @group legacy + * + * Note this is only a legacy test because it triggers a call to + * \Drupal\Core\Entity\EntityTypeInterface::getLabelCallback() which is mocked + * and triggers a deprecation error. Remove when ::getLabelCallback() is + * removed. */ public function testToLink($entity_label, $link_text, $expected_text, $link_rel = 'canonical', array $link_options = []) { $language = new Language(['id' => 'es']); diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php index 8cb36eb89ebea25a3a207deca4f1e57dd50d9e64..141668def57562bc1b95f0005e1a3ed46047f62f 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php @@ -168,6 +168,7 @@ public function testBundle() { /** * @covers ::label + * @group legacy */ public function testLabel() { // Make a mock with one method that we use as the entity's uri_callback. We diff --git a/core/tests/Drupal/Tests/WebAssert.php b/core/tests/Drupal/Tests/WebAssert.php index f901117e50f5cfbe4119a3c59691eaec55012a88..57358cde16c2ceca854d717b2b58301f2380c9f3 100644 --- a/core/tests/Drupal/Tests/WebAssert.php +++ b/core/tests/Drupal/Tests/WebAssert.php @@ -155,7 +155,7 @@ public function optionExists($select, $option, TraversableElement $container = N $option_field = $select_field->find('named', ['option', $option]); if ($option_field === NULL) { - throw new ElementNotFoundException($this->session, 'select', 'id|name|label|value', $option); + throw new ElementNotFoundException($this->session->getDriver(), 'select', 'id|name|label|value', $option); } return $option_field;