We have a
Functional test class derived from
BrowserTestBase which is passing, but the output includes a deprecation notice.
Adding non-existent permissions to a role is deprecated in drupal:9.3.0 and triggers a runtime exception before drupal:10.0.0. The incorrect permissions are "edit any page content". Permissions should be defined in a permissions.yml file or a permission callback. See https://www.drupal.org/node/3193348
$modules array includes the
node module, as well as a custom module whose implementation of
hook_install() assigns permissions to roles. One of those permissions is the "edit any page content" permission. When the module is installed on the site the permissions are assigned correctly. My understanding of the Node module is that it creates and enables the Article and Page content types by default, exposing the permissions appropriate to those content types, and that is indeed what happens on the site. But
phpunit can't find those permissions, even though it knows that loading of the Node module is required. Including a call to
setUp() doesn't eliminate the notice. Presumably if I don't figure this out the tests will start failing when we try to move to Drupal 10. We could work around the problem by backing out the code to assign the permission in the hook, and just assign it manually, but that's kind of ugly. I could also hack the hook implementation to detect when it's running under
phpunit (assuming that's possible), and skip that assignment in that case, but that's also hackier than I would like.