Unverified Commit de686a93 authored by alexpott's avatar alexpott
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
...@@ -243,8 +243,8 @@ public function testGetFormObject() { ...@@ -243,8 +243,8 @@ public function testGetFormObject() {
$apple_form = $this->entityTypeManager->getFormObject('apple', 'default'); $apple_form = $this->entityTypeManager->getFormObject('apple', 'default');
$this->assertInstanceOf(TestEntityForm::class, $apple_form); $this->assertInstanceOf(TestEntityForm::class, $apple_form);
$this->assertAttributeInstanceOf(ModuleHandlerInterface::class, 'moduleHandler', $apple_form); $this->assertInstanceOf(ModuleHandlerInterface::class, $apple_form->moduleHandler);
$this->assertAttributeInstanceOf(TranslationInterface::class, 'stringTranslation', $apple_form); $this->assertInstanceOf(TranslationInterface::class, $apple_form->stringTranslation);
$banana_form = $this->entityTypeManager->getFormObject('banana', 'default'); $banana_form = $this->entityTypeManager->getFormObject('banana', 'default');
$this->assertInstanceOf(TestEntityFormInjected::class, $banana_form); $this->assertInstanceOf(TestEntityFormInjected::class, $banana_form);
...@@ -272,7 +272,7 @@ public function testGetFormObjectInvalidOperation() { ...@@ -272,7 +272,7 @@ public function testGetFormObjectInvalidOperation() {
* @covers ::getHandler * @covers ::getHandler
*/ */
public function testGetHandler() { public function testGetHandler() {
$class = $this->getTestHandlerClass(); $class = get_class($this->getMockForAbstractClass(TestEntityHandlerBase::class));
$apple = $this->prophesize(EntityTypeInterface::class); $apple = $this->prophesize(EntityTypeInterface::class);
$apple->getHandlerClass('storage')->willReturn($class); $apple->getHandlerClass('storage')->willReturn($class);
...@@ -282,8 +282,8 @@ public function testGetHandler() { ...@@ -282,8 +282,8 @@ public function testGetHandler() {
$apple_controller = $this->entityTypeManager->getHandler('apple', 'storage'); $apple_controller = $this->entityTypeManager->getHandler('apple', 'storage');
$this->assertInstanceOf($class, $apple_controller); $this->assertInstanceOf($class, $apple_controller);
$this->assertAttributeInstanceOf(ModuleHandlerInterface::class, 'moduleHandler', $apple_controller); $this->assertInstanceOf(ModuleHandlerInterface::class, $apple_controller->moduleHandler);
$this->assertAttributeInstanceOf(TranslationInterface::class, 'stringTranslation', $apple_controller); $this->assertInstanceOf(TranslationInterface::class, $apple_controller->stringTranslation);
} }
/** /**
...@@ -312,8 +312,8 @@ public function testGetRouteProviders() { ...@@ -312,8 +312,8 @@ public function testGetRouteProviders() {
$apple_route_provider = $this->entityTypeManager->getRouteProviders('apple'); $apple_route_provider = $this->entityTypeManager->getRouteProviders('apple');
$this->assertInstanceOf(TestRouteProvider::class, $apple_route_provider['default']); $this->assertInstanceOf(TestRouteProvider::class, $apple_route_provider['default']);
$this->assertAttributeInstanceOf(ModuleHandlerInterface::class, 'moduleHandler', $apple_route_provider['default']); $this->assertInstanceOf(ModuleHandlerInterface::class, $apple_route_provider['default']->moduleHandler);
$this->assertAttributeInstanceOf(TranslationInterface::class, 'stringTranslation', $apple_route_provider['default']); $this->assertInstanceOf(TranslationInterface::class, $apple_route_provider['default']->stringTranslation);
} }
/** /**
...@@ -396,6 +396,26 @@ protected function getTestHandlerClass() { ...@@ -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 { class TestEntityTypeManager extends EntityTypeManager {
/** /**
...@@ -415,6 +435,16 @@ public function setDiscovery(DiscoveryInterface $discovery) { ...@@ -415,6 +435,16 @@ public function setDiscovery(DiscoveryInterface $discovery) {
*/ */
class TestEntityForm extends EntityHandlerBase { class TestEntityForm extends EntityHandlerBase {
/**
* {@inheritdoc}
*/
public $moduleHandler;
/**
* {@inheritdoc}
*/
public $stringTranslation;
/** /**
* The entity type manager. * The entity type manager.
* *
...@@ -496,4 +526,14 @@ public static function create(ContainerInterface $container) { ...@@ -496,4 +526,14 @@ public static function create(ContainerInterface $container) {
*/ */
class TestRouteProvider extends EntityHandlerBase { class TestRouteProvider extends EntityHandlerBase {
/**
* {@inheritdoc}
*/
public $moduleHandler;
/**
* {@inheritdoc}
*/
public $stringTranslation;
} }
...@@ -26,7 +26,6 @@ trait PHPUnit8Warnings { ...@@ -26,7 +26,6 @@ trait PHPUnit8Warnings {
'readAttribute() is deprecated and will be removed in PHPUnit 9.', 'readAttribute() is deprecated and will be removed in PHPUnit 9.',
'getObjectAttribute() 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.', 'assertAttributeEquals() is deprecated and will be removed in PHPUnit 9.',
'assertAttributeInstanceOf() is deprecated and will be removed in PHPUnit 9.',
]; ];
/** /**
......
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