getMethod('normalizeRoleIds'); $roleIdsChanged = $adminReflection->getMethod('roleIdsChanged'); $normalizeRoleIds->setAccessible(true); $roleIdsChanged->setAccessible(true); adminMultiRoleExpect( $normalizeRoleIds->invoke(null, ['7', 2, 7, 0, -1]) === [2, 7], 'Role ids must be normalized, deduplicated and sorted' ); adminMultiRoleExpect( $roleIdsChanged->invoke(null, [2], [2, 7]) === true, 'Adding a role must invalidate the existing token' ); adminMultiRoleExpect( $roleIdsChanged->invoke(null, [2, 7], [2]) === true, 'Removing a role must invalidate the existing token' ); adminMultiRoleExpect( $roleIdsChanged->invoke(null, [2, 7], [7, 2]) === false, 'Changing only role order must not invalidate the token' ); $cacheMethod = new ReflectionMethod(AdminAuthCache::class, 'clearAuthCache'); $sourceLines = file($cacheMethod->getFileName()); $methodSource = implode('', array_slice( $sourceLines, $cacheMethod->getStartLine() - 1, $cacheMethod->getEndLine() - $cacheMethod->getStartLine() + 1 )); adminMultiRoleExpect( str_contains($methodSource, 'delete($this->cacheUrlKey)'), 'Single-admin permission cache must delete its concrete cache key' ); adminMultiRoleExpect( !str_contains($methodSource, 'tag($this->cacheUrlKey)'), 'Single-admin permission cache must not clear a tag that was never assigned' ); echo "AdminMultiRoleRegressionTest passed\n";