Draft: Issue #3519393: Convert functional tests in navigation module to kernel tests
Closes #3519393
Merge request reports
Activity
33 43 34 44 // After installing Navigation, the bar is present, but not the block. 35 45 $module_installer->install(['navigation']); 36 $this->drupalLogin($this->drupalCreateUser(['access navigation'])); 46 $this->installConfig(['navigation']); 47 $this->setCurrentUser($this->createUser(['access navigation'])); 37 48 $this->drupalGet($test_page_url); 38 49 $this->assertSession()->elementExists('css', '.admin-toolbar'); 39 50 $this->assertSession()->elementNotExists('css', '.toolbar-button--icon--test-block'); 40 51 41 52 // After installing Navigation Test Block, both elements are present. 53 $this->refreshVariables(); Alternatively this can be narrowed down to
$this->container->get('cache.render')->reset();
.Edited by Michael StrelanDigging further, if we remove
refreshVariables
in the functional test it still passes, so why do we need it here? I stepped through it and can see in functional tests the render cache usesDatabaseBackend
which does checksum invalidation. But in kernel tests we useMemoryBackend
which is not meant to persist between requests. In order to test multiple requests properly we probably ought to useDatabaseBackend
too. I tried that but couldn't get it to work. It's probably ok to putrefreshVariables
in todrupalGet
as perUiHelperTrait
.changed this line in version 2 of the diff
60 72 61 73 // After installing Navigation, both elements are present. 62 74 $module_installer->install(['navigation']); 63 $this->drupalLogin($this->drupalCreateUser(['access navigation'])); 75 $this->installConfig(['navigation']); 76 $this->setCurrentUser($this->createUser(['access navigation'])); 64 77 $this->drupalGet($test_page_url); 65 78 $this->assertSession()->elementExists('css', '.admin-toolbar'); 66 79 $this->assertSession()->elementContains('css', '.toolbar-button--icon--test-block', 'Test Navigation Block'); - Comment on lines 62 to 66
This doesn't seem to work because
hook_page_top
doesn't get invoked for the navigation module. This seems to be related to https://www.drupal.org/node/3491200.