Problem/Motivation

In FileFieldTestBase, unlike ::assertFileEntryExists(), ::assertFileEntryNotExists() doesn't have a default $message parameter, therefore requiring the calling class to at least supply a NULL value.

Steps to reproduce

Call ::assertFileEntryNotExists() with one param.

Proposed resolution

Give the $message parameter a default value of NULL.

Remaining tasks

Review.

User interface changes

None.

Introduced terminology

None.

API changes

::assertFileEntryNotExists() will be callable with one param.

Data model changes

None.

Release notes snippet

Issue fork drupal-3043127

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

Pancho created an issue. See original summary.

pancho’s picture

StatusFileSize
new889 bytes

Small fix.

pancho’s picture

Status: Active » Needs review
pancho’s picture

Title: FileFieldTestBase::assertFileEntryNotExists() missing default $message parameter » FileFieldTestBase::assertFileEntryNotExists() not properly typehinted, missing default $message parameter
Priority: Minor » Normal
StatusFileSize
new1.77 KB
new1.6 KB

Also, both assertFileEntryExists() and assertFileEntryNotExists() do require $file to be a FileInterface, so adding a proper type hint and docblocks.

pancho’s picture

Replacing format_string() with FormattableMarkup should probably happen for the whole base class in #3043024: Expand FileManagedTestBase with some of FileFieldTestBase.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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
new162 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.

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.

liam morland made their first commit to this issue’s fork.

liam morland’s picture

If the value is NULL, the automatic message will result in this error:

Argument #2 ($message) must be of type string, Drupal\Component\Render\FormattableMarkup

liam morland’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

Can issue summary be updated to use standard template.

Pretty sure javascript is a random failure.

liam morland’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs issue summary update
smustgrave’s picture

Shouldn't the default be '' and don't need to typecast?

liam morland’s picture

Other ones have NULL as the default. The cast is needed anyway because of the error I mentioned in #16.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Gotcha,

Change seems small then so don't mind marking.

quietone’s picture

Status: Reviewed & tested by the community » Needs work
Related issues: +#2549805: [Meta] Remove all usage of FormattableMarkup in tests apart from explicit tests of that API

mohit_aghera made their first commit to this issue’s fork.

mohit_aghera’s picture

Status: Needs work » Reviewed & tested by the community

I'm setting back to RTBC since there is just one change (setting default value to param) in the test file now.
MR is updated with latest 11.x
Tests are green as well.

xjm’s picture

Title: FileFieldTestBase::assertFileEntryNotExists() not properly typehinted, missing default $message parameter » FileFieldTestBase::assertFileEntryNotExists() should be documented, typehinted, and accept a null value for $message
Status: Reviewed & tested by the community » Needs work

The method is missing its parameter documentation, which does not help the situation. Given that we're changing the allowed values of the assertion method, I think it's also in scope to add parameter docs.

Since the current version is only broadening the allowed values of the method, it's pretty BC. That said, since we're talking of typehints, I think we can also expand the scope to add signature typehints to the assertion, which is an allowable BC break for test-only code. I checked contrib usages and overrides of this assertion, and there's only one contrib module in a non-D7 test: MinisiteTestBase.

Thanks everyone!

xjm’s picture

Sorry, I should have provided the reference to the BC policy regarding test code. In this case, since it's a method on a base class, it's borderline, but as a release manager I have discretion to allow internal BC breaks in certain cases like this one. :) Thanks!

mohit_aghera’s picture

Status: Needs work » Needs review

Thanks for clarifying and updating the issue.
I've made necessary changes to the assertion call.
MR is green now.

liam morland’s picture

I have rebased this. Is there a reason this does not also add type declarations to the other methods in that file?

xjm’s picture

@liam morland That could be done elsewhere -- and there are meta issues to address missing typehints in core generally -- but it is out of scope for this issue, which is just about the one specific method. Thanks!

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Feedback appears to be addressed

  • xjm committed f9563f61 on 11.x
    Issue #3043127 by liam morland, mohit_aghera, pancho, smustgrave, xjm,...

  • xjm committed abde03f3 on 11.2.x
    Issue #3043127 by liam morland, mohit_aghera, pancho, smustgrave, xjm,...
xjm’s picture

Version: 11.x-dev » 11.2.x-dev
Status: Reviewed & tested by the community » Fixed

Committed to 11.x despite the BC break, based on my assessment in #27. I also backported it to 11.2.x in accordance with #3534111: [policy, no patch] Update allowed changes to current practice for backport of Test API changes.

Thanks everyone!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.