You are here

public function TestDeprecatedTestHooks::testHookTestFinished in Drupal 8

@expectedDeprecation The deprecated hook hook_test_finished() is implemented in these functions: simpletest_deprecation_test_test_finished(). Convert your test to a PHPUnit-based one and implement test listeners. See https://www.drupal.org/node/2934242

File

core/modules/simpletest/tests/src/Kernel/TestDeprecatedTestHooks.php, line 80

Class

TestDeprecatedTestHooks
Test the deprecation messages for Simpletest test hooks.

Namespace

Drupal\Tests\simpletest\Kernel

Code

public function testHookTestFinished() {

  // Mock test_discovery.
  $discovery = $this
    ->getMockBuilder(TestDiscovery::class)
    ->disableOriginalConstructor()
    ->setMethods([
    'registerTestNamespaces',
  ])
    ->getMock();
  $discovery
    ->expects($this
    ->once())
    ->method('registerTestNamespaces')
    ->willReturn([]);

  // Mock renderer.
  $renderer = $this
    ->getMockBuilder(Renderer::class)
    ->disableOriginalConstructor()
    ->setMethods([
    'render',
  ])
    ->getMock();

  // We don't care what the rendered batch elements look like.
  $renderer
    ->expects($this
    ->any())
    ->method('render')
    ->willReturn('');

  // Set up the container.
  $this->container
    ->set('test_discovery', $discovery);
  $this->container
    ->set('renderer', $renderer);

  // A mock batch.
  $context = [];

  // InnocuousTest is a WebTestBase test class which passes and never touches
  // the database.
  _simpletest_batch_operation([
    InnocuousTest::class,
  ], __METHOD__, $context);
}