Issue #2961691 by alexpott, Berdir, timmillwood, idebr: Change SYMFONY_DEPRECATIONS_HELPER back to strict
parent
ba42166da2
commit
c2585a1888
|
@ -107,7 +107,7 @@ class CommentLinkBuilder implements CommentLinkBuilderInterface {
|
||||||
'title' => $this->formatPlural($entity->get($field_name)->comment_count, '1 comment', '@count comments'),
|
'title' => $this->formatPlural($entity->get($field_name)->comment_count, '1 comment', '@count comments'),
|
||||||
'attributes' => ['title' => $this->t('Jump to the first comment.')],
|
'attributes' => ['title' => $this->t('Jump to the first comment.')],
|
||||||
'fragment' => 'comments',
|
'fragment' => 'comments',
|
||||||
'url' => $entity->urlInfo(),
|
'url' => $entity->toUrl(),
|
||||||
];
|
];
|
||||||
if ($this->moduleHandler->moduleExists('history')) {
|
if ($this->moduleHandler->moduleExists('history')) {
|
||||||
$links['comment-new-comments'] = [
|
$links['comment-new-comments'] = [
|
||||||
|
@ -141,7 +141,7 @@ class CommentLinkBuilder implements CommentLinkBuilderInterface {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$links['comment-add'] += ['url' => $entity->urlInfo()];
|
$links['comment-add'] += ['url' => $entity->toUrl()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($this->currentUser->isAnonymous()) {
|
elseif ($this->currentUser->isAnonymous()) {
|
||||||
|
@ -174,7 +174,7 @@ class CommentLinkBuilder implements CommentLinkBuilderInterface {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$links['comment-add']['url'] = $entity->urlInfo();
|
$links['comment-add']['url'] = $entity->toUrl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,7 +310,7 @@ class CommentLinkBuilderTest extends UnitTestCase {
|
||||||
|
|
||||||
$url = Url::fromRoute('node.view');
|
$url = Url::fromRoute('node.view');
|
||||||
$node->expects($this->any())
|
$node->expects($this->any())
|
||||||
->method('urlInfo')
|
->method('toUrl')
|
||||||
->willReturn($url);
|
->willReturn($url);
|
||||||
$node->expects($this->any())
|
$node->expects($this->any())
|
||||||
->method('url')
|
->method('url')
|
||||||
|
|
|
@ -134,16 +134,16 @@ class MailHandler implements MailHandlerInterface {
|
||||||
|
|
||||||
if (!$message->isPersonal()) {
|
if (!$message->isPersonal()) {
|
||||||
$this->logger->notice('%sender-name (@sender-from) sent an email regarding %contact_form.', [
|
$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(),
|
'@sender-from' => $sender_cloned->getEmail(),
|
||||||
'%contact_form' => $contact_form->label(),
|
'%contact_form' => $contact_form->label(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this->logger->notice('%sender-name (@sender-from) sent %recipient-name an email.', [
|
$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(),
|
'@sender-from' => $sender_cloned->getEmail(),
|
||||||
'%recipient-name' => $message->getPersonalRecipient()->getUsername(),
|
'%recipient-name' => $message->getPersonalRecipient()->getAccountName(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,13 @@ abstract class ForumBreadcrumbBuilderBase implements BreadcrumbBuilderInterface
|
||||||
*/
|
*/
|
||||||
protected $forumManager;
|
protected $forumManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The taxonomy term storage.
|
||||||
|
*
|
||||||
|
* @var \Drupal\taxonomy\TermStorageInterface
|
||||||
|
*/
|
||||||
|
protected $termStorage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a forum breadcrumb builder object.
|
* Constructs a forum breadcrumb builder object.
|
||||||
*
|
*
|
||||||
|
@ -59,6 +66,7 @@ abstract class ForumBreadcrumbBuilderBase implements BreadcrumbBuilderInterface
|
||||||
$this->config = $config_factory->get('forum.settings');
|
$this->config = $config_factory->get('forum.settings');
|
||||||
$this->forumManager = $forum_manager;
|
$this->forumManager = $forum_manager;
|
||||||
$this->setStringTranslation($string_translation);
|
$this->setStringTranslation($string_translation);
|
||||||
|
$this->termStorage = $entity_manager->getStorage('taxonomy_term');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -30,7 +30,7 @@ class ForumListingBreadcrumbBuilder extends ForumBreadcrumbBuilderBase {
|
||||||
$term_id = $term->id();
|
$term_id = $term->id();
|
||||||
$breadcrumb->addCacheableDependency($term);
|
$breadcrumb->addCacheableDependency($term);
|
||||||
|
|
||||||
$parents = $this->forumManager->getParents($term_id);
|
$parents = $this->termStorage->loadAllParents($term_id);
|
||||||
if ($parents) {
|
if ($parents) {
|
||||||
foreach (array_reverse($parents) as $parent) {
|
foreach (array_reverse($parents) as $parent) {
|
||||||
if ($parent->id() != $term_id) {
|
if ($parent->id() != $term_id) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ class ForumNodeBreadcrumbBuilder extends ForumBreadcrumbBuilderBase {
|
||||||
$breadcrumb = parent::build($route_match);
|
$breadcrumb = parent::build($route_match);
|
||||||
$breadcrumb->addCacheContexts(['route']);
|
$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) {
|
if ($parents) {
|
||||||
$parents = array_reverse($parents);
|
$parents = array_reverse($parents);
|
||||||
foreach ($parents as $parent) {
|
foreach ($parents as $parent) {
|
||||||
|
|
|
@ -62,7 +62,7 @@ class ForumUninstallValidator implements ModuleUninstallValidatorInterface {
|
||||||
if ($vocabulary->access('view')) {
|
if ($vocabulary->access('view')) {
|
||||||
$reasons[] = $this->t('To uninstall Forum, first delete all <a href=":url">%vocabulary</a> terms', [
|
$reasons[] = $this->t('To uninstall Forum, first delete all <a href=":url">%vocabulary</a> terms', [
|
||||||
'%vocabulary' => $vocabulary->label(),
|
'%vocabulary' => $vocabulary->label(),
|
||||||
':url' => $vocabulary->url('overview-form'),
|
':url' => $vocabulary->toUrl('overview-form')->toString(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace Drupal\Tests\forum\Unit\Breadcrumb;
|
||||||
|
|
||||||
use Drupal\Core\Cache\Cache;
|
use Drupal\Core\Cache\Cache;
|
||||||
use Drupal\Core\Link;
|
use Drupal\Core\Link;
|
||||||
|
use Drupal\taxonomy\TermStorageInterface;
|
||||||
use Drupal\Tests\UnitTestCase;
|
use Drupal\Tests\UnitTestCase;
|
||||||
use Symfony\Component\DependencyInjection\Container;
|
use Symfony\Component\DependencyInjection\Container;
|
||||||
|
|
||||||
|
@ -138,12 +139,12 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
|
||||||
$prophecy->getCacheMaxAge()->willReturn(Cache::PERMANENT);
|
$prophecy->getCacheMaxAge()->willReturn(Cache::PERMANENT);
|
||||||
$term2 = $prophecy->reveal();
|
$term2 = $prophecy->reveal();
|
||||||
|
|
||||||
$forum_manager = $this->getMock('Drupal\forum\ForumManagerInterface');
|
$term_storage = $this->getMockBuilder(TermStorageInterface::class)->getMock();
|
||||||
$forum_manager->expects($this->at(0))
|
$term_storage->expects($this->at(0))
|
||||||
->method('getParents')
|
->method('loadAllParents')
|
||||||
->will($this->returnValue([$term1]));
|
->will($this->returnValue([$term1]));
|
||||||
$forum_manager->expects($this->at(1))
|
$term_storage->expects($this->at(1))
|
||||||
->method('getParents')
|
->method('loadAllParents')
|
||||||
->will($this->returnValue([$term1, $term2]));
|
->will($this->returnValue([$term1, $term2]));
|
||||||
|
|
||||||
// The root forum.
|
// The root forum.
|
||||||
|
@ -167,6 +168,7 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
|
||||||
->method('getStorage')
|
->method('getStorage')
|
||||||
->will($this->returnValueMap([
|
->will($this->returnValueMap([
|
||||||
['taxonomy_vocabulary', $vocab_storage],
|
['taxonomy_vocabulary', $vocab_storage],
|
||||||
|
['taxonomy_term', $term_storage],
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$config_factory = $this->getConfigFactoryStub(
|
$config_factory = $this->getConfigFactoryStub(
|
||||||
|
@ -177,6 +179,8 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$forum_manager = $this->getMock('Drupal\forum\ForumManagerInterface');
|
||||||
|
|
||||||
// Build a breadcrumb builder to test.
|
// Build a breadcrumb builder to test.
|
||||||
$breadcrumb_builder = $this->getMock(
|
$breadcrumb_builder = $this->getMock(
|
||||||
'Drupal\forum\Breadcrumb\ForumListingBreadcrumbBuilder', NULL, [
|
'Drupal\forum\Breadcrumb\ForumListingBreadcrumbBuilder', NULL, [
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace Drupal\Tests\forum\Unit\Breadcrumb;
|
||||||
|
|
||||||
use Drupal\Core\Cache\Cache;
|
use Drupal\Core\Cache\Cache;
|
||||||
use Drupal\Core\Link;
|
use Drupal\Core\Link;
|
||||||
|
use Drupal\taxonomy\TermStorageInterface;
|
||||||
use Drupal\Tests\UnitTestCase;
|
use Drupal\Tests\UnitTestCase;
|
||||||
use Symfony\Component\DependencyInjection\Container;
|
use Symfony\Component\DependencyInjection\Container;
|
||||||
|
|
||||||
|
@ -149,11 +150,12 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
|
||||||
$forum_manager = $this->getMockBuilder('Drupal\forum\ForumManagerInterface')
|
$forum_manager = $this->getMockBuilder('Drupal\forum\ForumManagerInterface')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$forum_manager->expects($this->at(0))
|
$term_storage = $this->getMockBuilder(TermStorageInterface::class)->getMock();
|
||||||
->method('getParents')
|
$term_storage->expects($this->at(0))
|
||||||
|
->method('loadAllParents')
|
||||||
->will($this->returnValue([$term1]));
|
->will($this->returnValue([$term1]));
|
||||||
$forum_manager->expects($this->at(1))
|
$term_storage->expects($this->at(1))
|
||||||
->method('getParents')
|
->method('loadAllParents')
|
||||||
->will($this->returnValue([$term1, $term2]));
|
->will($this->returnValue([$term1, $term2]));
|
||||||
|
|
||||||
$prophecy = $this->prophesize('Drupal\taxonomy\VocabularyInterface');
|
$prophecy = $this->prophesize('Drupal\taxonomy\VocabularyInterface');
|
||||||
|
@ -176,6 +178,7 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
|
||||||
->method('getStorage')
|
->method('getStorage')
|
||||||
->will($this->returnValueMap([
|
->will($this->returnValueMap([
|
||||||
['taxonomy_vocabulary', $vocab_storage],
|
['taxonomy_vocabulary', $vocab_storage],
|
||||||
|
['taxonomy_term', $term_storage],
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$config_factory = $this->getConfigFactoryStub(
|
$config_factory = $this->getConfigFactoryStub(
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Drupal\Tests\forum\Unit;
|
namespace Drupal\Tests\forum\Unit;
|
||||||
|
|
||||||
|
use Drupal\Core\Url;
|
||||||
use Drupal\simpletest\AssertHelperTrait;
|
use Drupal\simpletest\AssertHelperTrait;
|
||||||
use Drupal\Tests\UnitTestCase;
|
use Drupal\Tests\UnitTestCase;
|
||||||
|
|
||||||
|
@ -103,13 +104,16 @@ class ForumUninstallValidatorTest extends UnitTestCase {
|
||||||
->method('hasForumNodes')
|
->method('hasForumNodes')
|
||||||
->willReturn(TRUE);
|
->willReturn(TRUE);
|
||||||
|
|
||||||
|
$url = $this->prophesize(Url::class);
|
||||||
|
$url->toString()->willReturn('/path/to/vocabulary/overview');
|
||||||
|
|
||||||
$vocabulary = $this->getMock('Drupal\taxonomy\VocabularyInterface');
|
$vocabulary = $this->getMock('Drupal\taxonomy\VocabularyInterface');
|
||||||
$vocabulary->expects($this->once())
|
$vocabulary->expects($this->once())
|
||||||
->method('label')
|
->method('label')
|
||||||
->willReturn('Vocabulary label');
|
->willReturn('Vocabulary label');
|
||||||
$vocabulary->expects($this->once())
|
$vocabulary->expects($this->once())
|
||||||
->method('url')
|
->method('toUrl')
|
||||||
->willReturn('/path/to/vocabulary/overview');
|
->willReturn($url->reveal());
|
||||||
$vocabulary->expects($this->once())
|
$vocabulary->expects($this->once())
|
||||||
->method('access')
|
->method('access')
|
||||||
->willReturn(TRUE);
|
->willReturn(TRUE);
|
||||||
|
@ -143,7 +147,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
|
||||||
->method('label')
|
->method('label')
|
||||||
->willReturn('Vocabulary label');
|
->willReturn('Vocabulary label');
|
||||||
$vocabulary->expects($this->never())
|
$vocabulary->expects($this->never())
|
||||||
->method('url');
|
->method('toUrl');
|
||||||
$vocabulary->expects($this->once())
|
$vocabulary->expects($this->once())
|
||||||
->method('access')
|
->method('access')
|
||||||
->willReturn(FALSE);
|
->willReturn(FALSE);
|
||||||
|
@ -172,10 +176,13 @@ class ForumUninstallValidatorTest extends UnitTestCase {
|
||||||
->method('hasForumNodes')
|
->method('hasForumNodes')
|
||||||
->willReturn(FALSE);
|
->willReturn(FALSE);
|
||||||
|
|
||||||
|
$url = $this->prophesize(Url::class);
|
||||||
|
$url->toString()->willReturn('/path/to/vocabulary/overview');
|
||||||
|
|
||||||
$vocabulary = $this->getMock('Drupal\taxonomy\VocabularyInterface');
|
$vocabulary = $this->getMock('Drupal\taxonomy\VocabularyInterface');
|
||||||
$vocabulary->expects($this->once())
|
$vocabulary->expects($this->once())
|
||||||
->method('url')
|
->method('toUrl')
|
||||||
->willReturn('/path/to/vocabulary/overview');
|
->willReturn($url->reveal());
|
||||||
$vocabulary->expects($this->once())
|
$vocabulary->expects($this->once())
|
||||||
->method('label')
|
->method('label')
|
||||||
->willReturn('Vocabulary label');
|
->willReturn('Vocabulary label');
|
||||||
|
@ -211,7 +218,7 @@ class ForumUninstallValidatorTest extends UnitTestCase {
|
||||||
->method('label')
|
->method('label')
|
||||||
->willReturn('Vocabulary label');
|
->willReturn('Vocabulary label');
|
||||||
$vocabulary->expects($this->never())
|
$vocabulary->expects($this->never())
|
||||||
->method('url');
|
->method('toUrl');
|
||||||
$vocabulary->expects($this->once())
|
$vocabulary->expects($this->once())
|
||||||
->method('access')
|
->method('access')
|
||||||
->willReturn(FALSE);
|
->willReturn(FALSE);
|
||||||
|
|
|
@ -221,7 +221,9 @@ class MigrateExecutable implements MigrateExecutableInterface {
|
||||||
if ($save) {
|
if ($save) {
|
||||||
try {
|
try {
|
||||||
$this->getEventDispatcher()->dispatch(MigrateEvents::PRE_ROW_SAVE, new MigratePreRowSaveEvent($this->migration, $this->message, $row));
|
$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));
|
$this->getEventDispatcher()->dispatch(MigrateEvents::POST_ROW_SAVE, new MigratePostRowSaveEvent($this->migration, $this->message, $row, $destination_id_values));
|
||||||
if ($destination_id_values) {
|
if ($destination_id_values) {
|
||||||
// We do not save an idMap entry for config.
|
// We do not save an idMap entry for config.
|
||||||
|
|
|
@ -95,9 +95,9 @@ class MigrateExecutableTest extends MigrateTestCase {
|
||||||
->will($this->returnValue(['id' => 'test']));
|
->will($this->returnValue(['id' => 'test']));
|
||||||
|
|
||||||
$this->idMap->expects($this->once())
|
$this->idMap->expects($this->once())
|
||||||
->method('lookupDestinationId')
|
->method('lookupDestinationIds')
|
||||||
->with(['id' => 'test'])
|
->with(['id' => 'test'])
|
||||||
->will($this->returnValue(['test']));
|
->will($this->returnValue([['test']]));
|
||||||
|
|
||||||
$source->expects($this->once())
|
$source->expects($this->once())
|
||||||
->method('current')
|
->method('current')
|
||||||
|
@ -137,9 +137,9 @@ class MigrateExecutableTest extends MigrateTestCase {
|
||||||
->will($this->returnValue(['id' => 'test']));
|
->will($this->returnValue(['id' => 'test']));
|
||||||
|
|
||||||
$this->idMap->expects($this->once())
|
$this->idMap->expects($this->once())
|
||||||
->method('lookupDestinationId')
|
->method('lookupDestinationIds')
|
||||||
->with(['id' => 'test'])
|
->with(['id' => 'test'])
|
||||||
->will($this->returnValue(['test']));
|
->will($this->returnValue([['test']]));
|
||||||
|
|
||||||
$source->expects($this->once())
|
$source->expects($this->once())
|
||||||
->method('current')
|
->method('current')
|
||||||
|
@ -213,9 +213,9 @@ class MigrateExecutableTest extends MigrateTestCase {
|
||||||
->method('saveMessage');
|
->method('saveMessage');
|
||||||
|
|
||||||
$this->idMap->expects($this->once())
|
$this->idMap->expects($this->once())
|
||||||
->method('lookupDestinationId')
|
->method('lookupDestinationIds')
|
||||||
->with(['id' => 'test'])
|
->with(['id' => 'test'])
|
||||||
->will($this->returnValue(['test']));
|
->will($this->returnValue([['test']]));
|
||||||
|
|
||||||
$this->message->expects($this->once())
|
$this->message->expects($this->once())
|
||||||
->method('display')
|
->method('display')
|
||||||
|
@ -269,9 +269,9 @@ class MigrateExecutableTest extends MigrateTestCase {
|
||||||
->method('saveMessage');
|
->method('saveMessage');
|
||||||
|
|
||||||
$this->idMap->expects($this->once())
|
$this->idMap->expects($this->once())
|
||||||
->method('lookupDestinationId')
|
->method('lookupDestinationIds')
|
||||||
->with(['id' => 'test'])
|
->with(['id' => 'test'])
|
||||||
->will($this->returnValue(['test']));
|
->will($this->returnValue([['test']]));
|
||||||
|
|
||||||
$this->assertSame(MigrationInterface::RESULT_COMPLETED, $this->executable->import());
|
$this->assertSame(MigrationInterface::RESULT_COMPLETED, $this->executable->import());
|
||||||
}
|
}
|
||||||
|
@ -319,7 +319,7 @@ class MigrateExecutableTest extends MigrateTestCase {
|
||||||
->method('saveMessage');
|
->method('saveMessage');
|
||||||
|
|
||||||
$this->idMap->expects($this->never())
|
$this->idMap->expects($this->never())
|
||||||
->method('lookupDestinationId');
|
->method('lookupDestinationIds');
|
||||||
|
|
||||||
$this->assertSame(MigrationInterface::RESULT_COMPLETED, $this->executable->import());
|
$this->assertSame(MigrationInterface::RESULT_COMPLETED, $this->executable->import());
|
||||||
}
|
}
|
||||||
|
@ -367,9 +367,9 @@ class MigrateExecutableTest extends MigrateTestCase {
|
||||||
->method('saveMessage');
|
->method('saveMessage');
|
||||||
|
|
||||||
$this->idMap->expects($this->once())
|
$this->idMap->expects($this->once())
|
||||||
->method('lookupDestinationId')
|
->method('lookupDestinationIds')
|
||||||
->with(['id' => 'test'])
|
->with(['id' => 'test'])
|
||||||
->will($this->returnValue(['test']));
|
->will($this->returnValue([['test']]));
|
||||||
|
|
||||||
$this->message->expects($this->once())
|
$this->message->expects($this->once())
|
||||||
->method('display')
|
->method('display')
|
||||||
|
|
|
@ -85,7 +85,7 @@ services:
|
||||||
class: Drupal\serialization\EntityResolver\UuidResolver
|
class: Drupal\serialization\EntityResolver\UuidResolver
|
||||||
tags:
|
tags:
|
||||||
- { name: entity_resolver}
|
- { name: entity_resolver}
|
||||||
arguments: ['@entity.manager']
|
arguments: ['@entity.repository']
|
||||||
serialization.entity_resolver.target_id:
|
serialization.entity_resolver.target_id:
|
||||||
class: Drupal\serialization\EntityResolver\TargetIdResolver
|
class: Drupal\serialization\EntityResolver\TargetIdResolver
|
||||||
tags:
|
tags:
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Drupal\serialization\EntityResolver;
|
namespace Drupal\serialization\EntityResolver;
|
||||||
|
|
||||||
use Drupal\Core\Entity\EntityManagerInterface;
|
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,20 +11,20 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||||
class UuidResolver implements EntityResolverInterface {
|
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.
|
* Constructs a UuidResolver object.
|
||||||
*
|
*
|
||||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
* @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
|
||||||
* The entity manager.
|
* The entity repository.
|
||||||
*/
|
*/
|
||||||
public function __construct(EntityManagerInterface $entity_manager) {
|
public function __construct(EntityRepositoryInterface $entity_repository) {
|
||||||
$this->entityManager = $entity_manager;
|
$this->entityRepository = $entity_repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +35,7 @@ class UuidResolver implements EntityResolverInterface {
|
||||||
// deserialized. If it can return a UUID from that data, and if there's an
|
// deserialized. If it can return a UUID from that data, and if there's an
|
||||||
// entity with that UUID, then return its ID.
|
// entity with that UUID, then return its ID.
|
||||||
if (($normalizer instanceof UuidReferenceInterface) && ($uuid = $normalizer->getUuid($data))) {
|
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();
|
return $entity->id();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ class EntityNormalizer extends ComplexDataNormalizer implements DenormalizerInte
|
||||||
|
|
||||||
// The bundle property will be required to denormalize a bundleable
|
// The bundle property will be required to denormalize a bundleable
|
||||||
// fieldable entity.
|
// 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
|
// Extract bundle data to pass into entity creation if the entity type uses
|
||||||
// bundles.
|
// bundles.
|
||||||
if ($entity_type_definition->hasKey('bundle')) {
|
if ($entity_type_definition->hasKey('bundle')) {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Drupal\Tests\serialization\Unit\EntityResolver;
|
namespace Drupal\Tests\serialization\Unit\EntityResolver;
|
||||||
|
|
||||||
|
use Drupal\Core\Entity\EntityRepositoryInterface;
|
||||||
use Drupal\Tests\UnitTestCase;
|
use Drupal\Tests\UnitTestCase;
|
||||||
use Drupal\serialization\EntityResolver\UuidResolver;
|
use Drupal\serialization\EntityResolver\UuidResolver;
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@ class UuidResolverTest extends UnitTestCase {
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function setUp() {
|
protected function setUp() {
|
||||||
$this->entityManager = $this->getMockBuilder('Drupal\Core\Entity\EntityManager')
|
$this->entityManager = $this->getMockBuilder(EntityRepositoryInterface::class)
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ class EntityNormalizerTest extends UnitTestCase {
|
||||||
->with('bundle')
|
->with('bundle')
|
||||||
->will($this->returnValue('test_type'));
|
->will($this->returnValue('test_type'));
|
||||||
$entity_type->expects($this->once())
|
$entity_type->expects($this->once())
|
||||||
->method('isSubClassOf')
|
->method('entityClassImplements')
|
||||||
->with(FieldableEntityInterface::class)
|
->with(FieldableEntityInterface::class)
|
||||||
->willReturn(TRUE);
|
->willReturn(TRUE);
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ class EntityNormalizerTest extends UnitTestCase {
|
||||||
->with('bundle')
|
->with('bundle')
|
||||||
->will($this->returnValue('test_type'));
|
->will($this->returnValue('test_type'));
|
||||||
$entity_type->expects($this->once())
|
$entity_type->expects($this->once())
|
||||||
->method('isSubClassOf')
|
->method('entityClassImplements')
|
||||||
->with(FieldableEntityInterface::class)
|
->with(FieldableEntityInterface::class)
|
||||||
->willReturn(TRUE);
|
->willReturn(TRUE);
|
||||||
|
|
||||||
|
@ -303,7 +303,7 @@ class EntityNormalizerTest extends UnitTestCase {
|
||||||
|
|
||||||
$entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface');
|
$entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface');
|
||||||
$entity_type->expects($this->once())
|
$entity_type->expects($this->once())
|
||||||
->method('isSubClassOf')
|
->method('entityClassImplements')
|
||||||
->with(FieldableEntityInterface::class)
|
->with(FieldableEntityInterface::class)
|
||||||
->willReturn(TRUE);
|
->willReturn(TRUE);
|
||||||
$entity_type->expects($this->once())
|
$entity_type->expects($this->once())
|
||||||
|
@ -376,7 +376,7 @@ class EntityNormalizerTest extends UnitTestCase {
|
||||||
|
|
||||||
$entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface');
|
$entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface');
|
||||||
$entity_type->expects($this->once())
|
$entity_type->expects($this->once())
|
||||||
->method('isSubClassOf')
|
->method('entityClassImplements')
|
||||||
->with(FieldableEntityInterface::class)
|
->with(FieldableEntityInterface::class)
|
||||||
->willReturn(FALSE);
|
->willReturn(FALSE);
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,13 @@ class RolesRidTest extends UnitTestCase {
|
||||||
* Tests the titleQuery method.
|
* Tests the titleQuery method.
|
||||||
*
|
*
|
||||||
* @covers ::titleQuery
|
* @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() {
|
public function testTitleQuery() {
|
||||||
$role1 = new Role([
|
$role1 = new Role([
|
||||||
|
|
|
@ -133,10 +133,8 @@ class ViewsData {
|
||||||
*
|
*
|
||||||
* @param string|null $key
|
* @param string|null $key
|
||||||
* The key of the cache entry to retrieve. Defaults to NULL, this will
|
* The key of the cache entry to retrieve. Defaults to NULL, this will
|
||||||
* return all table data.
|
* return all table data. NULL $key deprecated in Drupal 8.2.x and will be
|
||||||
*
|
* removed in 9.0.0. Use getAll() instead.
|
||||||
* @deprecated 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
|
* @see https://www.drupal.org/node/2723553
|
||||||
*
|
*
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
<env name="SIMPLETEST_DB" value=""/>
|
<env name="SIMPLETEST_DB" value=""/>
|
||||||
<!-- Example BROWSERTEST_OUTPUT_DIRECTORY value: /path/to/webroot/sites/simpletest/browser_output -->
|
<!-- Example BROWSERTEST_OUTPUT_DIRECTORY value: /path/to/webroot/sites/simpletest/browser_output -->
|
||||||
<env name="BROWSERTEST_OUTPUT_DIRECTORY" value=""/>
|
<env name="BROWSERTEST_OUTPUT_DIRECTORY" value=""/>
|
||||||
<!-- To disable deprecation testing completely set SYMFONY_DEPRECATIONS_HELPER value: 'disabled' -->
|
<!-- To disable deprecation testing completely uncomment the next line. -->
|
||||||
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak_vendors"/>
|
<!-- <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 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 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"]' -->
|
<!-- Example for changing the driver args to phantomjs tests MINK_DRIVER_ARGS_PHANTOMJS value: '["http://127.0.0.1:8510"]' -->
|
||||||
|
|
|
@ -310,7 +310,12 @@ All arguments are long options.
|
||||||
|
|
||||||
--suppress-deprecations
|
--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> ...]]
|
<test1>[,<test2>[,<test3> ...]]
|
||||||
|
|
||||||
|
@ -825,13 +830,6 @@ function simpletest_script_run_one_test($test_id, $test_class) {
|
||||||
if ($args['suppress-deprecations']) {
|
if ($args['suppress-deprecations']) {
|
||||||
putenv('SYMFONY_DEPRECATIONS_HELPER=disabled');
|
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)) {
|
if (is_subclass_of($test_class, TestCase::class)) {
|
||||||
$status = simpletest_script_run_phpunit($test_id, $test_class);
|
$status = simpletest_script_run_phpunit($test_id, $test_class);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,6 +114,12 @@ class AssetResolverTest extends UnitTestCase {
|
||||||
/**
|
/**
|
||||||
* @covers ::getCssAssets
|
* @covers ::getCssAssets
|
||||||
* @dataProvider providerAttachedAssets
|
* @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) {
|
public function testGetCssAssets(AttachedAssetsInterface $assets_a, AttachedAssetsInterface $assets_b, $expected_cache_item_count) {
|
||||||
$this->assetResolver->getCssAssets($assets_a, FALSE);
|
$this->assetResolver->getCssAssets($assets_a, FALSE);
|
||||||
|
|
|
@ -483,6 +483,8 @@ class ContentEntityBaseUnitTest extends UnitTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::label
|
* @covers ::label
|
||||||
|
*
|
||||||
|
* @group legacy
|
||||||
*/
|
*/
|
||||||
public function testLabel() {
|
public function testLabel() {
|
||||||
// Make a mock with one method that we use as the entity's label callback.
|
// Make a mock with one method that we use as the entity's label callback.
|
||||||
|
|
|
@ -58,6 +58,13 @@ class EntityLinkTest extends UnitTestCase {
|
||||||
* @covers ::link
|
* @covers ::link
|
||||||
*
|
*
|
||||||
* @dataProvider providerTestLink
|
* @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 = []) {
|
public function testLink($entity_label, $link_text, $expected_text, $link_rel = 'canonical', array $link_options = []) {
|
||||||
$language = new Language(['id' => 'es']);
|
$language = new Language(['id' => 'es']);
|
||||||
|
@ -120,6 +127,13 @@ class EntityLinkTest extends UnitTestCase {
|
||||||
* @covers ::toLink
|
* @covers ::toLink
|
||||||
*
|
*
|
||||||
* @dataProvider providerTestLink
|
* @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 = []) {
|
public function testToLink($entity_label, $link_text, $expected_text, $link_rel = 'canonical', array $link_options = []) {
|
||||||
$language = new Language(['id' => 'es']);
|
$language = new Language(['id' => 'es']);
|
||||||
|
|
|
@ -168,6 +168,7 @@ class EntityUnitTest extends UnitTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers ::label
|
* @covers ::label
|
||||||
|
* @group legacy
|
||||||
*/
|
*/
|
||||||
public function testLabel() {
|
public function testLabel() {
|
||||||
// Make a mock with one method that we use as the entity's uri_callback. We
|
// Make a mock with one method that we use as the entity's uri_callback. We
|
||||||
|
|
|
@ -155,7 +155,7 @@ class WebAssert extends MinkWebAssert {
|
||||||
$option_field = $select_field->find('named', ['option', $option]);
|
$option_field = $select_field->find('named', ['option', $option]);
|
||||||
|
|
||||||
if ($option_field === NULL) {
|
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;
|
return $option_field;
|
||||||
|
|
Loading…
Reference in New Issue