DrupalApplicationTesterTrait.php

Same filename and directory in other branches
  1. 11.x core/tests/Drupal/KernelTests/DrupalApplicationTesterTrait.php

Namespace

Drupal\KernelTests

File

core/tests/Drupal/KernelTests/DrupalApplicationTesterTrait.php

View source
<?php

declare (strict_types=1);
namespace Drupal\KernelTests;

use Drupal\Tests\Composer\ComposerIntegrationTrait;
use Symfony\Component\Console\Tester\ApplicationTester;

/**
 * Trait to help with testing the drupal console.
 */
trait DrupalApplicationTesterTrait {
  use ComposerIntegrationTrait;
  
  /**
   * Build our ApplicationTester.
   */
  private function applicationTester(array $context = []) : ApplicationTester {
    $application = include static::binDir() . '/dr';
    $context['kernel.environment'] = 'testing';
    $context['kernel.allow_dumping'] = FALSE;
    $application = $application($context);
    $application->setAutoExit(FALSE);
    return new ApplicationTester($application);
  }

}

Traits

Title Deprecated Summary
DrupalApplicationTesterTrait Trait to help with testing the drupal console.

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