Problem/Motivation

$this->assertTrue($output instanceof MarkupInterface || is_string($output), new FormattableMarkup('\Drupal::theme() returns an object that implements MarkupInterface or a string for data type @type.', ['@type' => $type]));

Proposed resolution

Refactor the test to test independently the string and the MarkupInterface cases.

Remaining tasks

Discuss
Review patch

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3155495

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

Hardik_Patel_12 created an issue. See original summary.

hardik_patel_12’s picture

Status: Active » Needs review
StatusFileSize
new1.02 KB

Kindly review the patch.

Status: Needs review » Needs work

The last submitted patch, 2: 3155495-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Lal_’s picture

Status: Needs work » Needs review
StatusFileSize
new1.26 KB
new1.06 KB

Putting them inside the condition..

Status: Needs review » Needs work

The last submitted patch, 4: 3155495-4.patch, failed testing. View results

Lal_’s picture

StatusFileSize
new1.26 KB
kunalgautam’s picture

StatusFileSize
new1.07 KB
new981 bytes
s_bhandari’s picture

Status: Needs work » Needs review
mondrake’s picture

Title: Remove redundant $message from assert(Not)InstanceOf calls » Refactor system/Kernel/Theme/ThemeTest::testThemeDataTypes
Issue summary: View changes
StatusFileSize
new2.37 KB

Umm I'm afraid #7 is not really touching the point:

  1. +++ b/core/modules/system/tests/src/Kernel/Theme/ThemeTest.php
    @@ -58,8 +58,9 @@ public function testThemeDataTypes() {
    +      $this->assertIsString((string) $output);
    

    this is always true

  2. +++ b/core/modules/system/tests/src/Kernel/Theme/ThemeTest.php
    @@ -58,8 +58,9 @@ public function testThemeDataTypes() {
    +        $this->assertInstanceOf(MarkupInterface::class, $output);
    

    this is irrelevant since it's in an if {} block that is executed only if $output is an instance of MarkupInterface...

We now have a MarkupInterfaceComparator that can seamlessly compare strings and MarkupInterface objects through assertEquals, so we can just forget about the casting.

But, I think in this test we want to really assert that when the theme returns an empty string, the renderer returns a string as well. So let's refactor the test to make that explicit.

Not interdiff, it's a new patch.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new143 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

nikhil_110’s picture

StatusFileSize
new3.11 KB

Attached patch against Drupal 10.1.x

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

hardik_patel_12’s picture

Status: Needs work » Needs review
StatusFileSize
new2.1 KB
new2.37 KB

Attached patch against Drupal 11.x

hardik_patel_12’s picture

StatusFileSize
new2.13 KB
new2.55 KB

Rerolling patch against Drupal 11.x and adding interdiff.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Breaking apart the test seems fine. Not coverage lost.

quietone’s picture

Status: Reviewed & tested by the community » Needs work

@mondrake, thanks for the explanation given in #9. That made this much easier to review.

I think a comment can be improved but it would be fine to add this. However, according to GitLab this can be merged but the diff does not apply to HEAD. Not sure why that is. So, since this needs work I added a suggestion for the comment.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.