Commit f483fcd2 authored by catch's avatar catch
Browse files

Issue #3309745 by andypost, Berdir, longwave, Wim Leers, Taran2L, mondrake,...

Issue #3309745 by andypost, Berdir, longwave, Wim Leers, Taran2L, mondrake, alexpott: Fix dynamic property deprecations and other unit test failures for PHP 8.2

(cherry picked from commit 88ca0c51)
parent 2fd6e85b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
use Drupal\Core\Language\Language;
use Drupal\Core\Session\AccountInterface;
use Drupal\Tests\UnitTestCase;
use Drupal\user\Entity\User;

/**
 * @coversDefaultClass \Drupal\contact\MailHandler
@@ -292,7 +293,7 @@ public function getSendMailMessages() {
   *   Mock sender for testing.
   */
  protected function getMockSender($anonymous = TRUE, $mail_address = 'anonymous@drupal.org') {
    $sender = $this->createMock('\Drupal\Core\Session\AccountInterface');
    $sender = $this->createMock(User::class);
    $sender->expects($this->once())
      ->method('isAnonymous')
      ->willReturn($anonymous);
+5 −9
Original line number Diff line number Diff line
@@ -262,20 +262,16 @@ public function testFieldComponent() {
    $this->assertEquals($default_formatter, $formatter->getPluginId());
    $this->assertEquals($formatter_settings, $formatter->getSettings());

    // Check that the formatter is statically persisted, by assigning an
    // arbitrary property and reading it back.
    $random_value = $this->randomString();
    $formatter->randomValue = $random_value;
    $formatter = $display->getRenderer($field_name);
    $this->assertEquals($random_value, $formatter->randomValue);
    // Check that the formatter is statically persisted.
    $this->assertSame($formatter, $display->getRenderer($field_name));

    // Check that changing the definition creates a new formatter.
    $display->setComponent($field_name, [
      'type' => 'field_test_multiple',
    ]);
    $formatter = $display->getRenderer($field_name);
    $this->assertEquals('field_test_multiple', $formatter->getPluginId());
    $this->assertFalse(isset($formatter->randomValue));
    $renderer = $display->getRenderer($field_name);
    $this->assertEquals('field_test_multiple', $renderer->getPluginId());
    $this->assertNotSame($formatter, $renderer);

    // Check that the display has dependencies on the field and the module that
    // provides the formatter.
+5 −9
Original line number Diff line number Diff line
@@ -103,20 +103,16 @@ public function testFieldComponent() {
    $this->assertEquals($default_widget, $widget->getPluginId());
    $this->assertEquals($widget_settings, $widget->getSettings());

    // Check that the widget is statically persisted, by assigning an
    // arbitrary property and reading it back.
    $random_value = $this->randomString();
    $widget->randomValue = $random_value;
    $widget = $form_display->getRenderer($field_name);
    $this->assertEquals($random_value, $widget->randomValue);
    // Check that the widget is statically persisted.
    $this->assertSame($widget, $form_display->getRenderer($field_name));

    // Check that changing the definition creates a new widget.
    $form_display->setComponent($field_name, [
      'type' => 'field_test_multiple',
    ]);
    $widget = $form_display->getRenderer($field_name);
    $this->assertEquals('test_field_widget', $widget->getPluginId());
    $this->assertFalse(isset($widget->randomValue));
    $renderer = $form_display->getRenderer($field_name);
    $this->assertEquals('test_field_widget', $renderer->getPluginId());
    $this->assertNotSame($widget, $renderer);

    // Check that specifying an unknown widget (e.g. case of a disabled module)
    // gets stored as is in the display, but results in the default widget being
+0 −6
Original line number Diff line number Diff line
@@ -7,7 +7,6 @@
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\RevisionableEntityBundleInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Session\AccountInterface;
@@ -118,11 +117,6 @@ public function testRevisionOperations($operation, array $hasPermissionMap, $ass
    $accessControl = new NodeAccessControlHandler($entityType, $grants, $entityTypeManager);
    $accessControl->setModuleHandler($moduleHandler);

    $nodeType = $this->createMock(RevisionableEntityBundleInterface::class);
    $typeProperty = new \stdClass();
    $typeProperty->entity = $nodeType;
    $node->type = $typeProperty;

    $access = $accessControl->access($node, $operation, $account, FALSE);
    $this->assertEquals($assertAccess, $access);
  }
+4 −3
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\Tests\serialization\Unit\Normalizer;

use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\EntityTypeRepositoryInterface;
@@ -187,7 +188,7 @@ public function testDenormalizeWithValidBundle() {
    $key_1 = $this->createMock(FieldItemListInterface::class);
    $key_2 = $this->createMock(FieldItemListInterface::class);

    $entity = $this->createMock(FieldableEntityInterface::class);
    $entity = $this->createMock(ContentEntityBase::class);
    $entity->expects($this->exactly(2))
      ->method('get')
      ->willReturnMap([
@@ -340,7 +341,7 @@ public function testDenormalizeWithNoBundle() {
    $key_1 = $this->createMock(FieldItemListInterface::class);
    $key_2 = $this->createMock(FieldItemListInterface::class);

    $entity = $this->createMock(FieldableEntityInterface::class);
    $entity = $this->createMock(ContentEntityBase::class);
    $entity->expects($this->exactly(2))
      ->method('get')
      ->willReturnMap([
@@ -409,7 +410,7 @@ public function testDenormalizeWithNoFieldableEntityType() {
    $storage->expects($this->once())
      ->method('create')
      ->with($test_data)
      ->willReturn($this->createMock('Drupal\Core\Entity\EntityInterface'));
      ->willReturn($this->createMock(ContentEntityBase::class));

    $this->entityTypeManager->expects($this->once())
      ->method('getStorage')
Loading