Skip to content
Snippets Groups Projects

Draft: Issue #3519393: Convert functional tests in navigation module to kernel tests

Open Draft: Issue #3519393: Convert functional tests in navigation module to kernel tests
2 unresolved threads
2 unresolved threads

Closes #3519393

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
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 Strelan
  • FWIW in UiHelperTrait::drupalGet we have this already:

    // Ensure that any changes to variables in the other thread are picked up.
    $this->refreshVariables();

    Seems we need to do the same in HttpKernelUiHelperTrait

  • Digging 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 uses DatabaseBackend which does checksum invalidation. But in kernel tests we use MemoryBackend which is not meant to persist between requests. In order to test multiple requests properly we probably ought to use DatabaseBackend too. I tried that but couldn't get it to work. It's probably ok to put refreshVariables in to drupalGet as per UiHelperTrait.

  • Michael Strelan changed this line in version 2 of the diff

    changed this line in version 2 of the diff

  • Please register or sign in to reply
  • 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');
  • Michael Strelan added 3 commits

    added 3 commits

    • 6817731e - Fix namespace
    • 92b78e05 - Add refreshVariables to HttpKernelUiHelperTrait
    • 5809cdd2 - Remove refreshVariables from NavigationDefaultBlockDefinitionTest

    Compare with previous version

  • Please register or sign in to reply
    Loading