Unverified Commit de686a93 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3126969 by mondrake, longwave, alexpott, daffie: Replace usage of...

Issue #3126969 by mondrake, longwave, alexpott, daffie: Replace usage of assertAttributeInstanceOf() that is deprecated

(cherry picked from commit 5bee7eac7ba372cc91e131d696d2d033a3977a26)
parent 219df57c
Loading
Loading
Loading
Loading
+47 −7
Changes for core/tests/Drupal/Tests/Core/Entity/EntityTypeManagerTest.php: 47 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -243,8 +243,8 @@ public function testGetFormObject() {

    $apple_form = $this->entityTypeManager->getFormObject('apple', 'default');
    $this->assertInstanceOf(TestEntityForm::class, $apple_form);
    $this->assertAttributeInstanceOf(ModuleHandlerInterface::class, 'moduleHandler', $apple_form);
    $this->assertAttributeInstanceOf(TranslationInterface::class, 'stringTranslation', $apple_form);
    $this->assertInstanceOf(ModuleHandlerInterface::class, $apple_form->moduleHandler);
    $this->assertInstanceOf(TranslationInterface::class, $apple_form->stringTranslation);

    $banana_form = $this->entityTypeManager->getFormObject('banana', 'default');
    $this->assertInstanceOf(TestEntityFormInjected::class, $banana_form);
@@ -272,7 +272,7 @@ public function testGetFormObjectInvalidOperation() {
   * @covers ::getHandler
   */
  public function testGetHandler() {
    $class = $this->getTestHandlerClass();
    $class = get_class($this->getMockForAbstractClass(TestEntityHandlerBase::class));
    $apple = $this->prophesize(EntityTypeInterface::class);
    $apple->getHandlerClass('storage')->willReturn($class);

@@ -282,8 +282,8 @@ public function testGetHandler() {

    $apple_controller = $this->entityTypeManager->getHandler('apple', 'storage');
    $this->assertInstanceOf($class, $apple_controller);
    $this->assertAttributeInstanceOf(ModuleHandlerInterface::class, 'moduleHandler', $apple_controller);
    $this->assertAttributeInstanceOf(TranslationInterface::class, 'stringTranslation', $apple_controller);
    $this->assertInstanceOf(ModuleHandlerInterface::class, $apple_controller->moduleHandler);
    $this->assertInstanceOf(TranslationInterface::class, $apple_controller->stringTranslation);
  }

  /**
@@ -312,8 +312,8 @@ public function testGetRouteProviders() {

    $apple_route_provider = $this->entityTypeManager->getRouteProviders('apple');
    $this->assertInstanceOf(TestRouteProvider::class, $apple_route_provider['default']);
    $this->assertAttributeInstanceOf(ModuleHandlerInterface::class, 'moduleHandler', $apple_route_provider['default']);
    $this->assertAttributeInstanceOf(TranslationInterface::class, 'stringTranslation', $apple_route_provider['default']);
    $this->assertInstanceOf(ModuleHandlerInterface::class, $apple_route_provider['default']->moduleHandler);
    $this->assertInstanceOf(TranslationInterface::class, $apple_route_provider['default']->stringTranslation);
  }

  /**
@@ -396,6 +396,26 @@ protected function getTestHandlerClass() {

}

/**
 * Provides a test entity handler.
 */
abstract class TestEntityHandlerBase extends EntityHandlerBase {

  /**
   * {@inheritdoc}
   */
  public $moduleHandler;

  /**
   * {@inheritdoc}
   */
  public $stringTranslation;

}

/**
 * Provides a test entity type manager.
 */
class TestEntityTypeManager extends EntityTypeManager {

  /**
@@ -415,6 +435,16 @@ public function setDiscovery(DiscoveryInterface $discovery) {
 */
class TestEntityForm extends EntityHandlerBase {

  /**
   * {@inheritdoc}
   */
  public $moduleHandler;

  /**
   * {@inheritdoc}
   */
  public $stringTranslation;

  /**
   * The entity type manager.
   *
@@ -496,4 +526,14 @@ public static function create(ContainerInterface $container) {
 */
class TestRouteProvider extends EntityHandlerBase {

  /**
   * {@inheritdoc}
   */
  public $moduleHandler;

  /**
   * {@inheritdoc}
   */
  public $stringTranslation;

}
+0 −1
Changes for core/tests/Drupal/Tests/Traits/PHPUnit8Warnings.php: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ trait PHPUnit8Warnings {
    'readAttribute() is deprecated and will be removed in PHPUnit 9.',
    'getObjectAttribute() is deprecated and will be removed in PHPUnit 9.',
    'assertAttributeEquals() is deprecated and will be removed in PHPUnit 9.',
    'assertAttributeInstanceOf() is deprecated and will be removed in PHPUnit 9.',
  ];

  /**