class KernelTestSharedContainerTest

Tests that the container is shared between kernel test methods.

Attributes

#[CoversClass(KernelTestBase::class)] #[Group('KernelTests')] #[RunTestsInSeparateProcesses] #[ShareEnvironment]

Hierarchy

Expanded class hierarchy of KernelTestSharedContainerTest

File

core/tests/Drupal/KernelTests/KernelTestSharedContainerTest.php, line 16

Namespace

Drupal\KernelTests
View source
class KernelTestSharedContainerTest extends KernelTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'container_rebuild_test',
  ];
  
  /**
   * Tests the number of container builds for each iteration of a test.
   */
  public function testContainerRebuilds($iteration, $container_rebuilds) : void {
    $this->assertSame($container_rebuilds, $this->container
      ->get('state')
      ->get('container_rebuild_test.count', 0), 'Container rebuilt once, iteration ' . $iteration);
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.