function KernelTestBaseTest::testVarDump
Tests the dump() function provided by the var-dumper Symfony component.
File
- 
              core/tests/ Drupal/ KernelTests/ KernelTestBaseTest.php, line 428 
Class
- KernelTestBaseTest
- @coversDefaultClass \Drupal\KernelTests\KernelTestBase[[api-linebreak]]
Namespace
Drupal\KernelTestsCode
public function testVarDump() {
  // Append the stream capturer to the STDOUT stream, so that we can test the
  // dump() output and also prevent it from actually outputting in this
  // particular test.
  stream_filter_register("capture", StreamCapturer::class);
  stream_filter_append(STDOUT, "capture");
  // Dump some variables.
  $this->enableModules([
    'system',
    'user',
  ]);
  $role = Role::create([
    'id' => 'test_role',
    'label' => 'Test role',
  ]);
  dump($role);
  dump($role->id());
  $this->assertStringContainsString('Drupal\\user\\Entity\\Role', StreamCapturer::$cache);
  $this->assertStringContainsString('test_role', StreamCapturer::$cache);
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
