diff --git a/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php b/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php index 8482acffa1dfd5d684292da57cae6a85c8f655ef..66668eed18eb4feeab7514ef75d75028fc5f8746 100644 --- a/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php +++ b/core/modules/ckeditor5/src/Plugin/Editor/CKEditor5.php @@ -859,7 +859,6 @@ protected static function createEphemeralPairedEditor(EditorInterface $editor, F $paired_editor->enforceIsNew(TRUE); $reflector = new \ReflectionObject($paired_editor); $property = $reflector->getProperty('filterFormat'); - $property->setAccessible(TRUE); $property->setValue($paired_editor, clone $filter_format); return $paired_editor; } diff --git a/core/modules/ckeditor5/src/SmartDefaultSettings.php b/core/modules/ckeditor5/src/SmartDefaultSettings.php index 4a17e004f1a28ed20431d105b4bdc07f354b4d5e..5d3e0b243947bc02145191fb54b740fa445c2f92 100644 --- a/core/modules/ckeditor5/src/SmartDefaultSettings.php +++ b/core/modules/ckeditor5/src/SmartDefaultSettings.php @@ -125,7 +125,6 @@ public function computeSmartDefaultSettings(?EditorInterface $text_editor, Filte // @todo Remove in https://www.drupal.org/project/drupal/issues/3231347. $reflector = new \ReflectionObject($text_editor); $property = $reflector->getProperty('filterFormat'); - $property->setAccessible(TRUE); $property->setValue($text_editor, $text_format); } diff --git a/core/modules/ckeditor5/tests/src/Traits/PrivateMethodUnitTestTrait.php b/core/modules/ckeditor5/tests/src/Traits/PrivateMethodUnitTestTrait.php index e4e69ee25ca5d8eb51986b2c766203f300c7cf02..9a2a2c7210f832b00f0b7f408c0032a02ea6d291 100644 --- a/core/modules/ckeditor5/tests/src/Traits/PrivateMethodUnitTestTrait.php +++ b/core/modules/ckeditor5/tests/src/Traits/PrivateMethodUnitTestTrait.php @@ -23,7 +23,6 @@ trait PrivateMethodUnitTestTrait { protected static function getMethod(string $fqcn, string $name): \ReflectionMethod { $class = new \ReflectionClass($fqcn); $method = $class->getMethod($name); - $method->setAccessible(TRUE); return $method; } diff --git a/core/modules/comment/tests/src/Unit/Plugin/views/field/CommentBulkFormTest.php b/core/modules/comment/tests/src/Unit/Plugin/views/field/CommentBulkFormTest.php index 6a9aded8c94537d8c8a771d66269fc88d073024e..e4aa6dae605032fdd38d78a6867168d1487289d4 100644 --- a/core/modules/comment/tests/src/Unit/Plugin/views/field/CommentBulkFormTest.php +++ b/core/modules/comment/tests/src/Unit/Plugin/views/field/CommentBulkFormTest.php @@ -94,7 +94,6 @@ public function testConstructor() { $comment_bulk_form->init($executable, $display, $options); $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)); } diff --git a/core/modules/content_moderation/tests/src/Unit/ContentModerationRouteSubscriberTest.php b/core/modules/content_moderation/tests/src/Unit/ContentModerationRouteSubscriberTest.php index 10ab1b0ca89dc25efceabda77790c2c8d2c6d9ec..01125ef764843ede1d4017706db600e3f80f337d 100644 --- a/core/modules/content_moderation/tests/src/Unit/ContentModerationRouteSubscriberTest.php +++ b/core/modules/content_moderation/tests/src/Unit/ContentModerationRouteSubscriberTest.php @@ -61,7 +61,6 @@ protected function setupEntityTypes() { ]; $reflector = new \ReflectionProperty($this->routeSubscriber, 'moderatedEntityTypes'); - $reflector->setAccessible(TRUE); $reflector->setValue($this->routeSubscriber, $entity_types); } diff --git a/core/modules/field_ui/tests/src/Unit/FieldConfigEditFormTest.php b/core/modules/field_ui/tests/src/Unit/FieldConfigEditFormTest.php index 04ecaf4ecd5a5fe1e49fafb9c6a4f461ca3696e9..00267079bcb30aaa8b49fbbd7d7c901f6131bdbc 100644 --- a/core/modules/field_ui/tests/src/Unit/FieldConfigEditFormTest.php +++ b/core/modules/field_ui/tests/src/Unit/FieldConfigEditFormTest.php @@ -38,7 +38,6 @@ protected function setUp(): void { public function testHasAnyRequired(array $element, bool $result) { $reflection = new \ReflectionClass('\Drupal\field_ui\Form\FieldConfigEditForm'); $method = $reflection->getMethod('hasAnyRequired'); - $method->setAccessible(TRUE); $this->assertEquals($result, $method->invoke($this->fieldConfigEditForm, $element)); } diff --git a/core/modules/filter/tests/src/Kernel/Migrate/d6/FilterFormatPermissionTest.php b/core/modules/filter/tests/src/Kernel/Migrate/d6/FilterFormatPermissionTest.php index dcdf97b90359bcb5e516d0bdb7c637c1609ff1d7..e3dff1116bf353e957b0cfd2498d2537fc8555b3 100644 --- a/core/modules/filter/tests/src/Kernel/Migrate/d6/FilterFormatPermissionTest.php +++ b/core/modules/filter/tests/src/Kernel/Migrate/d6/FilterFormatPermissionTest.php @@ -24,7 +24,6 @@ public function testConfigurableFilterFormat() { $migration = Migration::create($this->container, [], 'custom_migration', []); $filterFormatPermissionMigration = FilterFormatPermission::create($this->container, ['migration' => 'custom_filter_format'], 'custom_filter_format', [], $migration); $reflected_config = new \ReflectionProperty($filterFormatPermissionMigration, 'configuration'); - $reflected_config->setAccessible(TRUE); $config = $reflected_config->getValue($filterFormatPermissionMigration); $this->assertEquals('custom_filter_format', $config['migration']); } diff --git a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumBreadcrumbBuilderBaseTest.php b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumBreadcrumbBuilderBaseTest.php index 062b8a958f755092860de4f055e7712c6d380139..9d4c3ff64d7861e81da30b1c7b09de236f52b98d 100644 --- a/core/modules/forum/tests/src/Unit/Breadcrumb/ForumBreadcrumbBuilderBaseTest.php +++ b/core/modules/forum/tests/src/Unit/Breadcrumb/ForumBreadcrumbBuilderBaseTest.php @@ -60,7 +60,6 @@ public function testConstructor() { // Test that the constructor made a config object with our info in it. $reflector = new \ReflectionClass($builder); $ref_property = $reflector->getProperty('config'); - $ref_property->setAccessible(TRUE); $config = $ref_property->getValue($builder); $this->assertEquals('IAmATestValue', $config->get('IAmATestKey')); } diff --git a/core/modules/jsonapi/tests/src/Kernel/Query/FilterTest.php b/core/modules/jsonapi/tests/src/Kernel/Query/FilterTest.php index c9bae28c113326bf2865f6523bac6cc7f6d0a31d..dad459c3dae86e0e0f28679fe03c6f2223addbea 100644 --- a/core/modules/jsonapi/tests/src/Kernel/Query/FilterTest.php +++ b/core/modules/jsonapi/tests/src/Kernel/Query/FilterTest.php @@ -154,14 +154,11 @@ public function testQueryCondition() { // Expose parts of \Drupal\Core\Entity\Query\Sql\Query::execute(). $o = new \ReflectionObject($entity_query); $m1 = $o->getMethod('prepare'); - $m1->setAccessible(TRUE); $m2 = $o->getMethod('compile'); - $m2->setAccessible(TRUE); // The private property computed by the two previous private calls, whose // value we need to inspect. $p = $o->getProperty('sqlQuery'); - $p->setAccessible(TRUE); $m1->invoke($entity_query); $m2->invoke($entity_query); diff --git a/core/modules/jsonapi/tests/src/Kernel/ResourceType/ResourceTypeRepositoryTest.php b/core/modules/jsonapi/tests/src/Kernel/ResourceType/ResourceTypeRepositoryTest.php index 40f4391944a408d78c6939071610184d70c020ae..e7d5216e5c5eb7823a589d1d4ef1a4aedbc19b1d 100644 --- a/core/modules/jsonapi/tests/src/Kernel/ResourceType/ResourceTypeRepositoryTest.php +++ b/core/modules/jsonapi/tests/src/Kernel/ResourceType/ResourceTypeRepositoryTest.php @@ -124,7 +124,6 @@ public function testMappingNameConflictCheck($field_name_list) { $bundle = 'article'; $reflection_class = new \ReflectionClass($this->resourceTypeRepository); $reflection_method = $reflection_class->getMethod('getFields'); - $reflection_method->setAccessible(TRUE); $this->expectException(\LogicException::class); $this->expectExceptionMessage("The generated alias '{$field_name_list[1]}' for field name '{$field_name_list[0]}' conflicts with an existing field. Please report this in the JSON:API issue queue!"); diff --git a/core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php b/core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php index a2fb19c5f86ad50510e911e282ed9300bfd38204..7a34a41a6252a0d3df0eab283f1177051b5733b4 100644 --- a/core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php +++ b/core/modules/jsonapi/tests/src/Unit/EventSubscriber/ResourceResponseValidatorTest.php @@ -103,7 +103,6 @@ public function testValidateResponse($request, $response, $expected, $descriptio // Expose protected ResourceResponseSubscriber::validateResponse() method. $object = new \ReflectionObject($this->subscriber); $method = $object->getMethod('validateResponse'); - $method->setAccessible(TRUE); $this->assertSame($expected, $method->invoke($this->subscriber, $response, $request), $description); } diff --git a/core/modules/layout_builder/tests/src/Unit/DefaultsSectionStorageTest.php b/core/modules/layout_builder/tests/src/Unit/DefaultsSectionStorageTest.php index 578b1b663287a506fb042bb42975d822aa39a6f8..302658068a39cd0e1d2efe05d1b163c11c9fdcca 100644 --- a/core/modules/layout_builder/tests/src/Unit/DefaultsSectionStorageTest.php +++ b/core/modules/layout_builder/tests/src/Unit/DefaultsSectionStorageTest.php @@ -134,7 +134,6 @@ public function testExtractEntityFromRoute($success, $expected_entity_id, $value } $method = new \ReflectionMethod($this->plugin, 'extractEntityFromRoute'); - $method->setAccessible(TRUE); $result = $method->invoke($this->plugin, $value, $defaults); if ($success) { $this->assertEquals('the_return_value', $result); @@ -210,7 +209,6 @@ public function testExtractEntityFromRouteCreate() { $this->entityTypeManager->getStorage('entity_view_display')->willReturn($entity_storage->reveal()); $method = new \ReflectionMethod($this->plugin, 'extractEntityFromRoute'); - $method->setAccessible(TRUE); $result = $method->invoke($this->plugin, $value, []); $this->assertSame($expected, $result); } diff --git a/core/modules/layout_builder/tests/src/Unit/OverridesSectionStorageTest.php b/core/modules/layout_builder/tests/src/Unit/OverridesSectionStorageTest.php index 14f3576bafd2bdae3dfff95d3858f84749c2cb6d..4e7fd27d4180c9f6e95c263c1879e4aad3c121af 100644 --- a/core/modules/layout_builder/tests/src/Unit/OverridesSectionStorageTest.php +++ b/core/modules/layout_builder/tests/src/Unit/OverridesSectionStorageTest.php @@ -106,7 +106,6 @@ public function testExtractEntityFromRoute($success, $expected_entity_type_id, $ } $method = new \ReflectionMethod($this->plugin, 'extractEntityFromRoute'); - $method->setAccessible(TRUE); $result = $method->invoke($this->plugin, $value, $defaults); if ($success) { $this->assertInstanceOf(FieldableEntityInterface::class, $result); diff --git a/core/modules/layout_builder/tests/src/Unit/SectionStorageManagerTest.php b/core/modules/layout_builder/tests/src/Unit/SectionStorageManagerTest.php index 0c13e5ddd14e03a635e82d2878735e7e662ec70f..50d11c371a128cebacd7436b1fcf65c94d1b3952 100644 --- a/core/modules/layout_builder/tests/src/Unit/SectionStorageManagerTest.php +++ b/core/modules/layout_builder/tests/src/Unit/SectionStorageManagerTest.php @@ -73,14 +73,12 @@ protected function setUp(): void { $this->discovery = $this->prophesize(DiscoveryInterface::class); $reflection_property = new \ReflectionProperty($this->manager, 'discovery'); - $reflection_property->setAccessible(TRUE); $reflection_property->setValue($this->manager, $this->discovery->reveal()); $this->plugin = $this->prophesize(SectionStorageInterface::class); $this->factory = $this->prophesize(FactoryInterface::class); $this->factory->createInstance('the_plugin_id', [])->willReturn($this->plugin->reveal()); $reflection_property = new \ReflectionProperty($this->manager, 'factory'); - $reflection_property->setAccessible(TRUE); $reflection_property->setValue($this->manager, $this->factory->reveal()); } diff --git a/core/modules/locale/tests/src/Unit/LocaleLookupTest.php b/core/modules/locale/tests/src/Unit/LocaleLookupTest.php index bcc09c250cfad6b8d87cc35a1ea4906f80682335..59b439354a10f17c534423c7029529cf4078203e 100644 --- a/core/modules/locale/tests/src/Unit/LocaleLookupTest.php +++ b/core/modules/locale/tests/src/Unit/LocaleLookupTest.php @@ -363,7 +363,6 @@ public function testGetCid(array $roles, $expected) { $o = new \ReflectionObject($locale_lookup); $method = $o->getMethod('getCid'); - $method->setAccessible(TRUE); $cid = $method->invoke($locale_lookup, 'getCid'); $this->assertEquals($expected, $cid); diff --git a/core/modules/menu_link_content/tests/src/Unit/MenuLinkPluginTest.php b/core/modules/menu_link_content/tests/src/Unit/MenuLinkPluginTest.php index a6af5800c6b697be0c7ee16a7d02dc89a92a2c2b..1643a55ad9a11c3b636392f598c472bf1fba1d34 100644 --- a/core/modules/menu_link_content/tests/src/Unit/MenuLinkPluginTest.php +++ b/core/modules/menu_link_content/tests/src/Unit/MenuLinkPluginTest.php @@ -23,7 +23,6 @@ public function testGetInstanceReflection() { $class = new \ReflectionClass(MenuLinkContent::class); $instance_method = $class->getMethod('getUuid'); - $instance_method->setAccessible(TRUE); $this->assertEquals('test_id', $instance_method->invoke($menu_link_content_plugin)); } diff --git a/core/modules/migrate/tests/src/Kernel/MigrateSqlSourceTestBase.php b/core/modules/migrate/tests/src/Kernel/MigrateSqlSourceTestBase.php index ba11c234a667463cc61fddf8d6686f0cc87aaf03..da3414ffa857a9b44a37a2d99020f7e3101e322f 100644 --- a/core/modules/migrate/tests/src/Kernel/MigrateSqlSourceTestBase.php +++ b/core/modules/migrate/tests/src/Kernel/MigrateSqlSourceTestBase.php @@ -91,7 +91,6 @@ public function testSource(array $source_data, array $expected_data, $expected_c // reflection hack to set it in the plugin instance. $reflector = new \ReflectionObject($plugin); $property = $reflector->getProperty('database'); - $property->setAccessible(TRUE); $property->setValue($plugin, $this->getDatabase($source_data)); /** @var MemoryCounterBackend $cache **/ @@ -99,7 +98,6 @@ public function testSource(array $source_data, array $expected_data, $expected_c if ($expected_cache_key) { // Verify the computed cache key. $property = $reflector->getProperty('cacheKey'); - $property->setAccessible(TRUE); $this->assertSame($expected_cache_key, $property->getValue($plugin)); // Cache miss prior to calling ::count(). diff --git a/core/modules/migrate/tests/src/Kernel/Plugin/source/MigrationSourceCacheTest.php b/core/modules/migrate/tests/src/Kernel/Plugin/source/MigrationSourceCacheTest.php index 4be68c05a2ec708d611b738d05cb6dd2469cf296..4cf9804529adca57c0e84fe19de790f32624944d 100644 --- a/core/modules/migrate/tests/src/Kernel/Plugin/source/MigrationSourceCacheTest.php +++ b/core/modules/migrate/tests/src/Kernel/Plugin/source/MigrationSourceCacheTest.php @@ -83,7 +83,6 @@ public function testCacheCountsNotContaminated() { // Verify the cache keys are different. $cache_key_property = new \ReflectionProperty(SourcePluginBase::class, 'cacheKey'); - $cache_key_property->setAccessible(TRUE); $this->assertNotEquals($cache_key_property->getValue($migration_1_source), $cache_key_property->getValue($migration_2_source)); } @@ -112,7 +111,6 @@ public function testCacheCountsUsed() { // Pollute the cache. $cache_key_property = new \ReflectionProperty($migration_source, 'cacheKey'); - $cache_key_property->setAccessible(TRUE); $cache_key = $cache_key_property->getValue($migration_source); \Drupal::cache('migrate')->set($cache_key, 7); $this->assertCount(7, $migration_source); diff --git a/core/modules/migrate/tests/src/Kernel/QueryBatchTest.php b/core/modules/migrate/tests/src/Kernel/QueryBatchTest.php index d1583487631daa197ce2aaf33472baf89bc722ea..0fd188ae3e00383e4e9e24e1919427624723de80 100644 --- a/core/modules/migrate/tests/src/Kernel/QueryBatchTest.php +++ b/core/modules/migrate/tests/src/Kernel/QueryBatchTest.php @@ -156,7 +156,6 @@ public function testQueryBatch($source_data, $expected_data, $num_rows, $configu // reflection hack to set it in the plugin instance. $reflector = new \ReflectionObject($plugin); $property = $reflector->getProperty('database'); - $property->setAccessible(TRUE); $connection = $this->getDatabase($source_data); $property->setValue($plugin, $connection); @@ -183,7 +182,6 @@ public function testQueryBatch($source_data, $expected_data, $num_rows, $configu $expected_batch_size = $configuration['batch_size']; } $property = $reflector->getProperty('batchSize'); - $property->setAccessible(TRUE); self::assertSame($expected_batch_size, $property->getValue($plugin)); // Test the batch count. @@ -194,7 +192,6 @@ public function testQueryBatch($source_data, $expected_data, $num_rows, $configu } } $property = $reflector->getProperty('batch'); - $property->setAccessible(TRUE); self::assertSame($expected_batch_count, $property->getValue($plugin)); } diff --git a/core/modules/mysql/tests/src/Kernel/mysql/PrefixInfoTest.php b/core/modules/mysql/tests/src/Kernel/mysql/PrefixInfoTest.php index 929cb649072475f9dea8919b5346bf8176fdbf0e..10835c0ae46d5811a4ad82089952c39585909392 100644 --- a/core/modules/mysql/tests/src/Kernel/mysql/PrefixInfoTest.php +++ b/core/modules/mysql/tests/src/Kernel/mysql/PrefixInfoTest.php @@ -33,21 +33,18 @@ public function testGetPrefixInfo() { // Get the prefix info for the first database. $method = new \ReflectionMethod($db1_schema, 'getPrefixInfo'); - $method->setAccessible(TRUE); $db1_info = $method->invoke($db1_schema); // We change the database after opening the connection, so as to prevent // connecting to a non-existent database. $reflection = new \ReflectionObject($db2_connection); $property = $reflection->getProperty('connectionOptions'); - $property->setAccessible(TRUE); $connection_info['default']['database'] = 'foobar'; $property->setValue($db2_connection, $connection_info['default']); // For testing purposes, we also change the database info. $reflection_class = new \ReflectionClass(Database::class); $property = $reflection_class->getProperty('databaseInfo'); - $property->setAccessible(TRUE); $info = $property->getValue(); $info['extra']['default']['database'] = 'foobar'; $property->setValue(NULL, $info); diff --git a/core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php b/core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php index f219b373280d5da0a30c0deb2d77ae93c6913414..7e373f2aae1c45786f267cac7e3585c60e3336f1 100644 --- a/core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php +++ b/core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php @@ -240,7 +240,6 @@ public function testIntrospectIndexSchema(): void { unset($table_specification['fields']); $introspect_index_schema = new \ReflectionMethod(get_class($this->schema), 'introspectIndexSchema'); - $introspect_index_schema->setAccessible(TRUE); $index_schema = $introspect_index_schema->invoke($this->schema, $table_name); $this->assertEquals($table_specification, $index_schema); diff --git a/core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php b/core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php index 4f3f98b571c78e71834e9bcea66775a3cea32b65..044e4340b41b08391dec3bfc8d04466ddc9f17c0 100644 --- a/core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php +++ b/core/modules/node/tests/src/Unit/Plugin/views/field/NodeBulkFormTest.php @@ -94,7 +94,6 @@ public function testConstructor() { $node_bulk_form->init($executable, $display, $options); $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)); } diff --git a/core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php b/core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php index b7fee8694a838f1c19ccb3bf975cf14cae6ec2ef..19158e1131726f3ce45efae5399754378a17b5b7 100644 --- a/core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php +++ b/core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php @@ -107,13 +107,11 @@ public function testIntrospectIndexSchema(): void { unset($table_specification['fields']); $introspect_index_schema = new \ReflectionMethod(get_class($this->schema), 'introspectIndexSchema'); - $introspect_index_schema->setAccessible(TRUE); $index_schema = $introspect_index_schema->invoke($this->schema, $table_name); // The PostgreSQL driver is using a custom naming scheme for its indexes, so // we need to adjust the initial table specification. $ensure_identifier_length = new \ReflectionMethod(get_class($this->schema), 'ensureIdentifiersLength'); - $ensure_identifier_length->setAccessible(TRUE); foreach ($table_specification['unique keys'] as $original_index_name => $columns) { unset($table_specification['unique keys'][$original_index_name]); diff --git a/core/modules/rest/tests/src/Unit/EntityResourceValidationTraitTest.php b/core/modules/rest/tests/src/Unit/EntityResourceValidationTraitTest.php index 99bd36db1ea7bf7e8919785379678442a3c84e5e..83630dbeb84c8647d924b89eaae16c6ad99f00de 100644 --- a/core/modules/rest/tests/src/Unit/EntityResourceValidationTraitTest.php +++ b/core/modules/rest/tests/src/Unit/EntityResourceValidationTraitTest.php @@ -23,7 +23,6 @@ public function testValidate() { $trait = new EntityResourceValidationTraitTestClass(); $method = new \ReflectionMethod($trait, 'validate'); - $method->setAccessible(TRUE); $violations = $this->prophesize(EntityConstraintViolationList::class); $violations->filterByFieldAccess()->shouldBeCalled()->willReturn([]); @@ -63,7 +62,6 @@ public function testFailedValidate() { $trait = new EntityResourceValidationTraitTestClass(); $method = new \ReflectionMethod($trait, 'validate'); - $method->setAccessible(TRUE); $this->expectException(UnprocessableEntityHttpException::class); diff --git a/core/modules/sqlite/tests/src/Kernel/sqlite/SchemaTest.php b/core/modules/sqlite/tests/src/Kernel/sqlite/SchemaTest.php index a3aec37553fd51866dbca285a4fe06e9088a3e4c..4d32f0abbca38d0fb55c290a27c75a2851252500 100644 --- a/core/modules/sqlite/tests/src/Kernel/sqlite/SchemaTest.php +++ b/core/modules/sqlite/tests/src/Kernel/sqlite/SchemaTest.php @@ -94,7 +94,6 @@ public function testIntrospectIndexSchema(): void { unset($table_specification['fields']); $introspect_index_schema = new \ReflectionMethod(get_class($this->schema), 'introspectIndexSchema'); - $introspect_index_schema->setAccessible(TRUE); $index_schema = $introspect_index_schema->invoke($this->schema, $table_name); $this->assertEquals($table_specification, $index_schema); diff --git a/core/modules/system/tests/src/Kernel/Common/SystemListingTest.php b/core/modules/system/tests/src/Kernel/Common/SystemListingTest.php index 102247ee3ccda15f84dd6d9796fff82830bdf594..b48da4ed26a395501c7b0c693cec440f6f7c7dc6 100644 --- a/core/modules/system/tests/src/Kernel/Common/SystemListingTest.php +++ b/core/modules/system/tests/src/Kernel/Common/SystemListingTest.php @@ -62,7 +62,6 @@ public function testFileScanIgnoreDirectory() { // Reset the static to force a re-scan of the directories. $reflected_class = new \ReflectionClass(ExtensionDiscovery::class); $reflected_property = $reflected_class->getProperty('files'); - $reflected_property->setAccessible(TRUE); $reflected_property->setValue($reflected_class, []); $this->setSetting('file_scan_ignore_directories', ['drupal_system_listing_compatible_test']); diff --git a/core/modules/system/tests/src/Kernel/Installer/InstallTranslationFilePatternTest.php b/core/modules/system/tests/src/Kernel/Installer/InstallTranslationFilePatternTest.php index 4ebf17e8723c05eef75ac63619af216d500a8d8d..3942882d40f350bba0907173e1cc08a1fc2765a2 100644 --- a/core/modules/system/tests/src/Kernel/Installer/InstallTranslationFilePatternTest.php +++ b/core/modules/system/tests/src/Kernel/Installer/InstallTranslationFilePatternTest.php @@ -34,7 +34,6 @@ protected function setUp(): void { parent::setUp(); $this->fileTranslation = new FileTranslation('filename', $this->container->get('file_system')); $method = new \ReflectionMethod('\Drupal\Core\StringTranslation\Translator\FileTranslation', 'getTranslationFilesPattern'); - $method->setAccessible(TRUE); $this->filePatternMethod = $method; } diff --git a/core/modules/system/tests/src/Kernel/System/CronQueueTest.php b/core/modules/system/tests/src/Kernel/System/CronQueueTest.php index 4e2f1e7858cb0d20348369cb04872e26eb638fd6..abedf8b4b57af2b55eff8b89f46a132665932b8b 100644 --- a/core/modules/system/tests/src/Kernel/System/CronQueueTest.php +++ b/core/modules/system/tests/src/Kernel/System/CronQueueTest.php @@ -133,7 +133,6 @@ public function testDelayException() { // Ensure that the memory queue expiry time is unchanged after the // DelayedRequeueException has been thrown. $property = (new \ReflectionClass($memory))->getProperty('queue'); - $property->setAccessible(TRUE); $memory_queue_internal = $property->getValue($memory); $this->assertEquals($this->currentTime + $memory_lease_time, reset($memory_queue_internal)->expire); } diff --git a/core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php b/core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php index c530ad7966ad52a80fdb140e0c3796af0be0e116..97c9bfc4c5b84499b7183d89e017642cfc86d053 100644 --- a/core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php +++ b/core/modules/user/tests/src/Unit/Plugin/views/field/UserBulkFormTest.php @@ -94,7 +94,6 @@ public function testConstructor() { $user_bulk_form->init($executable, $display, $options); $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)); } diff --git a/core/modules/views/tests/src/Kernel/ViewExecutableTest.php b/core/modules/views/tests/src/Kernel/ViewExecutableTest.php index 2a5e816ba1acad0c3a965491f70ea3fa81ff2398..f44cdc15a0d0a8848976a5fe0b62a648c6a9e93f 100644 --- a/core/modules/views/tests/src/Kernel/ViewExecutableTest.php +++ b/core/modules/views/tests/src/Kernel/ViewExecutableTest.php @@ -395,7 +395,6 @@ protected function assertViewDestroy(ViewExecutable $view): void { */ protected function getProtectedProperty($instance, $property) { $reflection = new \ReflectionProperty($instance, $property); - $reflection->setAccessible(TRUE); return $reflection->getValue($instance); } diff --git a/core/modules/views/tests/src/Kernel/ViewStorageTest.php b/core/modules/views/tests/src/Kernel/ViewStorageTest.php index dfb6787642eaf05c3b7579e90bd0b41348f7c9a7..ce2726a60d2d23a2050781ee42a2cadc16b86ec3 100644 --- a/core/modules/views/tests/src/Kernel/ViewStorageTest.php +++ b/core/modules/views/tests/src/Kernel/ViewStorageTest.php @@ -237,7 +237,6 @@ protected function displayMethodTests() { // it. $view = $this->controller->create([]); $ref_generate_display_id = new \ReflectionMethod($view, 'generateDisplayId'); - $ref_generate_display_id->setAccessible(TRUE); $this->assertEquals('default', $ref_generate_display_id->invoke($view, 'default'), 'The plugin ID for default is always default.'); $this->assertEquals('feed_1', $ref_generate_display_id->invoke($view, 'feed'), 'The generated ID for the first instance of a plugin type should have an suffix of _1.'); $view->addDisplay('feed', 'feed title'); diff --git a/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php b/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php index 1d07ee94f38c6aabaf758c83eb68f266638cf03a..b20448c26cfc1c0e000c5f56d8c0ac822ce63d0e 100644 --- a/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php +++ b/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php @@ -428,7 +428,6 @@ protected function setupValidMocks($use_ajax = self::USE_AJAX) { */ protected function getCommands(ViewAjaxResponse $response) { $reflection_property = new \ReflectionProperty('Drupal\views\Ajax\ViewAjaxResponse', 'commands'); - $reflection_property->setAccessible(TRUE); $commands = $reflection_property->getValue($response); return $commands; } diff --git a/core/modules/views/tests/src/Unit/ViewsHandlerManagerTest.php b/core/modules/views/tests/src/Unit/ViewsHandlerManagerTest.php index d3c803b3e6f6c7ab5e0a04c4c60163d4f21dcc36..70aeecb98e3fa5f6cec22cbd867eee557b76d363 100644 --- a/core/modules/views/tests/src/Unit/ViewsHandlerManagerTest.php +++ b/core/modules/views/tests/src/Unit/ViewsHandlerManagerTest.php @@ -59,7 +59,6 @@ protected function setupMockedFactory() { $reflection = new \ReflectionClass($this->handlerManager); $property = $reflection->getProperty('factory'); - $property->setAccessible(TRUE); $property->setValue($this->handlerManager, $this->factory); } diff --git a/core/tests/Drupal/BuildTests/Framework/Tests/BuildTestTest.php b/core/tests/Drupal/BuildTests/Framework/Tests/BuildTestTest.php index 29388641174e757a293572a373080ccb65c55acc..5945dfb14cdbebd8604dc60e873850998760e23b 100644 --- a/core/tests/Drupal/BuildTests/Framework/Tests/BuildTestTest.php +++ b/core/tests/Drupal/BuildTests/Framework/Tests/BuildTestTest.php @@ -163,7 +163,6 @@ public function testStandUpServer() { // Get the process object for the server. $ref_process = new \ReflectionProperty(parent::class, 'serverProcess'); - $ref_process->setAccessible(TRUE); $first_process = $ref_process->getValue($this); // Standing up the server again should not change the server process. diff --git a/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificConnectionUnitTestBase.php b/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificConnectionUnitTestBase.php index cc50302612025a14a528b09d96bf855d924db7d3..488979176179c534ab2485f059f22e5bac0fc7e1 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificConnectionUnitTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificConnectionUnitTestBase.php @@ -179,7 +179,6 @@ public function testOpenSelectQueryClose(): void { public function testConnectionOpen() { $reflection = new \ReflectionObject($this->connection); $connection_property = $reflection->getProperty('connection'); - $connection_property->setAccessible(TRUE); $error_mode = $connection_property->getValue($this->connection) ->getAttribute(\PDO::ATTR_ERRMODE); // Ensure the default error mode is set to exception. @@ -192,7 +191,6 @@ public function testConnectionOpen() { $reflection = new \ReflectionObject($test_connection); $connection_property = $reflection->getProperty('connection'); - $connection_property->setAccessible(TRUE); $error_mode = $connection_property->getValue($test_connection) ->getAttribute(\PDO::ATTR_ERRMODE); // Ensure PDO connection options can be overridden. diff --git a/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificSchemaTestBase.php b/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificSchemaTestBase.php index 342ed0ec3a7b9de6a08eca5291e30a1a2ae0c53f..96933c2333494818f10903697a38d7413413a36b 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificSchemaTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificSchemaTestBase.php @@ -254,7 +254,6 @@ public function testSchema(): void { // Test the primary key columns. $method = new \ReflectionMethod(get_class($this->schema), 'findPrimaryKeyColumns'); - $method->setAccessible(TRUE); $this->assertSame(['test_serial'], $method->invoke($this->schema, 'test_table')); $this->assertTrue($this->tryInsert(), 'Insert with a serial succeeded.'); @@ -579,7 +578,6 @@ protected function assertFieldCharacteristics(string $table_name, string $field_ */ public function testSchemaChangePrimaryKey(array $initial_primary_key, array $renamed_primary_key): void { $find_primary_key_columns = new \ReflectionMethod(get_class($this->schema), 'findPrimaryKeyColumns'); - $find_primary_key_columns->setAccessible(TRUE); // Test making the field the primary key of the table upon creation. $table_name = 'test_table'; @@ -892,7 +890,6 @@ protected function assertFieldChange(array $old_spec, array $new_spec, $test_dat */ public function testFindPrimaryKeyColumns(): void { $method = new \ReflectionMethod(get_class($this->schema), 'findPrimaryKeyColumns'); - $method->setAccessible(TRUE); // Test with single column primary key. $this->schema->createTable('table_with_pk_0', [ diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityCloneTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityCloneTest.php index 252fdf76e304222ba47fe5f176c204e872e7bf35..d1a0520b27125b3e16cdb31d74fb76a2368e03fb 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityCloneTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityCloneTest.php @@ -302,7 +302,6 @@ public function testEntityPropertiesModifications() { foreach ($properties as $property) { // Modify each entity property on the clone and assert that the change is // not propagated to the original entity. - $property->setAccessible(TRUE); $property->setValue($entity, 'default-value'); $property->setValue($translation, 'default-value'); $property->setValue($clone, 'test-entity-cloning'); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionTranslationTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionTranslationTest.php index c67bb05482f28e9c62cd3163eb4659ade848cd42..d3a5a5ccf8a022becf2b652764a2dd0404547619 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionTranslationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionTranslationTest.php @@ -202,7 +202,6 @@ public function testIsAnyStoredRevisionTranslated() { /** @var \Drupal\Core\Entity\ContentEntityStorageInterface $storage */ $storage = $this->entityTypeManager->getStorage('entity_test_mul'); $method = new \ReflectionMethod(get_class($storage), 'isAnyStoredRevisionTranslated'); - $method->setAccessible(TRUE); // Check that a non-revisionable new entity is handled correctly. $entity = EntityTestMul::create(); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php index 4978abe42e2473b481d23c98f448ce8d8dda2b57..aa7392067ffe98b154fca4dd28da8fed1073dd28 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php @@ -258,7 +258,6 @@ protected function findPrimaryKeys(EntityTypeInterface $entity_type) { $schema = $this->database->schema(); $find_primary_key_columns = new \ReflectionMethod(get_class($schema), 'findPrimaryKeyColumns'); - $find_primary_key_columns->setAccessible(TRUE); // Build up a map of primary keys depending on the entity type // configuration. If the field that is being removed is part of a table's diff --git a/core/tests/Drupal/KernelTests/Core/Installer/InstallerRedirectTraitTest.php b/core/tests/Drupal/KernelTests/Core/Installer/InstallerRedirectTraitTest.php index 44ebd36187166b1e9275236eb1102b0e1755f1c8..42ba0a82d0548b3c770c789c618ae216829ba3d8 100644 --- a/core/tests/Drupal/KernelTests/Core/Installer/InstallerRedirectTraitTest.php +++ b/core/tests/Drupal/KernelTests/Core/Installer/InstallerRedirectTraitTest.php @@ -83,12 +83,10 @@ public function testShouldRedirectToInstaller($expected, $exception, $connection // Un-protect the method using reflection. $method_ref = new \ReflectionMethod($trait, 'shouldRedirectToInstaller'); - $method_ref->setAccessible(TRUE); // Mock the database connection info. $db = $this->getMockForAbstractClass(Database::class); $property_ref = new \ReflectionProperty($db, 'databaseInfo'); - $property_ref->setAccessible(TRUE); $property_ref->setValue($db, ['default' => $connection_info]); if ($connection) { diff --git a/core/tests/Drupal/KernelTests/Core/Test/EnvironmentCleanerTest.php b/core/tests/Drupal/KernelTests/Core/Test/EnvironmentCleanerTest.php index 70e31657387d15614f7adbb70fb16b71e59ffe85..2639ba4f06c69b07f2e5a7b297b2197423fc2558 100644 --- a/core/tests/Drupal/KernelTests/Core/Test/EnvironmentCleanerTest.php +++ b/core/tests/Drupal/KernelTests/Core/Test/EnvironmentCleanerTest.php @@ -42,7 +42,6 @@ public function testDoCleanTemporaryDirectories() { ); $do_cleanup_ref = new \ReflectionMethod($cleaner, 'doCleanTemporaryDirectories'); - $do_cleanup_ref->setAccessible(TRUE); $this->assertFileExists(vfsStream::url('cleanup_test/sites/simpletest/delete_dir/delete.me')); $this->assertFileExists(vfsStream::url('cleanup_test/sites/simpletest/delete_me.too')); diff --git a/core/tests/Drupal/KernelTests/Core/Theme/TwigEnvironmentTest.php b/core/tests/Drupal/KernelTests/Core/Theme/TwigEnvironmentTest.php index 6257dc07cfa7958590d65f3b506451126ed2e84a..74d6c47242566e55a29ab1475481492e50abd486 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/TwigEnvironmentTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/TwigEnvironmentTest.php @@ -223,7 +223,6 @@ public function testTemplateInvalidation() { // on a real site where you reload the page. $reflection = new \ReflectionClass(Environment::class); $property_reflection = $reflection->getProperty('templateClassPrefix'); - $property_reflection->setAccessible(TRUE); $property_reflection->setValue($environment, 'otherPrefix'); $output = $environment->load(basename($tempfile))->render(); diff --git a/core/tests/Drupal/Tests/Component/Annotation/AnnotatedClassDiscoveryCachedTest.php b/core/tests/Drupal/Tests/Component/Annotation/AnnotatedClassDiscoveryCachedTest.php index 17c4202c6fc51505433846d7246d5e1d286f03a6..899295cbeb3eea37f3476a6bd193e5e63e8dbf8f 100644 --- a/core/tests/Drupal/Tests/Component/Annotation/AnnotatedClassDiscoveryCachedTest.php +++ b/core/tests/Drupal/Tests/Component/Annotation/AnnotatedClassDiscoveryCachedTest.php @@ -46,7 +46,6 @@ public function testGetDefinitions() { // Gain access to the file cache so we can change it. $ref_file_cache = new \ReflectionProperty($discovery, 'fileCache'); - $ref_file_cache->setAccessible(TRUE); /** @var \Drupal\Component\FileCache\FileCacheInterface $file_cache */ $file_cache = $ref_file_cache->getValue($discovery); // The file cache is keyed by the file path, and we'll add some known diff --git a/core/tests/Drupal/Tests/Component/Annotation/AnnotatedClassDiscoveryTest.php b/core/tests/Drupal/Tests/Component/Annotation/AnnotatedClassDiscoveryTest.php index 077d51c295fbcebc9d5ed1ed0f0333678786accb..ceada7a5a969a647eccecb09789ee6767689804c 100644 --- a/core/tests/Drupal/Tests/Component/Annotation/AnnotatedClassDiscoveryTest.php +++ b/core/tests/Drupal/Tests/Component/Annotation/AnnotatedClassDiscoveryTest.php @@ -33,8 +33,6 @@ public function testGetPluginNamespaces() { $discovery = new AnnotatedClassDiscovery(['com/example' => [__DIR__]]); $reflection = new \ReflectionMethod($discovery, 'getPluginNamespaces'); - $reflection->setAccessible(TRUE); - $result = $reflection->invoke($discovery); $this->assertEquals(['com/example' => [__DIR__]], $result); } diff --git a/core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php b/core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php index f9656cfc5e00c383c30f1bedb9fd6c0ed649e2c8..5a653b49005a361862c27580c567925f541c1721 100644 --- a/core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php +++ b/core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php @@ -38,7 +38,6 @@ public function testGetContextValue($expected, $context_value, $is_required, $da if ($context_value) { // Set visibility of contextValue. $ref_context_value = new \ReflectionProperty($mock_context, 'contextValue'); - $ref_context_value->setAccessible(TRUE); // Set contextValue to a testable state. $ref_context_value->setValue($mock_context, $context_value); // Exercise getContextValue(). diff --git a/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryCachedTraitTest.php b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryCachedTraitTest.php index 2ed15bbfe29bb14d8014f129cef79224ec7485e9..7895ecddcf353936b5476afcaede0565f161c567 100644 --- a/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryCachedTraitTest.php +++ b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryCachedTraitTest.php @@ -36,7 +36,6 @@ public function testGetDefinition($expected, $cached_definitions, $get_definitio // Mock a DiscoveryCachedTrait. $trait = $this->getMockForTrait('Drupal\Component\Plugin\Discovery\DiscoveryCachedTrait'); $reflection_definitions = new \ReflectionProperty($trait, 'definitions'); - $reflection_definitions->setAccessible(TRUE); // getDefinition() needs the ::$definitions property to be set in one of two // ways: 1) As existing cached data, or 2) as a side-effect of calling // getDefinitions(). diff --git a/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php index 4668eda810a1fb15eb59bcb327c33a50134f0c54..d3a07965520464ca78021eaea4c4da83b25a1191 100644 --- a/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php +++ b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php @@ -35,7 +35,6 @@ public function testDoGetDefinition($expected, $definitions, $plugin_id) { $trait = $this->getMockForTrait('Drupal\Component\Plugin\Discovery\DiscoveryTrait'); // Un-protect the method using reflection. $method_ref = new \ReflectionMethod($trait, 'doGetDefinition'); - $method_ref->setAccessible(TRUE); // Call doGetDefinition, with $exception_on_invalid always FALSE. $this->assertSame( $expected, @@ -67,7 +66,6 @@ public function testDoGetDefinitionException($expected, $definitions, $plugin_id $trait = $this->getMockForTrait('Drupal\Component\Plugin\Discovery\DiscoveryTrait'); // Un-protect the method using reflection. $method_ref = new \ReflectionMethod($trait, 'doGetDefinition'); - $method_ref->setAccessible(TRUE); // Call doGetDefinition, with $exception_on_invalid always TRUE. $this->expectException(PluginNotFoundException::class); $method_ref->invoke($trait, $definitions, $plugin_id, TRUE); diff --git a/core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php b/core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php index 3f4f7124441a95a738232bf0351ecf9a94324ef3..518eaddc1d3b95590090f431d4d13c4c89a5b85d 100644 --- a/core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php +++ b/core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php @@ -67,7 +67,6 @@ public function testGetDefinition($expected, $has_register_definitions, $excepti // Set up the ::$registerDefinitions property. $ref_register_definitions = new \ReflectionProperty($mock_decorator, 'registerDefinitions'); - $ref_register_definitions->setAccessible(TRUE); if ($has_register_definitions) { // Set the callback object on the mocked decorator. $ref_register_definitions->setValue( @@ -82,7 +81,6 @@ public function testGetDefinition($expected, $has_register_definitions, $excepti // Set up ::$definitions to an empty array. $ref_definitions = new \ReflectionProperty($mock_decorator, 'definitions'); - $ref_definitions->setAccessible(TRUE); $ref_definitions->setValue($mock_decorator, []); // Mock a decorated object. @@ -96,7 +94,6 @@ public function testGetDefinition($expected, $has_register_definitions, $excepti // Set up ::$decorated to our mocked decorated object. $ref_decorated = new \ReflectionProperty($mock_decorator, 'decorated'); - $ref_decorated->setAccessible(TRUE); $ref_decorated->setValue($mock_decorator, $mock_decorated); if ($exception_on_invalid) { @@ -137,7 +134,6 @@ public function testGetDefinitions($has_register_definitions, $definitions) { // Set up the ::$registerDefinitions property. $ref_register_definitions = new \ReflectionProperty($mock_decorator, 'registerDefinitions'); - $ref_register_definitions->setAccessible(TRUE); if ($has_register_definitions) { // Set the callback object on the mocked decorator. $ref_register_definitions->setValue( @@ -152,7 +148,6 @@ public function testGetDefinitions($has_register_definitions, $definitions) { // Set up ::$definitions to an empty array. $ref_definitions = new \ReflectionProperty($mock_decorator, 'definitions'); - $ref_definitions->setAccessible(TRUE); $ref_definitions->setValue($mock_decorator, []); // Mock a decorated object. @@ -166,7 +161,6 @@ public function testGetDefinitions($has_register_definitions, $definitions) { // Set up ::$decorated to our mocked decorated object. $ref_decorated = new \ReflectionProperty($mock_decorator, 'decorated'); - $ref_decorated->setAccessible(TRUE); $ref_decorated->setValue($mock_decorator, $mock_decorated); // Exercise getDefinitions(). It calls parent::getDefinitions() but in this @@ -216,7 +210,6 @@ function () { ->getMock(); // Poke the decorated object into our decorator. $ref_decorated = new \ReflectionProperty($mock_decorator, 'decorated'); - $ref_decorated->setAccessible(TRUE); $ref_decorated->setValue($mock_decorator, $mock_decorated); // Exercise __call. diff --git a/core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php b/core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php index 45d27708fa924dfbda60db63636ea6813b6f0233..0f59ca828d9339701334d2adda692a9e7af10f97 100644 --- a/core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php +++ b/core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php @@ -115,7 +115,6 @@ public function testGetInstanceArguments($expected, $reflector_name, $plugin_id, ->disableOriginalConstructor() ->getMock(); $get_instance_arguments_ref = new \ReflectionMethod($reflection_factory, 'getInstanceArguments'); - $get_instance_arguments_ref->setAccessible(TRUE); // Special case for plugin class without a constructor. // getInstanceArguments() throws an exception if there's no constructor. diff --git a/core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php b/core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php index 36b60b68a55398642a6be4fc7f57c141d8d90a2f..11e0a403b6271bca2de6ed44b8f5acf9c2f03467 100644 --- a/core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php +++ b/core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php @@ -56,7 +56,6 @@ public function testCreateInstance() { // PluginManagerBase::createInstance() looks for a factory object and then // calls createInstance() on it. So we have to mock a factory object. $factory_ref = new \ReflectionProperty($manager, 'factory'); - $factory_ref->setAccessible(TRUE); $factory_ref->setValue($manager, $this->getMockFactoryInterface(1)); // Finally the test. @@ -77,7 +76,6 @@ public function testCreateInstanceFallback() { $manager = new StubFallbackPluginManager(); // Put our stubbed factory on the base object. $factory_ref = new \ReflectionProperty($manager, 'factory'); - $factory_ref->setAccessible(TRUE); // Set up the configuration array. $configuration_array = ['config' => 'something']; diff --git a/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php b/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php index 4dc8eea2137c4edb847a6f6e11570e21587abba7..b589e7697140765e070cdc1eddb48d70584e1473 100644 --- a/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php +++ b/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php @@ -27,7 +27,6 @@ protected function setUp(): void { parent::setUp(); $property = new \ReflectionProperty('Drupal\Component\Utility\Html', 'seenIdsInit'); - $property->setAccessible(TRUE); $property->setValue(NULL); } diff --git a/core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/ConfigTest.php b/core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/ConfigTest.php index 47eedd822c6eaf4365129d37c8a997c054e5aa14..192afb575ed5a27c39cdb49726814137179b47d0 100644 --- a/core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/ConfigTest.php +++ b/core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/ConfigTest.php @@ -46,10 +46,8 @@ public function testNoRootMergeConfig() { $config = new Config($root); $ref_default = new \ReflectionProperty($config, 'defaultConfig'); - $ref_default->setAccessible(TRUE); $ref_plugin_config = new \ReflectionMethod($config, 'getAllCleanupPaths'); - $ref_plugin_config->setAccessible(TRUE); $this->assertEquals( $ref_default->getValue($config), $ref_plugin_config->invoke($config) @@ -76,7 +74,6 @@ public function testRootMergeConfig() { $config = new Config($root); $ref_plugin_config = new \ReflectionMethod($config, 'getAllCleanupPaths'); - $ref_plugin_config->setAccessible(TRUE); $plugin_config = $ref_plugin_config->invoke($config); @@ -103,11 +100,9 @@ public function testMixedCaseConfigCleanupPackages() { $config = new Config($root); $ref_plugin_config = new \ReflectionMethod($config, 'getAllCleanupPaths'); - $ref_plugin_config->setAccessible(TRUE); // Put some mixed-case in the defaults. $ref_default = new \ReflectionProperty($config, 'defaultConfig'); - $ref_default->setAccessible(TRUE); $ref_default->setValue($config, [ 'BeHatted/Mank' => ['tests'], 'SymFunic/HTTPFoundational' => ['src'], diff --git a/core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/VendorHardeningPluginTest.php b/core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/VendorHardeningPluginTest.php index 81b286b986dee2a1c0d921cb682ec3d58006d2b6..30cc3bf10ef9b95aacbbad1d12dab4ebea4df2b4 100644 --- a/core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/VendorHardeningPluginTest.php +++ b/core/tests/Drupal/Tests/Composer/Plugin/VendorHardening/VendorHardeningPluginTest.php @@ -58,12 +58,10 @@ public function testCleanPackage() { ->willReturn(vfsStream::url('vendor/drupal/package')); $ref_config = new \ReflectionProperty($plugin, 'config'); - $ref_config->setAccessible(TRUE); $ref_config->setValue($plugin, $config); $io = $this->prophesize(IOInterface::class); $ref_io = new \ReflectionProperty($plugin, 'io'); - $ref_io->setAccessible(TRUE); $ref_io->setValue($plugin, $io->reveal()); $this->assertFileExists(vfsStream::url('vendor/drupal/package/tests/SomeTest.php')); @@ -89,7 +87,6 @@ public function testCleanPathsForPackage() { $io = $this->prophesize(IOInterface::class); $ref_io = new \ReflectionProperty($plugin, 'io'); - $ref_io->setAccessible(TRUE); $ref_io->setValue($plugin, $io->reveal()); $this->assertFileExists(vfsStream::url('vendor/drupal/package/tests/SomeTest.php')); @@ -98,7 +95,6 @@ public function testCleanPathsForPackage() { $package->getName()->willReturn('drupal/package'); $ref_clean = new \ReflectionMethod($plugin, 'cleanPathsForPackage'); - $ref_clean->setAccessible(TRUE); $ref_clean->invokeArgs($plugin, [$package->reveal(), ['tests']]); $this->assertFileDoesNotExist(vfsStream::url('vendor/drupal/package/tests')); @@ -133,11 +129,9 @@ public function testCleanAllPackages() { $io = $this->prophesize(IOInterface::class); $ref_io = new \ReflectionProperty($plugin, 'io'); - $ref_io->setAccessible(TRUE); $ref_io->setValue($plugin, $io->reveal()); $ref_config = new \ReflectionProperty($plugin, 'config'); - $ref_config->setAccessible(TRUE); $ref_config->setValue($plugin, $config); $this->assertFileExists(vfsStream::url('vendor/drupal/package/tests/SomeTest.php')); @@ -231,7 +225,6 @@ public function testFindBinOverlap($expected, $binaries, $clean_paths) { ->getMock(); $ref_find_bin_overlap = new \ReflectionMethod($plugin, 'findBinOverlap'); - $ref_find_bin_overlap->setAccessible(TRUE); $this->assertSame($expected, $ref_find_bin_overlap->invokeArgs($plugin, [$binaries, $clean_paths])); } diff --git a/core/tests/Drupal/Tests/ComposerIntegrationTest.php b/core/tests/Drupal/Tests/ComposerIntegrationTest.php index ecf7c27a505d61ae0f2e254e88bbe928f358e429..854b495a0f95e4959707e02286436b26b0746c68 100644 --- a/core/tests/Drupal/Tests/ComposerIntegrationTest.php +++ b/core/tests/Drupal/Tests/ComposerIntegrationTest.php @@ -260,7 +260,6 @@ public function testVendorCleanup(): void { } $reflection = new \ReflectionProperty(Config::class, 'defaultConfig'); - $reflection->setAccessible(TRUE); $config = $reflection->getValue(); foreach (array_keys($config) as $package) { $this->assertContains(strtolower($package), $packages); diff --git a/core/tests/Drupal/Tests/Core/Block/BlockManagerTest.php b/core/tests/Drupal/Tests/Core/Block/BlockManagerTest.php index 8d4d191d009c29911cead3d8dce8149832807a5b..5ce1b499fc3cd389ed57625f89cc0e69a1aa8146 100644 --- a/core/tests/Drupal/Tests/Core/Block/BlockManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Block/BlockManagerTest.php @@ -79,7 +79,6 @@ protected function setUp(): void { ]); // Force the discovery object onto the block manager. $property = new \ReflectionProperty(BlockManager::class, 'discovery'); - $property->setAccessible(TRUE); $property->setValue($this->blockManager, $discovery->reveal()); } diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php index 8c97657b934f7c4962fa5156cfc0d186f843f9bf..cc58ccd5e903a68c985833337101011b58d6b40e 100644 --- a/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php @@ -224,7 +224,6 @@ public function testPreSaveDuringSync() { */ public function testAddDependency() { $method = new \ReflectionMethod('\Drupal\Core\Config\Entity\ConfigEntityBase', 'addDependency'); - $method->setAccessible(TRUE); $method->invoke($this->entity, 'module', $this->provider); $method->invoke($this->entity, 'module', 'core'); $method->invoke($this->entity, 'module', 'node'); diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayBaseTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayBaseTest.php index 8dd7e77dc76bd8eb5153474c2ea2ef7cc51f0436..ca315415fc3bf785d285d6f6b8dcd5ee37e55097 100644 --- a/core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayBaseTest.php +++ b/core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayBaseTest.php @@ -17,7 +17,6 @@ class EntityDisplayBaseTest extends UnitTestCase { public function testGetTargetEntityTypeId() { $mock = $this->getMockForAbstractClass('\Drupal\Core\Entity\EntityDisplayBase', [], '', FALSE); $reflection = new \ReflectionProperty($mock, 'targetEntityType'); - $reflection->setAccessible(TRUE); $reflection->setValue($mock, 'test'); $this->assertEquals('test', $mock->getTargetEntityTypeId()); } @@ -28,7 +27,6 @@ public function testGetTargetEntityTypeId() { public function testGetMode() { $mock = $this->getMockForAbstractClass('\Drupal\Core\Entity\EntityDisplayBase', [], '', FALSE); $reflection = new \ReflectionProperty($mock, 'mode'); - $reflection->setAccessible(TRUE); $reflection->setValue($mock, 'test'); $this->assertEquals('test', $mock->getMode()); } @@ -39,7 +37,6 @@ public function testGetMode() { public function testGetOriginalMode() { $mock = $this->getMockForAbstractClass('\Drupal\Core\Entity\EntityDisplayBase', [], '', FALSE); $reflection = new \ReflectionProperty($mock, 'originalMode'); - $reflection->setAccessible(TRUE); $reflection->setValue($mock, 'test'); $this->assertEquals('test', $mock->getOriginalMode()); } @@ -50,7 +47,6 @@ public function testGetOriginalMode() { public function testGetTargetBundle() { $mock = $this->getMockForAbstractClass('\Drupal\Core\Entity\EntityDisplayBase', [], '', FALSE); $reflection = new \ReflectionProperty($mock, 'bundle'); - $reflection->setAccessible(TRUE); $reflection->setValue($mock, 'test'); $this->assertEquals('test', $mock->getTargetBundle()); } @@ -61,7 +57,6 @@ public function testGetTargetBundle() { public function testSetTargetBundle() { $mock = $this->getMockForAbstractClass('\Drupal\Core\Entity\EntityDisplayBase', [], '', FALSE); $reflection = new \ReflectionProperty($mock, 'bundle'); - $reflection->setAccessible(TRUE); $mock->setTargetBundle('test'); $this->assertEquals('test', $reflection->getValue($mock)); } diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php index e7ca0e53f50f6c1392b16cb18ed39692bc82a3fe..c3a9c10b836a45675d8fe1778f7ea7cc3dcd9110 100644 --- a/core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Config/Entity/EntityDisplayModeBaseUnitTest.php @@ -115,7 +115,6 @@ public function testSetTargetType() { // Gain access to the protected property. $property = new \ReflectionProperty($mock, 'targetEntityType'); - $property->setAccessible(TRUE); // Set the property to a known state. $property->setValue($mock, $bad_target); @@ -142,7 +141,6 @@ public function testGetTargetType() { // Gain access to the protected property. $property = new \ReflectionProperty($mock, 'targetEntityType'); - $property->setAccessible(TRUE); // Set the property to a known state. $property->setValue($mock, $target); diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/Query/QueryFactoryTest.php b/core/tests/Drupal/Tests/Core/Config/Entity/Query/QueryFactoryTest.php index 97c6a34c80685f31198a5a56f34bfd71219b9123..e54d3c6959e4ea0f50745d770bfb38c3a2120335 100644 --- a/core/tests/Drupal/Tests/Core/Config/Entity/Query/QueryFactoryTest.php +++ b/core/tests/Drupal/Tests/Core/Config/Entity/Query/QueryFactoryTest.php @@ -25,7 +25,6 @@ public function testGetKeys(array $expected, $key, Config $config) { $config_entity_type = $this->createMock('Drupal\Core\Config\Entity\ConfigEntityTypeInterface'); $query_factory = new QueryFactory($config_factory, $key_value_factory, $config_manager); $method = new \ReflectionMethod($query_factory, 'getKeys'); - $method->setAccessible(TRUE); $actual = $method->invoke($query_factory, $config, $key, 'get', $config_entity_type); $this->assertEquals($expected, $actual); @@ -110,7 +109,6 @@ public function testGetKeysWildCardEnd() { $query_factory = new QueryFactory($config_factory, $key_value_factory, $config_manager); $method = new \ReflectionMethod($query_factory, 'getKeys'); - $method->setAccessible(TRUE); $this->expectException(\LogicException::class); $this->expectExceptionMessage('test_config_entity_type lookup key test.* ends with a wildcard this can not be used as a lookup'); $method->invoke($query_factory, $this->getConfigObject('test'), 'test.*', 'get', $config_entity_type); diff --git a/core/tests/Drupal/Tests/Core/Config/StorageCopyTraitTest.php b/core/tests/Drupal/Tests/Core/Config/StorageCopyTraitTest.php index 3b0f780779608bd1f34751e278d28e6a84d52b34..d3710b278df4141d2407d5e77ce8cdb3ad529591 100644 --- a/core/tests/Drupal/Tests/Core/Config/StorageCopyTraitTest.php +++ b/core/tests/Drupal/Tests/Core/Config/StorageCopyTraitTest.php @@ -87,7 +87,6 @@ public function providerTestReplaceStorageContents() { protected static function toArray(MemoryStorage $storage) { $reflection = new \ReflectionObject($storage); $property = $reflection->getProperty('config'); - $property->setAccessible(TRUE); return $property->getValue($storage)->getArrayCopy(); } diff --git a/core/tests/Drupal/Tests/Core/Controller/ControllerBaseTest.php b/core/tests/Drupal/Tests/Core/Controller/ControllerBaseTest.php index 59b0bbae5b3ee95a36f782fb0f7251fcd7ae3d69..5044789637c59b143309ef05c3524051542dc41d 100644 --- a/core/tests/Drupal/Tests/Core/Controller/ControllerBaseTest.php +++ b/core/tests/Drupal/Tests/Core/Controller/ControllerBaseTest.php @@ -48,7 +48,6 @@ public function testGetConfig() { \Drupal::setContainer($container); $config_method = new \ReflectionMethod('Drupal\Core\Controller\ControllerBase', 'config'); - $config_method->setAccessible(TRUE); // Call config twice to ensure that the container is just called once. $config = $config_method->invoke($this->controllerBase, 'config_name'); diff --git a/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php b/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php index 45e8f49e4c51bd9b1b6f6c44d3dea787225e03e7..de09bbfed2141898754a91cae32a8fb2a6f371cf 100644 --- a/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php +++ b/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php @@ -55,7 +55,6 @@ public function testPrefixRoundTrip($expected, $prefix_info) { // setPrefix() is protected, so we make it accessible with reflection. $reflection = new \ReflectionClass('Drupal\Tests\Core\Database\Stub\StubConnection'); $set_prefix = $reflection->getMethod('setPrefix'); - $set_prefix->setAccessible(TRUE); // Set the prefix data. $set_prefix->invokeArgs($connection, [$prefix_info]); @@ -423,7 +422,6 @@ public function testFilterComments($expected, $comment) { // filterComment() is protected, so we make it accessible with reflection. $reflection = new \ReflectionClass('Drupal\Tests\Core\Database\Stub\StubConnection'); $filter_comment = $reflection->getMethod('filterComment'); - $filter_comment->setAccessible(TRUE); $this->assertEquals( $expected, @@ -599,7 +597,6 @@ public function testQueryTrim($expected, $query, $options) { $connection = new StubConnection($mock_pdo, []); $preprocess_method = new \ReflectionMethod($connection, 'preprocessStatement'); - $preprocess_method->setAccessible(TRUE); $this->assertSame($expected, $preprocess_method->invoke($connection, $query, $options)); } @@ -663,7 +660,7 @@ public function testFindCallerFromDebugBacktrace() { $result = $connection->findCallerFromDebugBacktrace(); $this->assertSame([ 'file' => __FILE__, - 'line' => 663, + 'line' => 660, 'function' => 'testFindCallerFromDebugBacktrace', 'class' => 'Drupal\Tests\Core\Database\ConnectionTest', 'type' => '->', diff --git a/core/tests/Drupal/Tests/Core/Database/SchemaIntrospectionTestTrait.php b/core/tests/Drupal/Tests/Core/Database/SchemaIntrospectionTestTrait.php index 3591adde959f21bfaa6a53bfb8e700c985e45c19..5e89de4ca572bc84b14af95a6fa0de75dc59cdcd 100644 --- a/core/tests/Drupal/Tests/Core/Database/SchemaIntrospectionTestTrait.php +++ b/core/tests/Drupal/Tests/Core/Database/SchemaIntrospectionTestTrait.php @@ -65,7 +65,6 @@ protected function getIndexColumnNames($table_name, $index_type) { $schema = \Drupal::database()->schema(); $introspect_index_schema = new \ReflectionMethod(get_class($schema), 'introspectIndexSchema'); - $introspect_index_schema->setAccessible(TRUE); $index_schema = $introspect_index_schema->invoke($schema, $table_name); // Filter the indexes by type. diff --git a/core/tests/Drupal/Tests/Core/DrupalKernel/DiscoverServiceProvidersTest.php b/core/tests/Drupal/Tests/Core/DrupalKernel/DiscoverServiceProvidersTest.php index 08ab3eb906f75975c2979aa03d52acc039fecc81..5a6e6c924ba5d1bea7240c359eb5cd6e372285fd 100644 --- a/core/tests/Drupal/Tests/Core/DrupalKernel/DiscoverServiceProvidersTest.php +++ b/core/tests/Drupal/Tests/Core/DrupalKernel/DiscoverServiceProvidersTest.php @@ -29,7 +29,6 @@ public function testDiscoverServiceCustom() { $kernel->discoverServiceProviders(); $reflected_yamls = (new \ReflectionObject($kernel))->getProperty('serviceYamls'); - $reflected_yamls->setAccessible(TRUE); $expect = [ 'app' => [ @@ -51,7 +50,6 @@ public function testDiscoverServiceNoContainerYamls() { $kernel->discoverServiceProviders(); $reflected_yamls = (new \ReflectionObject($kernel))->getProperty('serviceYamls'); - $reflected_yamls->setAccessible(TRUE); $expect = [ 'app' => [ diff --git a/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php b/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php index 16b5b0d4757a6ccbda183dae05542b1f5c43ad70..4efda0785bfc33bb289b8fc1e7839cdf91d9d533 100644 --- a/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php +++ b/core/tests/Drupal/Tests/Core/DrupalKernel/DrupalKernelTest.php @@ -38,7 +38,6 @@ public function testTrustedHosts($host, $server_name, $message, $expected = FALS $request->server->set('SERVER_NAME', $server_name); $method = new \ReflectionMethod('Drupal\Core\DrupalKernel', 'setupTrustedHosts'); - $method->setAccessible(TRUE); $valid_host = $method->invoke(NULL, $request, $trusted_host_patterns); $this->assertSame($expected, $valid_host, $message); diff --git a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php index acc3bbea081f9f5681ab049c832c17ad764a3d59..5da25e326fb61ea95d26528083c2908100d7e304 100644 --- a/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/ContentEntityBaseUnitTest.php @@ -573,12 +573,10 @@ public function testGet($expected, $field_name, $active_langcode, $fields) { // Poke in activeLangcode. $ref_langcode = new \ReflectionProperty($mock_base, 'activeLangcode'); - $ref_langcode->setAccessible(TRUE); $ref_langcode->setValue($mock_base, $active_langcode); // Poke in fields. $ref_fields = new \ReflectionProperty($mock_base, 'fields'); - $ref_fields->setAccessible(TRUE); $ref_fields->setValue($mock_base, $fields); // Exercise get(). diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityStorageBaseTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityStorageBaseTest.php index 065b770a90f5bb7f1127994ddd4d5b07b1868fce..d5bf5f40af7bb24a99362b38b2517bbc570feb86 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityStorageBaseTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityStorageBaseTest.php @@ -160,7 +160,6 @@ public function testLoadMultiple($expected, $load_multiple, $query) { ->willReturn(FALSE); // Add the EntityTypeInterface to the storage object. $ref_entity_type = new \ReflectionProperty($mock_base, 'entityType'); - $ref_entity_type->setAccessible(TRUE); $ref_entity_type->setValue($mock_base, $mock_entity_type); // Set up expectations for postLoad(), which we only call if there are diff --git a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php index 749c33cba220cac39c43846811066f6a4a99232a..64a278faa2b0117cba680b96f16f4d3f42a9c39a 100644 --- a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php @@ -1426,7 +1426,6 @@ public function testCleanIds() { ->willReturnMap([['id', 'id']]); $method = new \ReflectionMethod($this->entityStorage, 'cleanIds'); - $method->setAccessible(TRUE); $this->assertEquals($valid_ids, $method->invoke($this->entityStorage, $valid_ids)); $invalid_ids = [ diff --git a/core/tests/Drupal/Tests/Core/Extension/DependencyTest.php b/core/tests/Drupal/Tests/Core/Extension/DependencyTest.php index ac86b554c37f501efa9f48c72ba6d4403028e88c..865997272a5e74a169c636b996b24f87c32db34f 100644 --- a/core/tests/Drupal/Tests/Core/Extension/DependencyTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/DependencyTest.php @@ -53,13 +53,11 @@ public function testSerialization() { $dependency = new Dependency('paragraphs_demo', 'paragraphs', '>8.x-1.1'); $this->assertTrue($dependency->isCompatible('1.2')); $reflected_constraint = (new \ReflectionObject($dependency))->getProperty('constraint'); - $reflected_constraint->setAccessible(TRUE); $constraint = $reflected_constraint->getValue($dependency); $this->assertInstanceOf(Constraint::class, $constraint); $dependency = unserialize(serialize($dependency)); $reflected_constraint = (new \ReflectionObject($dependency))->getProperty('constraint'); - $reflected_constraint->setAccessible(TRUE); $constraint = $reflected_constraint->getValue($dependency); $this->assertNull($constraint); $this->assertTrue($dependency->isCompatible('1.2')); diff --git a/core/tests/Drupal/Tests/Core/Extension/ExtensionSerializationTest.php b/core/tests/Drupal/Tests/Core/Extension/ExtensionSerializationTest.php index df22664e590afb240163bb20230df9dfe4e7f29b..02c7ec19a1e9efc08e22f185b18c9d86c12fac00 100644 --- a/core/tests/Drupal/Tests/Core/Extension/ExtensionSerializationTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/ExtensionSerializationTest.php @@ -52,7 +52,6 @@ public function testServiceAppRouteUsage() { $extension = new Extension($container->getParameter('app.root'), 'module', 'core/modules/system/system.info.yml', 'system.module'); $extension = unserialize(serialize($extension)); $reflected_root = new \ReflectionProperty($extension, 'root'); - $reflected_root->setAccessible(TRUE); $this->assertEquals('vfs://dummy_app_root', $reflected_root->getValue($extension)); // Change the app root and test serializing and unserializing again. @@ -60,7 +59,6 @@ public function testServiceAppRouteUsage() { \Drupal::setContainer($container); $extension = unserialize(serialize($extension)); $reflected_root = new \ReflectionProperty($extension, 'root'); - $reflected_root->setAccessible(TRUE); $this->assertEquals('vfs://dummy_app_root2', $reflected_root->getValue($extension)); } diff --git a/core/tests/Drupal/Tests/Core/Form/ConfigFormBaseTraitTest.php b/core/tests/Drupal/Tests/Core/Form/ConfigFormBaseTraitTest.php index 7ef81b9f2a15ea7506f4ee3479636ef1ba90a42b..e2c5554216b3f781087b9f1aefd47042cc5d33c5 100644 --- a/core/tests/Drupal/Tests/Core/Form/ConfigFormBaseTraitTest.php +++ b/core/tests/Drupal/Tests/Core/Form/ConfigFormBaseTraitTest.php @@ -28,7 +28,6 @@ public function testConfig() { ->willReturn(['editable.config']); $config_method = new \ReflectionMethod($trait, 'config'); - $config_method->setAccessible(TRUE); // Ensure that configuration that is expected to be mutable is. $result = $config_method->invoke($trait, 'editable.config'); @@ -46,7 +45,6 @@ public function testConfig() { public function testConfigFactoryException() { $trait = $this->getMockForTrait('Drupal\Core\Form\ConfigFormBaseTrait'); $config_method = new \ReflectionMethod($trait, 'config'); - $config_method->setAccessible(TRUE); // There is no config factory available this should result in an exception. $this->expectException(\LogicException::class); @@ -60,7 +58,6 @@ public function testConfigFactoryException() { public function testConfigFactoryExceptionInvalidProperty() { $trait = $this->getMockForTrait('Drupal\Core\Form\ConfigFormBaseTrait'); $config_method = new \ReflectionMethod($trait, 'config'); - $config_method->setAccessible(TRUE); // There is no config factory available this should result in an exception. $this->expectException(\LogicException::class); diff --git a/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php b/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php index ea6ad1899446b176eca625e37adb0fff2d98c7f0..fa6c899e38fed202ed7319d1b39ce3468056e94a 100644 --- a/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php +++ b/core/tests/Drupal/Tests/Core/Form/FormBuilderTest.php @@ -788,7 +788,6 @@ public function providerTestChildAccessInheritance() { */ public function testValueCallableIsSafe($callback, $expected) { $method = new \ReflectionMethod(FormBuilder::class, 'valueCallableIsSafe'); - $method->setAccessible(TRUE); $is_safe = $method->invoke($this->formBuilder, $callback); $this->assertSame($expected, $is_safe); } @@ -839,7 +838,6 @@ public function testInvalidToken($expected, $valid_token, $user_is_authenticated $current_user = $this->prophesize(AccountInterface::class); $current_user->isAuthenticated()->willReturn($user_is_authenticated); $property = new \ReflectionProperty(FormBuilder::class, 'currentUser'); - $property->setAccessible(TRUE); $property->setValue($this->formBuilder, $current_user->reveal()); $expected_form = $form_id(); diff --git a/core/tests/Drupal/Tests/Core/Mail/Plugin/Mail/PhpMailTest.php b/core/tests/Drupal/Tests/Core/Mail/Plugin/Mail/PhpMailTest.php index abc7572b8eb37d745115eb8ae9628dab989d3940..fb4006e6f93a15fbe7849b752a195e8d8a27b12d 100644 --- a/core/tests/Drupal/Tests/Core/Mail/Plugin/Mail/PhpMailTest.php +++ b/core/tests/Drupal/Tests/Core/Mail/Plugin/Mail/PhpMailTest.php @@ -90,7 +90,6 @@ protected function createPhpMailInstance(): PhpMail { $reflection = new \ReflectionClass($mailer); $reflection_property = $reflection->getProperty('request'); - $reflection_property->setAccessible(TRUE); $reflection_property->setValue($mailer, $request); return $mailer; } diff --git a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php index 6a160314f985b6bb529ce4550e89b07abbb75866..55087bb87b409fecc6ef555cb14ae40c3032e893 100644 --- a/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/ContextualLinkManagerTest.php @@ -94,7 +94,6 @@ protected function setUp(): void { ); $property = new \ReflectionProperty('Drupal\Core\Menu\ContextualLinkManager', 'discovery'); - $property->setAccessible(TRUE); $property->setValue($this->contextualLinkManager, $this->pluginDiscovery); } diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php index ec5a48ed79431632013665117c888066dac5aec9..7639ee7ddb360a137bb89b2acc1903b58c8553bb 100644 --- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskIntegrationTestBase.php @@ -63,30 +63,25 @@ protected function getLocalTaskManager($module_dirs, $route_name, $route_params) $argumentResolver = $this->createMock('Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface'); $property = new \ReflectionProperty('Drupal\Core\Menu\LocalTaskManager', 'argumentResolver'); - $property->setAccessible(TRUE); $property->setValue($manager, $argumentResolver); // todo mock a request with a route. $request_stack = new RequestStack(); $property = new \ReflectionProperty('Drupal\Core\Menu\LocalTaskManager', 'requestStack'); - $property->setAccessible(TRUE); $property->setValue($manager, $request_stack); $accessManager = $this->createMock('Drupal\Core\Access\AccessManagerInterface'); $property = new \ReflectionProperty('Drupal\Core\Menu\LocalTaskManager', 'accessManager'); - $property->setAccessible(TRUE); $property->setValue($manager, $accessManager); $route_provider = $this->createMock('Drupal\Core\Routing\RouteProviderInterface'); $property = new \ReflectionProperty('Drupal\Core\Menu\LocalTaskManager', 'routeProvider'); - $property->setAccessible(TRUE); $property->setValue($manager, $route_provider); $module_handler = $this->getMockBuilder('Drupal\Core\Extension\ModuleHandlerInterface') ->disableOriginalConstructor() ->getMock(); $property = new \ReflectionProperty('Drupal\Core\Menu\LocalTaskManager', 'moduleHandler'); - $property->setAccessible(TRUE); $property->setValue($manager, $module_handler); // Set all the modules as being existent. $module_handler->expects($this->any()) @@ -98,11 +93,9 @@ protected function getLocalTaskManager($module_dirs, $route_name, $route_params) $pluginDiscovery = new YamlDiscovery('links.task', $module_dirs); $pluginDiscovery = new ContainerDerivativeDiscoveryDecorator($pluginDiscovery); $property = new \ReflectionProperty('Drupal\Core\Menu\LocalTaskManager', 'discovery'); - $property->setAccessible(TRUE); $property->setValue($manager, $pluginDiscovery); $method = new \ReflectionMethod('Drupal\Core\Menu\LocalTaskManager', 'alterInfo'); - $method->setAccessible(TRUE); $method->invoke($manager, 'local_tasks'); $plugin_stub = $this->createMock('Drupal\Core\Menu\LocalTaskInterface'); @@ -111,7 +104,6 @@ protected function getLocalTaskManager($module_dirs, $route_name, $route_params) ->method('createInstance') ->willReturn($plugin_stub); $property = new \ReflectionProperty('Drupal\Core\Menu\LocalTaskManager', 'factory'); - $property->setAccessible(TRUE); $property->setValue($manager, $factory); $cache_backend = $this->createMock('Drupal\Core\Cache\CacheBackendInterface'); diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php index faf6850cbebfd01edc54c06fe0872db917da690c..dfb55098a3697023c001e72bf75409d4d7442255 100644 --- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php @@ -258,11 +258,9 @@ protected function setupLocalTaskManager() { $this->manager = new LocalTaskManager($this->argumentResolver, $request_stack, $this->routeMatch, $this->routeProvider, $module_handler, $this->cacheBackend, $language_manager, $this->accessManager, $this->account); $property = new \ReflectionProperty('Drupal\Core\Menu\LocalTaskManager', 'discovery'); - $property->setAccessible(TRUE); $property->setValue($this->manager, $this->pluginDiscovery); $property = new \ReflectionProperty('Drupal\Core\Menu\LocalTaskManager', 'factory'); - $property->setAccessible(TRUE); $property->setValue($this->manager, $this->factory); } diff --git a/core/tests/Drupal/Tests/Core/Routing/RouterUnsupportedTest.php b/core/tests/Drupal/Tests/Core/Routing/RouterUnsupportedTest.php index 458654e0e4f49d8ca3f4106a647b339ce950bb4a..222dbb8a1cbb94a8a0af6d061636052698611597 100644 --- a/core/tests/Drupal/Tests/Core/Routing/RouterUnsupportedTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/RouterUnsupportedTest.php @@ -42,9 +42,7 @@ public function testGenerateUnsupported() { public function testDeprecatedAdd() { // Test needs access to router's protected properties. $filters = new \ReflectionProperty(Router::class, 'filters'); - $filters->setAccessible(TRUE); $enhancers = new \ReflectionProperty(Router::class, 'enhancers'); - $enhancers->setAccessible(TRUE); $route_provider = $this->prophesize(RouteProviderInterface::class); $current_path_stack = $this->prophesize(CurrentPathStack::class); diff --git a/core/tests/Drupal/Tests/Core/Site/SettingsTest.php b/core/tests/Drupal/Tests/Core/Site/SettingsTest.php index 0737c5a81e543e99348691deb0b3c72dc0a36ab4..7090275cca1cb3d4676879cd2c1106f745559229 100644 --- a/core/tests/Drupal/Tests/Core/Site/SettingsTest.php +++ b/core/tests/Drupal/Tests/Core/Site/SettingsTest.php @@ -146,7 +146,6 @@ public function testGetInstanceReflection() { $class = new \ReflectionClass(Settings::class); $instance_property = $class->getProperty("instance"); - $instance_property->setAccessible(TRUE); $instance_property->setValue(NULL); $this->expectException(\BadMethodCallException::class); @@ -200,7 +199,6 @@ public function testFakeDeprecatedSettings(array $settings_config, string $setti $class = new \ReflectionClass(Settings::class); $instance_property = $class->getProperty('deprecatedSettings'); - $instance_property->setAccessible(TRUE); $deprecated_settings = $instance_property->getValue(); $deprecated_settings['deprecated_legacy'] = $deprecated_setting; $instance_property->setValue($deprecated_settings); diff --git a/core/tests/Drupal/Tests/Core/StringTranslation/StringTranslationTraitTest.php b/core/tests/Drupal/Tests/Core/StringTranslation/StringTranslationTraitTest.php index 6e5b813ac02ce0e1729ea301da2513e8c13e0d56..6f693318633f15549221d64352ec8425d4f62560 100644 --- a/core/tests/Drupal/Tests/Core/StringTranslation/StringTranslationTraitTest.php +++ b/core/tests/Drupal/Tests/Core/StringTranslation/StringTranslationTraitTest.php @@ -51,7 +51,6 @@ protected function setUp(): void { */ public function testT() { $method = $this->reflection->getMethod('t'); - $method->setAccessible(TRUE); $result = $method->invoke($this->translation, 'something'); $this->assertInstanceOf(TranslatableMarkup::class, $result); @@ -63,7 +62,6 @@ public function testT() { */ public function testFormatPlural() { $method = $this->reflection->getMethod('formatPlural'); - $method->setAccessible(TRUE); $result = $method->invoke($this->translation, 2, 'apple', 'apples'); $this->assertInstanceOf(PluralTranslatableMarkup::class, $result); diff --git a/core/tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php b/core/tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php index 4df06f7a4c51047aed83a928f288a2edd6b4d173..bffe8fa0a6ce0746de703852e4f325e764f12f2d 100644 --- a/core/tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php +++ b/core/tests/Drupal/Tests/Core/TempStore/SharedTempStoreTest.php @@ -366,7 +366,6 @@ public function testSerialization() { $this->assertInstanceOf(SharedTempStore::class, $store); $reflected_request_stack = (new \ReflectionObject($store))->getProperty('requestStack'); - $reflected_request_stack->setAccessible(TRUE); $request_stack = $reflected_request_stack->getValue($store); $this->assertEquals($this->requestStack, $request_stack); $this->assertSame($unserializable_request, $request_stack->pop()); diff --git a/core/tests/Drupal/Tests/Core/Test/BrowserTestBaseTest.php b/core/tests/Drupal/Tests/Core/Test/BrowserTestBaseTest.php index b32a8b396f894768d05b7942c031349141a22e0c..b15b989b595908a68830724b053e8ced98b99d09 100644 --- a/core/tests/Drupal/Tests/Core/Test/BrowserTestBaseTest.php +++ b/core/tests/Drupal/Tests/Core/Test/BrowserTestBaseTest.php @@ -53,7 +53,6 @@ public function testGetHttpClient() { $btb = $this->mockBrowserTestBaseWithDriver($driver); $ref_gethttpclient = new \ReflectionMethod($btb, 'getHttpClient'); - $ref_gethttpclient->setAccessible(TRUE); $this->assertSame(get_class($expected), get_class($ref_gethttpclient->invoke($btb))); } @@ -67,7 +66,6 @@ public function testGetHttpClientException() { $btb = $this->mockBrowserTestBaseWithDriver(new \stdClass()); $ref_gethttpclient = new \ReflectionMethod($btb, 'getHttpClient'); - $ref_gethttpclient->setAccessible(TRUE); $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('The Mink client type stdClass does not support getHttpClient().'); @@ -88,7 +86,6 @@ public function testTearDownWithoutSetUp() { ->getMockForAbstractClass(); $btb->expects($this->never())->method($method); $ref_tearDown = new \ReflectionMethod($btb, 'tearDown'); - $ref_tearDown->setAccessible(TRUE); $ref_tearDown->invoke($btb); } diff --git a/core/tests/Drupal/Tests/Core/Test/RunTests/TestFileParserTest.php b/core/tests/Drupal/Tests/Core/Test/RunTests/TestFileParserTest.php index 43bd98dcd17c2bc69c2520b44ac0ea5d269785de..3d8d388761854453cc2281ca3e3eb3e0ab80acb0 100644 --- a/core/tests/Drupal/Tests/Core/Test/RunTests/TestFileParserTest.php +++ b/core/tests/Drupal/Tests/Core/Test/RunTests/TestFileParserTest.php @@ -71,7 +71,6 @@ public function testParseContents($expected, $contents) { $parser = new TestFileParser(); $ref_parse = new \ReflectionMethod($parser, 'parseContents'); - $ref_parse->setAccessible(TRUE); $this->assertSame($expected, $ref_parse->invoke($parser, $contents)); } diff --git a/core/tests/Drupal/Tests/Core/Test/TestSetupTraitTest.php b/core/tests/Drupal/Tests/Core/Test/TestSetupTraitTest.php index 43dce9fdcc0999d3340e3b9d174fbfd8c4d4cd42..b6ba4e389db9659926bb1653fa75acc6dfd3197a 100644 --- a/core/tests/Drupal/Tests/Core/Test/TestSetupTraitTest.php +++ b/core/tests/Drupal/Tests/Core/Test/TestSetupTraitTest.php @@ -41,7 +41,6 @@ public function testChangeDatabasePrefix() { $reflection->getProperty('root')->setValue($test_setup, $root); $method = new \ReflectionMethod(get_class($test_setup), 'changeDatabasePrefix'); - $method->setAccessible(TRUE); $method->invoke($test_setup); // Ensure that SIMPLETEST_DB defines the default database connection after diff --git a/core/tests/Drupal/Tests/Core/Test/TestSuiteBaseTest.php b/core/tests/Drupal/Tests/Core/Test/TestSuiteBaseTest.php index fdcc901511a5d574fdb6dfc939ddc506cb1ecb66..8a82e033c4c78c2274c9edb604f9240c8f12c4a4 100644 --- a/core/tests/Drupal/Tests/Core/Test/TestSuiteBaseTest.php +++ b/core/tests/Drupal/Tests/Core/Test/TestSuiteBaseTest.php @@ -93,7 +93,6 @@ public function testAddTestsBySuiteNamespaceCore($filesystem, $suite_namespace, // Access addTestsBySuiteNamespace(). $ref_add_tests = new \ReflectionMethod($stub, 'addTestsBySuiteNamespace'); - $ref_add_tests->setAccessible(TRUE); // Invoke addTestsBySuiteNamespace(). $ref_add_tests->invokeArgs($stub, [vfsStream::url('root'), $suite_namespace]); diff --git a/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php b/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php index a394a12f9ac2b22fe77c8dfa2ca2e23edf98fb14..e532525e1d783cfbf7198f6342133ad0843a7e5b 100644 --- a/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php +++ b/core/tests/Drupal/Tests/Core/Theme/RegistryTest.php @@ -208,7 +208,6 @@ public function testPostProcessExtension($defined_functions, $hooks, $expected) $class = new \ReflectionClass(Registry::class); $reflection_method = $class->getMethod('postProcessExtension'); - $reflection_method->setAccessible(TRUE); $reflection_method->invokeArgs($this->registry, [&$hooks, $theme->reveal()]); $this->assertEquals($expected, $hooks);