Commit c2585a18 authored by catch's avatar catch

Issue #2961691 by alexpott, Berdir, timmillwood, idebr: Change...

Issue #2961691 by alexpott, Berdir, timmillwood, idebr: Change SYMFONY_DEPRECATIONS_HELPER back to strict
parent ba42166d
......@@ -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();
}
}
}
......
......@@ -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')
......
......@@ -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(),
]);
}
}
......
......@@ -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');
}
/**
......
......@@ -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) {
......
......@@ -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) {
......
......@@ -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 {
......
......@@ -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, [
......
......@@ -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(
......
......@@ -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);
......
......@@ -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.
......
......@@ -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')
......
......@@ -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:
......
......@@ -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();
}
}
......
......@@ -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')) {
......
......@@ -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();
......
......@@ -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);
......
......@@ -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([
......
......@@ -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
*
......
......@@ -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"]' -->
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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.
......
......@@ -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']);
......
......@@ -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
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment