Issue #2961691 by alexpott, Berdir, timmillwood, idebr: Change SYMFONY_DEPRECATIONS_HELPER back to strict

merge-requests/1654/head
Nathaniel Catchpole 2018-05-11 15:20:00 +01:00
parent ba42166da2
commit c2585a1888
26 changed files with 119 additions and 68 deletions

View File

@ -107,7 +107,7 @@ class CommentLinkBuilder implements CommentLinkBuilderInterface {
'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 @@ class CommentLinkBuilder implements CommentLinkBuilderInterface {
]);
}
else {
$links['comment-add'] += ['url' => $entity->urlInfo()];
$links['comment-add'] += ['url' => $entity->toUrl()];
}
}
elseif ($this->currentUser->isAnonymous()) {
@ -174,7 +174,7 @@ class CommentLinkBuilder implements CommentLinkBuilderInterface {
]);
}
else {
$links['comment-add']['url'] = $entity->urlInfo();
$links['comment-add']['url'] = $entity->toUrl();
}
}
}

View File

@ -310,7 +310,7 @@ class CommentLinkBuilderTest extends UnitTestCase {
$url = Url::fromRoute('node.view');
$node->expects($this->any())
->method('urlInfo')
->method('toUrl')
->willReturn($url);
$node->expects($this->any())
->method('url')

View File

@ -134,16 +134,16 @@ class MailHandler implements MailHandlerInterface {
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(),
]);
}
}

View File

@ -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 @@ abstract class ForumBreadcrumbBuilderBase implements BreadcrumbBuilderInterface
$this->config = $config_factory->get('forum.settings');
$this->forumManager = $forum_manager;
$this->setStringTranslation($string_translation);
$this->termStorage = $entity_manager->getStorage('taxonomy_term');
}
/**

View File

@ -30,7 +30,7 @@ class ForumListingBreadcrumbBuilder extends ForumBreadcrumbBuilderBase {
$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) {

View File

@ -26,7 +26,7 @@ class ForumNodeBreadcrumbBuilder extends ForumBreadcrumbBuilderBase {
$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) {

View File

@ -62,7 +62,7 @@ class ForumUninstallValidator implements ModuleUninstallValidatorInterface {
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 {

View File

@ -4,6 +4,7 @@ namespace Drupal\Tests\forum\Unit\Breadcrumb;
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 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
$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 @@ class ForumListingBreadcrumbBuilderTest extends UnitTestCase {
->method('getStorage')
->will($this->returnValueMap([
['taxonomy_vocabulary', $vocab_storage],
['taxonomy_term', $term_storage],
]));
$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.
$breadcrumb_builder = $this->getMock(
'Drupal\forum\Breadcrumb\ForumListingBreadcrumbBuilder', NULL, [

View File

@ -4,6 +4,7 @@ namespace Drupal\Tests\forum\Unit\Breadcrumb;
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 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
$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 @@ class ForumNodeBreadcrumbBuilderTest extends UnitTestCase {
->method('getStorage')
->will($this->returnValueMap([
['taxonomy_vocabulary', $vocab_storage],
['taxonomy_term', $term_storage],
]));
$config_factory = $this->getConfigFactoryStub(

View File

@ -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 @@ class ForumUninstallValidatorTest extends UnitTestCase {
->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 @@ class ForumUninstallValidatorTest extends UnitTestCase {
->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 @@ class ForumUninstallValidatorTest extends UnitTestCase {
->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 @@ class ForumUninstallValidatorTest extends UnitTestCase {
->method('label')
->willReturn('Vocabulary label');
$vocabulary->expects($this->never())
->method('url');
->method('toUrl');
$vocabulary->expects($this->once())
->method('access')
->willReturn(FALSE);

View File

@ -221,7 +221,9 @@ class MigrateExecutable implements MigrateExecutableInterface {
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.

View File

@ -95,9 +95,9 @@ class MigrateExecutableTest extends MigrateTestCase {
->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 @@ class MigrateExecutableTest extends MigrateTestCase {
->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 @@ class MigrateExecutableTest extends MigrateTestCase {
->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 @@ class MigrateExecutableTest extends MigrateTestCase {
->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 @@ class MigrateExecutableTest extends MigrateTestCase {
->method('saveMessage');
$this->idMap->expects($this->never())
->method('lookupDestinationId');
->method('lookupDestinationIds');
$this->assertSame(MigrationInterface::RESULT_COMPLETED, $this->executable->import());
}
@ -367,9 +367,9 @@ class MigrateExecutableTest extends MigrateTestCase {
->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')

View File

@ -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:

View File

@ -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 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
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 @@ class UuidResolver implements EntityResolverInterface {
// 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();
}
}

View File

@ -40,7 +40,7 @@ class EntityNormalizer extends ComplexDataNormalizer implements DenormalizerInte
// 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')) {

View File

@ -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();

View File

@ -119,7 +119,7 @@ class EntityNormalizerTest extends UnitTestCase {
->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 @@ class EntityNormalizerTest extends UnitTestCase {
->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 @@ class EntityNormalizerTest extends UnitTestCase {
$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 @@ class EntityNormalizerTest extends UnitTestCase {
$entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface');
$entity_type->expects($this->once())
->method('isSubClassOf')
->method('entityClassImplements')
->with(FieldableEntityInterface::class)
->willReturn(FALSE);

View File

@ -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([

View File

@ -133,10 +133,8 @@ class ViewsData {
*
* @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
*

View File

@ -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"]' -->

View File

@ -310,7 +310,12 @@ All arguments are long options.
--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);
}

View File

@ -114,6 +114,12 @@ class AssetResolverTest extends UnitTestCase {
/**
* @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);

View File

@ -483,6 +483,8 @@ class ContentEntityBaseUnitTest extends UnitTestCase {
/**
* @covers ::label
*
* @group legacy
*/
public function testLabel() {
// Make a mock with one method that we use as the entity's label callback.

View File

@ -58,6 +58,13 @@ class EntityLinkTest extends UnitTestCase {
* @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 @@ class EntityLinkTest extends UnitTestCase {
* @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']);

View File

@ -168,6 +168,7 @@ class EntityUnitTest extends UnitTestCase {
/**
* @covers ::label
* @group legacy
*/
public function testLabel() {
// Make a mock with one method that we use as the entity's uri_callback. We

View File

@ -155,7 +155,7 @@ class WebAssert extends MinkWebAssert {
$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;