Problem/Motivation

When I pushed the branch for node/3582330, phpunit reported,

There was 1 failure:
1) Drupal\Tests\auto_entitylabel\Kernel\AutoEntityLabelPermissionControllerTest::testAutoEntityLabelPermissions
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
'administer node_type labels' => [...]
+ 'administer entity_test_no_id_bundle labels' => [...]
)
/builds/issue/auto_entitylabel-3582330/tests/src/Kernel/AutoEntityLabelPermissionControllerTest.php:70
FAILURES!

this is unrelated to that ticket, so I opened a new one.

Steps to reproduce

see https://git.drupalcode.org/issue/auto_entitylabel-3582330/-/jobs/9160899

Proposed resolution

Rather than asserting that the whole array is identical, check the individual array values that we care about.

Remaining tasks

rewrite the test and make an MR

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

benstallings created an issue. See original summary.

benstallings’s picture

Assigned: benstallings » Unassigned
Status: Active » Needs review
csakiistvan’s picture

Assigned: Unassigned » csakiistvan

Environment

  • Drupal: 11.4.1
  • PHP: 8.5.5
  • Database: MariaDB 10.11.16
  • DDEV: v1.25.2
  • Auto Entity Label: 8.x-3.x-dev
  • Browser: Chrome

Prerequisites

  • Auto Entity Label installed.
  • A working PHPUnit setup for kernel tests (DDEV, with SIMPLETEST_DB pointing at the database).

Root cause

The test extends EntityKernelTestBase, which enables the entity_test module. On current Drupal core, entity_test defines an extra bundle entity type (entity_test_no_id_bundle), so autoEntityLabelPermissions() returns an additional administer entity_test_no_id_bundle labels permission. The test asserted the entire permissions array equalled only the node_type entry, so the extra key made the assertion fail.

Steps

  1. Apply the fix from MR !41: assert that the permissions array contains the expected administer node_type labels entry, instead of asserting the whole array is identical.
  2. Rebuild caches: ddev drush cr
  3. Run the kernel test: ddev exec "SIMPLETEST_DB=mysql://db:db@db/db vendor/bin/phpunit -c web/core web/modules/contrib/auto_entitylabel/tests/src/Kernel/AutoEntityLabelPermissionControllerTest.php"
  4. Observe the test result before and after the fix.

Expected results

  • The test passes regardless of extra entity types (and their label permissions) contributed by the test environment.
  • The specific administer node_type labels permission is still asserted to have the correct title and access settings.

Actual results

Before the fix, the test failed: the actual permissions array contained an extra administer entity_test_no_id_bundle labels key that the strict whole-array assertEquals did not expect. After applying the fix, the test passes (16 assertions, 0 failures), asserting only the presence and content of the administer node_type labels entry. The single remaining deprecation notice about #[RunTestsInSeparateProcesses] is unrelated core behaviour affecting all kernel tests.


Testing produced with the assistance of an LLM.

csakiistvan’s picture

Assigned: csakiistvan » Unassigned
Status: Needs review » Reviewed & tested by the community