If your functionaljavascript test does a browser login, it used to retain the logged-in user for code that also runs in the backend. Now it runs as anonymous.
Install drupal 11.x-dev at this commit or later: https://github.com/drupal/core/commit/aa12cc60d44f1. Here's a minimal unit test. The \Drupal::currentUser() call should return the rootUser, but it's anonymous.
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
/**
* Tests the thing
*/
#[Group('Aaa')]
#[RunTestsInSeparateProcesses]
class AaaTest extends WebDriverTestBase {
// It doesn't matter what we put here we get the same problem, but this field is required. The problem is the call to update it down below.
protected $defaultTheme = 'olivero';
/**
* Tests the thing
*/
public function testAaa(): void {
\Drupal::service('theme_installer')->install(['olivero', 'claro']);
$this->config('system.theme')
->set('default', 'olivero')
->set('admin', 'claro')
->save();
$this->drupalLogin($this->rootUser);
$this->assertNotEmpty(\Drupal::currentUser()->id());
}
I'm not sure. The theme setting code in the unit test above is something we've been using for 5 years, and seems similar to code I see in some core functionaljavascript tests so still seems right. Is there some hook the above-mentioned core commit is missing?
Active
11.3 🔥
phpunit
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activities found.