UnitTestCaseTest.php in Drupal 9        
                          
                  
                        
  
  
  
  
  
File
  core/tests/Drupal/Tests/UnitTestCaseTest.php
  
    View source  
  <?php
namespace Drupal\Tests;
class UnitTestCaseTest extends UnitTestCase {
  
  public function testAssertArrayEquals() {
    $this
      ->expectDeprecation('Drupal\\Tests\\UnitTestCase::assertArrayEquals() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use ::assertEquals(), ::assertEqualsCanonicalizing(), or ::assertSame() instead. See https://www.drupal.org/node/3136304');
    $this
      ->assertArrayEquals([], []);
  }
  
  public function testVarDumpSameProcess() {
    
    stream_filter_register("capture", StreamCapturer::class);
    stream_filter_append(STDOUT, "capture");
    
    $object = (object) [
      'foo' => 'bar',
    ];
    dump($object);
    dump('banana');
    $this
      ->assertStringContainsString('bar', StreamCapturer::$cache);
    $this
      ->assertStringContainsString('banana', StreamCapturer::$cache);
  }
  
  public function testVarDumpSeparateProcess() {
    
    stream_filter_register("capture", StreamCapturer::class);
    stream_filter_append(STDOUT, "capture");
    
    $object = (object) [
      'foo' => 'bar',
    ];
    dump($object);
    dump('banana');
    $this
      ->assertStringContainsString('bar', StreamCapturer::$cache);
    $this
      ->assertStringContainsString('banana', StreamCapturer::$cache);
  }
}