From 2f589d62af726cce68fface425ad005b1717ea5e Mon Sep 17 00:00:00 2001 From: quietone <quietone@2572884.no-reply.drupal.org> Date: Sun, 23 Feb 2025 21:48:20 +1300 Subject: [PATCH 1/2] enable and fix for Unit tests --- ...BigPipeResponseAttachmentsProcessorTest.php | 6 ++++++ .../Unit/StackMiddleware/ContentLengthTest.php | 3 +++ .../tests/src/Unit/BlockRepositoryTest.php | 3 +++ .../DisplayVariant/BlockPageVariantTest.php | 3 +++ .../tests/src/Unit/HTMLRestrictionsTest.php | 18 ++++++++++++++++++ .../tests/src/Unit/CommentLinkBuilderTest.php | 3 +++ .../src/Unit/FieldConfigEntityUnitTest.php | 6 ++++++ .../Plugin/migrate/process/d6/FileUriTest.php | 18 ++++++++++++++++++ .../src/Unit/FilterUninstallValidatorTest.php | 3 +++ .../Unit/ContentLanguageSettingsUnitTest.php | 12 ++++++++++++ .../src/Unit/LanguageNegotiationUrlTest.php | 3 +++ .../src/Unit/LocaleBulkDeprecationTest.php | 3 +++ .../destination/EntityContentBaseTest.php | 9 +++++++++ .../migrate/destination/EntityRevisionTest.php | 9 +++++++++ .../migrate/destination/EntityTestBase.php | 9 +++++++++ .../PerComponentEntityDisplayTest.php | 6 ++++++ .../PerComponentEntityFormDisplayTest.php | 6 ++++++ .../mysql/tests/src/Unit/InstallTasksTest.php | 18 ++++++++++++++++++ .../tests/src/Unit/LoggingBeginnerTest.php | 3 +++ .../tests/src/Unit/LoggingCommitterTest.php | 3 +++ .../tests/src/Unit/LoggingStagerTest.php | 3 +++ .../ResourceResponseSubscriberTest.php | 3 +++ .../src/Unit/SearchPageRepositoryTest.php | 3 +++ .../tests/src/Unit/Encoder/XmlEncoderTest.php | 3 +++ .../DateTimeIso8601NormalizerTest.php | 3 +++ .../Unit/Normalizer/DateTimeNormalizerTest.php | 3 +++ .../EntityReferenceFieldItemNormalizerTest.php | 3 +++ .../Normalizer/TimestampNormalizerTest.php | 3 +++ .../PathBasedBreadcrumbBuilderTest.php | 9 +++++++++ .../src/Unit/FileTransfer/FileTransferTest.php | 3 +++ .../Unit/Routing/AdminRouteSubscriberTest.php | 3 +++ .../tests/src/Unit/PermissionHandlerTest.php | 12 ++++++++++++ .../src/Unit/Plugin/Block/ViewsBlockTest.php | 3 +++ .../Unit/Plugin/field/FieldPluginBaseTest.php | 6 ++++++ .../tests/src/Unit/Plugin/field/FieldTest.php | 3 +++ .../src/Unit/Plugin/pager/SqlBaseTest.php | 3 +++ .../views/tests/src/Unit/PluginBaseTest.php | 3 +++ .../Unit/Routing/ViewPageControllerTest.php | 3 +++ .../views/tests/src/Unit/ViewsDataTest.php | 3 +++ .../tests/src/Unit/ViewListBuilderTest.php | 3 +++ core/phpcs.xml.dist | 1 + 41 files changed, 223 insertions(+) diff --git a/core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php b/core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php index 0ae2104b6ed7..69eca6473b49 100644 --- a/core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php +++ b/core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php @@ -42,6 +42,9 @@ public function testNonHtmlResponse($response_class): void { $big_pipe_response_attachments_processor->processAttachments($non_html_response); } + /** + * Provides data to testNonHtmlResponse(). + */ public static function nonHtmlResponseProvider() { return [ 'AjaxResponse, which implements AttachmentsInterface' => [AjaxResponse::class], @@ -89,6 +92,9 @@ public function testHtmlResponse(array $attachments): void { $this->assertEquals('processed', $processed_big_pipe_response->getContent(), 'Content of returned (processed) response object MUST be changed.'); } + /** + * Provides data to testHtmlResponse(). + */ public static function attachmentsProvider() { $typical_cases = [ 'no attachments' => [[]], diff --git a/core/modules/big_pipe/tests/src/Unit/StackMiddleware/ContentLengthTest.php b/core/modules/big_pipe/tests/src/Unit/StackMiddleware/ContentLengthTest.php index 3a6090b7afff..ec0cd6c9a3c5 100644 --- a/core/modules/big_pipe/tests/src/Unit/StackMiddleware/ContentLengthTest.php +++ b/core/modules/big_pipe/tests/src/Unit/StackMiddleware/ContentLengthTest.php @@ -37,6 +37,9 @@ public function testHandle(false|int $expected_header, Response $response): void $this->assertSame((string) $expected_header, $response->headers->get('Content-Length')); } + /** + * Provides data for testHandle(). + */ public static function providerTestSetContentLengthHeader() { $response = new Response('Test content', 200); $response->headers->set('Content-Length', (string) strlen('Test content')); diff --git a/core/modules/block/tests/src/Unit/BlockRepositoryTest.php b/core/modules/block/tests/src/Unit/BlockRepositoryTest.php index 4d36f8aa36ce..dd1a70b76fc2 100644 --- a/core/modules/block/tests/src/Unit/BlockRepositoryTest.php +++ b/core/modules/block/tests/src/Unit/BlockRepositoryTest.php @@ -112,6 +112,9 @@ public function testGetVisibleBlocksPerRegion(array $blocks_config, array $expec $this->assertEquals($expected_blocks, $result); } + /** + * Provides data to testGetVisibleBlocksPerRegion(). + */ public static function providerBlocksConfig() { $blocks_config = [ 'block1' => [ diff --git a/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php b/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php index d9648265184e..871af6072fd4 100644 --- a/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php +++ b/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php @@ -66,6 +66,9 @@ public function setUpDisplayVariant($configuration = [], $definition = []) { return new BlockPageVariant($configuration, 'test', $definition, $this->blockRepository, $this->blockViewBuilder, ['config:block_list']); } + /** + * Provides data to testBuild(). + */ public static function providerBuild() { $blocks_config = [ 'block1' => [ diff --git a/core/modules/ckeditor5/tests/src/Unit/HTMLRestrictionsTest.php b/core/modules/ckeditor5/tests/src/Unit/HTMLRestrictionsTest.php index 49621be87fd7..f512c008ceeb 100644 --- a/core/modules/ckeditor5/tests/src/Unit/HTMLRestrictionsTest.php +++ b/core/modules/ckeditor5/tests/src/Unit/HTMLRestrictionsTest.php @@ -28,6 +28,9 @@ public function testConstructor(array $elements, ?string $expected_exception_mes $this->assertIsArray($restrictions->getAllowedElements(FALSE)); } + /** + * Provides data to testConstructor(). + */ public static function providerConstruct(): \Generator { // Fundamental structure. yield 'INVALID: list instead of key-value pairs' => [ @@ -167,6 +170,9 @@ public function testCounting(array $elements, bool $expected_is_empty, int $expe $this->assertCount($expected_concrete_plus_wildcard_count, $r->getAllowedElements(FALSE)); } + /** + * Provides data to testCounting(). + */ public static function providerCounting(): \Generator { yield 'empty' => [ [], @@ -257,6 +263,9 @@ public function testConvenienceConstructors($input, array $expected, ?array $exp $this->assertSame($expected_raw + $filter_html_additional_expectations, HTMLRestrictions::fromFilterPluginInstance($filter_plugin_instance->reveal())->getAllowedElements(FALSE)); } + /** + * Provides data to testConvenienceConstructors(). + */ public static function providerConvenienceConstructors(): \Generator { // All empty cases. yield 'empty string' => [ @@ -639,6 +648,9 @@ public function testRepresentations(HTMLRestrictions $restrictions, array $expec $this->assertSame($expected_ghs_config, $restrictions->toGeneralHtmlSupportConfig()); } + /** + * Provides data to testRepresentations(). + */ public static function providerRepresentations(): \Generator { yield 'empty set' => [ HTMLRestrictions::emptySet(), @@ -920,6 +932,9 @@ public function testOperations(HTMLRestrictions $a, HTMLRestrictions $b, $expect $this->assertEquals($expected_union, $a->merge($b)); } + /** + * Provides data to testOperations(). + */ public static function providerOperands(): \Generator { // Empty set operand cases. yield 'any set + empty set' => [ @@ -1678,6 +1693,9 @@ public function testSubsets(HTMLRestrictions $input, HTMLRestrictions $expected_ $this->assertEquals($expected_extracted_plain_tags_subset, $input->extractPlainTagsSubset()); } + /** + * Provides data to testSubsets(). + */ public static function providerSubsets(): \Generator { yield 'empty set' => [ new HTMLRestrictions([]), diff --git a/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php b/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php index d00c44595dac..76c3578a41a0 100644 --- a/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php +++ b/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php @@ -333,6 +333,9 @@ protected function getMockNode($has_field, $comment_status, $form_location, $com if (!function_exists('history_read')) { + /** + * Gets a timestamp for the current user's last view of a specified node. + */ function history_read($nid) { return 0; } diff --git a/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php b/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php index 07f2b29dd663..a638add1049e 100644 --- a/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php +++ b/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php @@ -303,10 +303,16 @@ public function testGetType(): void { */ class DependencyFieldItem { + /** + * Gets the dependencies for this field item. + */ public static function calculateDependencies(FieldDefinitionInterface $definition) { return ['module' => ['test_module3']]; } + /** + * Informs the entity that entities it depends on will be deleted. + */ public static function onDependencyRemoval($field_config, $dependencies) { } diff --git a/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/FileUriTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/FileUriTest.php index ef3dfb4767e1..6fd395a23ef6 100644 --- a/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/FileUriTest.php +++ b/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/FileUriTest.php @@ -24,6 +24,9 @@ class FileUriTest extends MigrateTestCase { 'id' => 'test', ]; + /** + * Tests with a public scheme. + */ public function testPublic(): void { $value = [ 'sites/default/files/foo.jpg', @@ -34,6 +37,9 @@ public function testPublic(): void { $this->assertEquals('public://foo.jpg', $this->doTransform($value)); } + /** + * Tests with a base path that is not known. + */ public function testPublicUnknownBasePath(): void { $value = [ '/path/to/public/files/foo.jpg', @@ -44,6 +50,9 @@ public function testPublicUnknownBasePath(): void { $this->assertEquals('public://path/to/public/files/foo.jpg', $this->doTransform($value)); } + /** + * Tests with a private scheme. + */ public function testPrivate(): void { $value = [ 'sites/default/files/baz.gif', @@ -54,6 +63,9 @@ public function testPrivate(): void { $this->assertEquals('private://baz.gif', $this->doTransform($value)); } + /** + * Tests with a private base path that is not known. + */ public function testPrivateUnknownBasePath(): void { $value = [ '/path/to/private/files/baz.gif', @@ -64,6 +76,9 @@ public function testPrivateUnknownBasePath(): void { $this->assertEquals('private://path/to/private/files/baz.gif', $this->doTransform($value)); } + /** + * Tests the temporary scheme. + */ public function testTemporary(): void { $value = [ '/tmp/bar.png', @@ -74,6 +89,9 @@ public function testTemporary(): void { $this->assertEquals('temporary://bar.png', $this->doTransform($value)); } + /** + * Performs the transform process. + */ protected function doTransform(array $value) { $executable = new MigrateExecutable($this->getMigration()); $row = new Row(); diff --git a/core/modules/filter/tests/src/Unit/FilterUninstallValidatorTest.php b/core/modules/filter/tests/src/Unit/FilterUninstallValidatorTest.php index e79c6d23b1bc..25d31c500c6e 100644 --- a/core/modules/filter/tests/src/Unit/FilterUninstallValidatorTest.php +++ b/core/modules/filter/tests/src/Unit/FilterUninstallValidatorTest.php @@ -171,6 +171,9 @@ public function testValidateNoMatchingFormats(): void { */ class FilterBaseTestableClass extends FilterBase { + /** + * {@inheritdoc} + */ public function process($text, $langcode) { return new FilterProcessResult(); } diff --git a/core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php b/core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php index cf7388e7dccf..86236f3a47a5 100644 --- a/core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php +++ b/core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php @@ -151,6 +151,9 @@ public function testDefaultLangcode(ContentLanguageSettings $config, $expected): $this->assertSame($expected, $config->getDefaultLangcode()); } + /** + * Provides data to testDefaultLangcode(). + */ public static function providerDefaultLangcode() { $langcode = Random::machineName(); $config = new ContentLanguageSettings([ @@ -180,6 +183,9 @@ public function testLanguageAlterable(ContentLanguageSettings $config, $expected $this->assertSame($expected, $config->isLanguageAlterable()); } + /** + * Provides data to testLanguageAlterable(). + */ public static function providerLanguageAlterable() { $alterableConfig = new ContentLanguageSettings([ 'target_entity_type_id' => 'test_entity_type', @@ -214,6 +220,9 @@ public function testIsDefaultConfiguration(ContentLanguageSettings $config, $exp $this->assertSame($expected, $config->isDefaultConfiguration()); } + /** + * Provides data to testIsDefaultConfiguration(). + */ public static function providerIsDefaultConfiguration() { $alteredLanguage = new ContentLanguageSettings([ 'target_entity_type_id' => 'test_entity_type', @@ -281,6 +290,9 @@ public function testLoadByEntityTypeBundle($config_id, ?ContentLanguageSettings $this->assertSame($expected_language_alterable, $config->isLanguageAlterable()); } + /** + * Provides data to testLoadByEntityTypeBundle(). + */ public static function providerLoadByEntityTypeBundle() { $alteredLanguage = new ContentLanguageSettings([ 'target_entity_type_id' => 'test_entity_type', diff --git a/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php b/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php index 0784b457a125..8fb765cdcaad 100644 --- a/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php +++ b/core/modules/language/tests/src/Unit/LanguageNegotiationUrlTest.php @@ -345,6 +345,9 @@ public static function providerTestDomain() { if (!function_exists('base_path')) { + /** + * Returns the base path. + */ function base_path() { return '/'; } diff --git a/core/modules/locale/tests/src/Unit/LocaleBulkDeprecationTest.php b/core/modules/locale/tests/src/Unit/LocaleBulkDeprecationTest.php index efa52a8ec67e..176ffa13292b 100644 --- a/core/modules/locale/tests/src/Unit/LocaleBulkDeprecationTest.php +++ b/core/modules/locale/tests/src/Unit/LocaleBulkDeprecationTest.php @@ -14,6 +14,9 @@ */ class LocaleBulkDeprecationTest extends UnitTestCase { + /** + * {@inheritdoc} + */ protected function setUp(): void { parent::setUp(); diff --git a/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php index 6b18a1bacb83..1cabbebdde6f 100644 --- a/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php +++ b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php @@ -122,14 +122,23 @@ class EntityTestDestination extends EntityContentBase { */ private $entity = NULL; + /** + * Sets the test entity. + */ public function setEntity($entity): void { $this->entity = $entity; } + /** + * Gets the test entity. + */ protected function getEntity(Row $row, array $old_destination_id_values) { return $this->entity; } + /** + * Gets the test entity ID. + */ public static function getEntityTypeId($plugin_id) { return 'foo'; } diff --git a/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityRevisionTest.php b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityRevisionTest.php index 610f5dbb5bf5..1dde373b8851 100644 --- a/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityRevisionTest.php +++ b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityRevisionTest.php @@ -110,14 +110,23 @@ class EntityRevisionTestDestination extends EntityRevision { */ private $entity = NULL; + /** + * Sets the test entity. + */ public function setEntity($entity): void { $this->entity = $entity; } + /** + * Gets the test entity. + */ protected function getEntity(Row $row, array $old_destination_id_values) { return $this->entity; } + /** + * Gets the test entity ID. + */ public static function getEntityTypeId($plugin_id) { return 'foo'; } diff --git a/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityTestBase.php b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityTestBase.php index 4176c3935024..ff185911cccb 100644 --- a/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityTestBase.php +++ b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityTestBase.php @@ -59,14 +59,23 @@ protected function setUp(): void { */ class BaseFieldDefinitionTest extends BaseFieldDefinition { + /** + * {@inheritdoc} + */ public static function create($type) { return new static([]); } + /** + * {@inheritdoc} + */ public function getSettings() { return []; } + /** + * {@inheritdoc} + */ public function getType() { return 'integer'; } diff --git a/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityDisplayTest.php b/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityDisplayTest.php index 0c2b729e8b66..bac47cde2f20 100644 --- a/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityDisplayTest.php +++ b/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityDisplayTest.php @@ -71,11 +71,17 @@ public function __construct($entity) { $this->entity = $entity; } + /** + * Gets the test entity. + */ protected function getEntity($entity_type, $bundle, $view_mode) { $this->testValues = func_get_args(); return $this->entity; } + /** + * Gets the test values. + */ public function getTestValues() { return $this->testValues; } diff --git a/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityFormDisplayTest.php b/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityFormDisplayTest.php index 0ce3f69e6bb3..774ba999baf6 100644 --- a/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityFormDisplayTest.php +++ b/core/modules/migrate/tests/src/Unit/destination/PerComponentEntityFormDisplayTest.php @@ -71,11 +71,17 @@ public function __construct($entity) { $this->entity = $entity; } + /** + * Gets the test entity. + */ protected function getEntity($entity_type, $bundle, $form_mode) { $this->testValues = func_get_args(); return $this->entity; } + /** + * Gets the test values. + */ public function getTestValues() { return $this->testValues; } diff --git a/core/modules/mysql/tests/src/Unit/InstallTasksTest.php b/core/modules/mysql/tests/src/Unit/InstallTasksTest.php index a50a6f010c76..90305518bee2 100644 --- a/core/modules/mysql/tests/src/Unit/InstallTasksTest.php +++ b/core/modules/mysql/tests/src/Unit/InstallTasksTest.php @@ -55,14 +55,23 @@ public function __construct(Connection $connection) { $this->connection = $connection; } + /** + * {@inheritdoc} + */ protected function isConnectionActive() { return TRUE; } + /** + * {@inheritdoc} + */ protected function getConnection() { return $this->connection; } + /** + * {@inheritdoc} + */ protected function t($string, array $args = [], array $options = []) { return $string; } @@ -79,14 +88,23 @@ protected function t($string, array $args = [], array $options = []) { private function createTasksNoConnection(): Tasks { return new class() extends Tasks { + /** + * {@inheritdoc} + */ protected function isConnectionActive() { return FALSE; } + /** + * {@inheritdoc} + */ protected function getConnection() { return NULL; } + /** + * {@inheritdoc} + */ protected function t($string, array $args = [], array $options = []) { return $string; } diff --git a/core/modules/package_manager/tests/src/Unit/LoggingBeginnerTest.php b/core/modules/package_manager/tests/src/Unit/LoggingBeginnerTest.php index af84befb7dab..b54e663179a4 100644 --- a/core/modules/package_manager/tests/src/Unit/LoggingBeginnerTest.php +++ b/core/modules/package_manager/tests/src/Unit/LoggingBeginnerTest.php @@ -18,6 +18,9 @@ */ class LoggingBeginnerTest extends UnitTestCase { + /** + * Tests the output of LoggingBeginner(). + */ public function testDecoratedBeginnerIsCalled(): void { $decorated = $this->createMock(BeginnerInterface::class); diff --git a/core/modules/package_manager/tests/src/Unit/LoggingCommitterTest.php b/core/modules/package_manager/tests/src/Unit/LoggingCommitterTest.php index 3d6ab55de0cf..83c19a1b8b66 100644 --- a/core/modules/package_manager/tests/src/Unit/LoggingCommitterTest.php +++ b/core/modules/package_manager/tests/src/Unit/LoggingCommitterTest.php @@ -18,6 +18,9 @@ */ class LoggingCommitterTest extends UnitTestCase { + /** + * Tests the output of LoggingCommitter(). + */ public function testDecoratedCommitterIsCalled(): void { $decorated = $this->createMock(CommitterInterface::class); diff --git a/core/modules/package_manager/tests/src/Unit/LoggingStagerTest.php b/core/modules/package_manager/tests/src/Unit/LoggingStagerTest.php index f21577c348d3..a7e6c050e173 100644 --- a/core/modules/package_manager/tests/src/Unit/LoggingStagerTest.php +++ b/core/modules/package_manager/tests/src/Unit/LoggingStagerTest.php @@ -18,6 +18,9 @@ */ class LoggingStagerTest extends UnitTestCase { + /** + * Tests LoggingStager(). + */ public function testDecoratedStagerIsCalled(): void { $decorated = $this->createMock(StagerInterface::class); diff --git a/core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php b/core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php index 5b1c0c400b54..7e0740473736 100644 --- a/core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php +++ b/core/modules/rest/tests/src/Unit/EventSubscriber/ResourceResponseSubscriberTest.php @@ -53,6 +53,9 @@ public function testSerialization($data, $expected_response = FALSE): void { $this->assertEquals($expected_response !== FALSE ? $expected_response : Json::encode($data), $event->getResponse()->getContent()); } + /** + * Provides data to testSerialization(). + */ public static function providerTestSerialization() { return [ // The default data for \Drupal\rest\ResourceResponse. diff --git a/core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php b/core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php index ce67ed1e0056..fdc9754f3bd1 100644 --- a/core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php +++ b/core/modules/search/tests/src/Unit/SearchPageRepositoryTest.php @@ -321,6 +321,9 @@ public function __construct(array $values) { } } + /** + * {@inheritdoc} + */ public function label($langcode = NULL) { return $this->label; } diff --git a/core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php b/core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php index e4da1fbde1fe..99130000b404 100644 --- a/core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php +++ b/core/modules/serialization/tests/src/Unit/Encoder/XmlEncoderTest.php @@ -108,6 +108,9 @@ public function testDefaultEncoderHasSerializer(): void { */ class TestObject { + /** + * Return the characters "A". + */ public function getA() { return 'A'; } diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/DateTimeIso8601NormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/DateTimeIso8601NormalizerTest.php index 4a805e19d6b3..9c6d8a52f5c8 100644 --- a/core/modules/serialization/tests/src/Unit/Normalizer/DateTimeIso8601NormalizerTest.php +++ b/core/modules/serialization/tests/src/Unit/Normalizer/DateTimeIso8601NormalizerTest.php @@ -307,6 +307,9 @@ public static function jsonSchemaDataProvider(): array { */ class DateTimeIso8601NormalizerTestDrupalDateTime extends DrupalDateTime { + /** + * Sets the timezone. + */ public function setTimezone(\DateTimeZone $timezone) { parent::setTimezone($timezone); } diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/DateTimeNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/DateTimeNormalizerTest.php index 3527c5ef6ffd..3082742e4a47 100644 --- a/core/modules/serialization/tests/src/Unit/Normalizer/DateTimeNormalizerTest.php +++ b/core/modules/serialization/tests/src/Unit/Normalizer/DateTimeNormalizerTest.php @@ -232,6 +232,9 @@ public static function jsonSchemaDataProvider(): array { */ class DateTimeNormalizerTestDrupalDateTime extends DrupalDateTime { + /** + * Sets the timezone. + */ public function setTimezone(\DateTimeZone $timezone) { parent::setTimezone($timezone); } diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php index 905598fea786..02ee2585da87 100644 --- a/core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php +++ b/core/modules/serialization/tests/src/Unit/Normalizer/EntityReferenceFieldItemNormalizerTest.php @@ -169,6 +169,9 @@ public function testNormalize(): void { $this->assertSame($expected, $normalized); } + /** + * Tests normalizing with an entity reference field. + */ public function testNormalizeWithNewEntityReference(): void { $test_url = '/test/100'; diff --git a/core/modules/serialization/tests/src/Unit/Normalizer/TimestampNormalizerTest.php b/core/modules/serialization/tests/src/Unit/Normalizer/TimestampNormalizerTest.php index e0e4c991c470..60f6db35f7ce 100644 --- a/core/modules/serialization/tests/src/Unit/Normalizer/TimestampNormalizerTest.php +++ b/core/modules/serialization/tests/src/Unit/Normalizer/TimestampNormalizerTest.php @@ -172,6 +172,9 @@ public static function jsonSchemaDataProvider(): array { */ class TimestampNormalizerTestDrupalDateTime extends DrupalDateTime { + /** + * Sets the timezone. + */ public function setTimezone(\DateTimeZone $timezone) { parent::setTimezone($timezone); } diff --git a/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php b/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php index e3745d487755..58a2a29e162c 100644 --- a/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php +++ b/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php @@ -419,6 +419,9 @@ public function setupAccessManagerToAllow(): void { ->willReturn((new AccessResultAllowed())->cachePerPermissions()); } + /** + * Prepares the mock processInbound() method. + */ protected function setupStubPathProcessor(): void { $this->pathProcessor->expects($this->any()) ->method('processInbound') @@ -437,11 +440,17 @@ class TestPathBasedBreadcrumbBuilder extends PathBasedBreadcrumbBuilder { */ protected LinkGeneratorInterface $linkGenerator; + /** + * {@inheritdoc} + */ public function setStringTranslation(TranslationInterface $string_translation) { $this->stringTranslation = $string_translation; return $this; } + /** + * Sets the link generator. + */ public function setLinkGenerator(LinkGeneratorInterface $link_generator): void { $this->linkGenerator = $link_generator; } diff --git a/core/modules/system/tests/src/Unit/FileTransfer/FileTransferTest.php b/core/modules/system/tests/src/Unit/FileTransfer/FileTransferTest.php index 2f67aa7a609d..0486dffcc1e4 100644 --- a/core/modules/system/tests/src/Unit/FileTransfer/FileTransferTest.php +++ b/core/modules/system/tests/src/Unit/FileTransfer/FileTransferTest.php @@ -27,6 +27,9 @@ protected function setUp(): void { $this->testConnection = TestFileTransfer::factory($this->root, []); } + /** + * Tests the value returned by __get(). + */ public function testFileTransferMagicMethods(): void { // Test to ensure __get() preserves public access. $this->assertInstanceOf(MockTestConnection::class, $this->testConnection->connection); diff --git a/core/modules/system/tests/src/Unit/Routing/AdminRouteSubscriberTest.php b/core/modules/system/tests/src/Unit/Routing/AdminRouteSubscriberTest.php index 7cd8f89c11e0..bbb2c88a8897 100644 --- a/core/modules/system/tests/src/Unit/Routing/AdminRouteSubscriberTest.php +++ b/core/modules/system/tests/src/Unit/Routing/AdminRouteSubscriberTest.php @@ -30,6 +30,9 @@ public function testAlterRoutes(Route $route, $is_admin): void { $this->assertSame($is_admin, $route->getOption('_admin_route')); } + /** + * Provides data to testAlterRoutes(). + */ public static function providerTestAlterRoutes() { $data = []; $data['non-admin'] = [ diff --git a/core/modules/user/tests/src/Unit/PermissionHandlerTest.php b/core/modules/user/tests/src/Unit/PermissionHandlerTest.php index 0a46196d1d46..c07756add0e1 100644 --- a/core/modules/user/tests/src/Unit/PermissionHandlerTest.php +++ b/core/modules/user/tests/src/Unit/PermissionHandlerTest.php @@ -358,12 +358,18 @@ protected function assertPermissions(array $actual_permissions): void { */ class TestPermissionCallbacks { + /** + * Callback that returns a single description. + */ public function singleDescription() { return [ 'access_module_a' => 'single_description', ]; } + /** + * Callback that returns the title and description. + */ public function titleDescription() { return [ 'access module b' => [ @@ -373,6 +379,9 @@ public function titleDescription() { ]; } + /** + * Callback that returns restricted access. + */ public function titleDescriptionRestrictAccess() { return [ 'access_module_c' => [ @@ -383,6 +392,9 @@ public function titleDescriptionRestrictAccess() { ]; } + /** + * Callback that returns the title. + */ public function titleProvider() { return [ 'access module a via module b' => [ diff --git a/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php b/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php index c7dbd103ea10..75f7305e8173 100644 --- a/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/Block/ViewsBlockTest.php @@ -307,6 +307,9 @@ public function testBuildFailed(): void { if (!function_exists('views_add_contextual_links')) { + /** + * Define method views_add_contextual_links for this test. + */ function views_add_contextual_links(&$render_element, $location, $display_id, ?array $view_element = NULL) { } diff --git a/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php b/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php index f2afff8e31dd..489102c07eb9 100644 --- a/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php @@ -972,6 +972,9 @@ public function testElementClassesWithTokens(): void { */ class FieldPluginBaseTestField extends FieldPluginBase { + /** + * Set the link generator. + */ public function setLinkGenerator(LinkGeneratorInterface $link_generator): void { $this->linkGenerator = $link_generator; } @@ -983,6 +986,9 @@ public function setLinkGenerator(LinkGeneratorInterface $link_generator): void { if (!function_exists('base_path')) { + /** + * Returns the base path. + */ function base_path() { return '/'; } diff --git a/core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php b/core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php index 128a5cefb7cf..d872bac6cac3 100644 --- a/core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php @@ -762,6 +762,9 @@ protected function setupLanguageRenderer(EntityField $handler, $definition): voi */ class FieldTestEntityField extends EntityField { + /** + * {@inheritdoc} + */ public function executePrepareItemsByDelta(array $all_values) { return $this->prepareItemsByDelta($all_values); } diff --git a/core/modules/views/tests/src/Unit/Plugin/pager/SqlBaseTest.php b/core/modules/views/tests/src/Unit/Plugin/pager/SqlBaseTest.php index 7dad710f4419..edd524d3039c 100644 --- a/core/modules/views/tests/src/Unit/Plugin/pager/SqlBaseTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/pager/SqlBaseTest.php @@ -36,6 +36,9 @@ class SqlBaseTest extends UnitTestCase { */ protected $display; + /** + * {@inheritdoc} + */ protected function setUp(): void { parent::setUp(); diff --git a/core/modules/views/tests/src/Unit/PluginBaseTest.php b/core/modules/views/tests/src/Unit/PluginBaseTest.php index b0b708a71d8e..a78824176272 100644 --- a/core/modules/views/tests/src/Unit/PluginBaseTest.php +++ b/core/modules/views/tests/src/Unit/PluginBaseTest.php @@ -290,6 +290,9 @@ public function testFilterByDefinedOptions($storage, $options, $expected_storage $this->assertEquals($expected_storage, $storage); } + /** + * Provides data to testFilterByDefinedOptions(). + */ public static function providerTestFilterByDefinedOptions() { $data = []; diff --git a/core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php b/core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php index 07e8894e7074..aef3e8c11dd8 100644 --- a/core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php +++ b/core/modules/views/tests/src/Unit/Routing/ViewPageControllerTest.php @@ -206,6 +206,9 @@ public function testHandleWithArgumentsOnOverriddenRouteWithUpcasting(): void { if (!function_exists('views_add_contextual_links')) { + /** + * Define method views_add_contextual_links for this test. + */ function views_add_contextual_links(&$render_element, $location, $display_id, ?array $view_element = NULL) { } diff --git a/core/modules/views/tests/src/Unit/ViewsDataTest.php b/core/modules/views/tests/src/Unit/ViewsDataTest.php index d88891901899..aec182fb164d 100644 --- a/core/modules/views/tests/src/Unit/ViewsDataTest.php +++ b/core/modules/views/tests/src/Unit/ViewsDataTest.php @@ -649,6 +649,9 @@ public function testGetEmptyKey($key): void { $this->viewsData->get($key); } + /** + * Provides data to testGetEmptyKey(). + */ public static function providerTestGetEmptyKey() { return [ [NULL], diff --git a/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php b/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php index b6a878eb5486..b51d5f1018f1 100644 --- a/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php +++ b/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php @@ -202,6 +202,9 @@ public function testBuildRowEntityList(): void { */ class TestViewListBuilder extends ViewListBuilder { + /** + * {@inheritdoc} + */ public function buildOperations(EntityInterface $entity) { return []; } diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist index 7d3de555897d..50039ecc1717 100644 --- a/core/phpcs.xml.dist +++ b/core/phpcs.xml.dist @@ -70,6 +70,7 @@ <include-pattern>*/FunctionalJavascript/*</include-pattern> <include-pattern>*/Kernel/*</include-pattern> <include-pattern>*/Functional/*</include-pattern> + <include-pattern>*/Unit/*</include-pattern> </rule> <rule ref="Drupal.Commenting.FunctionComment.MissingParamType"/> <rule ref="Drupal.Commenting.FunctionComment.MissingReturnComment"> -- GitLab From 4bb1e1655427a493f8df8dd092b4cf998c980951 Mon Sep 17 00:00:00 2001 From: quietone <quietone@2572884.no-reply.drupal.org> Date: Sat, 15 Mar 2025 01:06:41 +1300 Subject: [PATCH 2/2] TestSqlIdMap.php --- core/modules/migrate/tests/src/Unit/TestSqlIdMap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php b/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php index 0ddee3085393..296d615f6e2d 100644 --- a/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php +++ b/core/modules/migrate/tests/src/Unit/TestSqlIdMap.php @@ -82,7 +82,7 @@ protected function getFieldSchema(array $id_definition) { /** * {@inheritdoc} */ - // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod + // phpcs:ignore Generic.CodeAnalysis.UselessOverridingMethod, Drupal.Commenting.FunctionComment.Missing public function ensureTables() { parent::ensureTables(); } -- GitLab