Problem/Motivation

Part of #3529510: [meta] Add return types to test traits
Add return type hints to these traits that create something.

  1. core/modules/image/tests/src/Kernel/ImageFieldCreationTrait.php
  2. core/modules/media/tests/src/Traits/MediaTypeCreationTrait.php
  3. core/modules/node/tests/src/Traits/ContentTypeCreationTrait.php
  4. core/modules/node/tests/src/Traits/NodeCreationTrait.php

Steps to reproduce

Add SlevomatCodingStandard.TypeHints.ReturnTypeHint to phpcs.xml.dist

Proposed resolution

Add return type hints for the selected files.

Remaining tasks

Resolve failing tests in WorkspacesContentModerationStateTest
Review

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3644372

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

quietone created an issue. See original summary.

quietone’s picture

Issue summary: View changes

quietone’s picture

Title: Return type for test CreationTriats » Return types for test CreationTriats
Parent issue: » #3529510: [meta] Add return types to test traits
quietone’s picture

Issue summary: View changes
Status: Active » Needs work

There are failing tests in WorkspacesContentModerationStateTest with the error The "node_type" entity type can only be saved in the default workspace..

How to resolve that?

godotislate’s picture

There are failing tests in WorkspacesContentModerationStateTest with the error The "node_type" entity type can only be saved in the default workspace..

WorkspacesContentModerationStateTest extends ContentModerationStateTest, so any test* in the parent class that aren't overridden by the child class get run as part of the child class. If any of those methods call createContentType(), since it is no longer overridden, it is not executing correctly outside of a workspace anymore.