Issue #3126563 by mondrake, daffie, alexpott: Replace usage of assertAttributeEquals() that is deprecated

merge-requests/2419/head
Alex Pott 2020-04-18 10:31:47 +01:00
parent cc564e260e
commit a6e402fc01
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
12 changed files with 27 additions and 34 deletions

View File

@ -10,6 +10,11 @@ use Drupal\Core\Plugin\PluginFormBase;
*/
class EmptyBlockForm extends PluginFormBase {
/**
* {@inheritdoc}
*/
public $plugin;
/**
* {@inheritdoc}
*/

View File

@ -93,7 +93,9 @@ class CommentBulkFormTest extends UnitTestCase {
$comment_bulk_form = new CommentBulkForm([], 'comment_bulk_form', $definition, $entity_type_manager, $language_manager, $messenger, $entity_repository);
$comment_bulk_form->init($executable, $display, $options);
$this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $comment_bulk_form);
$reflected_actions = (new \ReflectionObject($comment_bulk_form))->getProperty('actions');
$reflected_actions->setAccessible(TRUE);
$this->assertEquals(array_slice($actions, 0, -1, TRUE), $reflected_actions->getValue($comment_bulk_form));
}
}

View File

@ -57,18 +57,6 @@ class ForumBreadcrumbBuilderBaseTest extends UnitTestCase {
]
);
// Reflect upon our properties, except for config which is a special case.
$property_names = [
'entityTypeManager' => $entity_type_manager,
'forumManager' => $forum_manager,
'stringTranslation' => $translation_manager,
];
foreach ($property_names as $property_name => $property_value) {
$this->assertAttributeEquals(
$property_value, $property_name, $builder
);
}
// Test that the constructor made a config object with our info in it.
$reflector = new \ReflectionClass($builder);
$ref_property = $reflector->getProperty('config');

View File

@ -194,7 +194,7 @@ class MigrateSqlIdMapTest extends MigrateTestCase {
$message = $this->createMock('Drupal\migrate\MigrateMessageInterface');
$id_map = $this->getIdMap();
$id_map->setMessage($message);
$this->assertAttributeEquals($message, 'message', $id_map);
$this->assertEquals($message, $id_map->message);
}
/**

View File

@ -34,6 +34,11 @@ class TestSqlIdMap extends Sql implements \Iterator {
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $event_dispatcher);
}
/**
* {@inheritdoc}
*/
public $message;
/**
* {@inheritdoc}
*/

View File

@ -93,7 +93,9 @@ class NodeBulkFormTest extends UnitTestCase {
$node_bulk_form = new NodeBulkForm([], 'node_bulk_form', $definition, $entity_type_manager, $language_manager, $messenger, $entity_repository);
$node_bulk_form->init($executable, $display, $options);
$this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $node_bulk_form);
$reflected_actions = (new \ReflectionObject($node_bulk_form))->getProperty('actions');
$reflected_actions->setAccessible(TRUE);
$this->assertEquals(array_slice($actions, 0, -1, TRUE), $reflected_actions->getValue($node_bulk_form));
}
}

View File

@ -93,7 +93,9 @@ class UserBulkFormTest extends UnitTestCase {
$user_bulk_form = new UserBulkForm([], 'user_bulk_form', $definition, $entity_type_manager, $language_manager, $messenger, $entity_repository);
$user_bulk_form->init($executable, $display, $options);
$this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $user_bulk_form);
$reflected_actions = (new \ReflectionObject($user_bulk_form))->getProperty('actions');
$reflected_actions->setAccessible(TRUE);
$this->assertEquals(array_slice($actions, 0, -1, TRUE), $reflected_actions->getValue($user_bulk_form));
}
}

View File

@ -32,7 +32,7 @@ class MultipleBlockFormTest extends KernelTestBase {
// Ensure that EmptyBlockForm is used and the plugin is set.
$this->assertInstanceOf(EmptyBlockForm::class, $form_object2);
$this->assertAttributeEquals($block, 'plugin', $form_object2);
$this->assertEquals($block, $form_object2->plugin);
}
}

View File

@ -198,7 +198,10 @@ class ConnectionTest extends UnitTestCase {
$connection->schema()
);
$connection->destroy();
$this->assertAttributeEquals(NULL, 'schema', $connection);
$reflected_schema = (new \ReflectionObject($connection))->getProperty('schema');
$reflected_schema->setAccessible(TRUE);
$this->assertNull($reflected_schema->getValue($connection));
}
/**

View File

@ -248,8 +248,7 @@ class EntityTypeManagerTest extends UnitTestCase {
$banana_form = $this->entityTypeManager->getFormObject('banana', 'default');
$this->assertInstanceOf(TestEntityFormInjected::class, $banana_form);
$this->assertAttributeEquals('yellow', 'color', $banana_form);
$this->assertEquals('yellow', $banana_form->color);
}
/**
@ -500,7 +499,7 @@ class TestEntityFormInjected extends TestEntityForm implements ContainerInjectio
*
* @var string
*/
protected $color;
public $color;
/**
* Constructs a new TestEntityFormInjected.

View File

@ -11,18 +11,6 @@ use Drupal\Tests\UnitTestCase;
*/
class StaticMenuLinkOverridesTest extends UnitTestCase {
/**
* Tests the constructor.
*
* @covers ::__construct
*/
public function testConstruct() {
$config_factory = $this->getConfigFactoryStub(['core.menu.static_menu_link_overrides' => []]);
$static_override = new StaticMenuLinkOverrides($config_factory);
$this->assertAttributeEquals($config_factory, 'configFactory', $static_override);
}
/**
* Tests the reload method.
*

View File

@ -25,7 +25,6 @@ trait PHPUnit8Warnings {
private static $ignoredWarnings = [
'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.',
];
/**