function PhpMailTest::setUp

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Mail/Plugin/Mail/PhpMailTest.php \Drupal\Tests\Core\Mail\Plugin\Mail\PhpMailTest::setUp()
  2. 10 core/tests/Drupal/Tests/Core/Mail/Plugin/Mail/PhpMailTest.php \Drupal\Tests\Core\Mail\Plugin\Mail\PhpMailTest::setUp()

Overrides UnitTestCase::setUp

File

core/tests/Drupal/Tests/Core/Mail/Plugin/Mail/PhpMailTest.php, line 44

Class

PhpMailTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Mail%21Plugin%21Mail%21PhpMail.php/class/PhpMail/11.x" title="Defines the default Drupal mail backend, using PHP&#039;s native mail() function." class="local">\Drupal\Core\Mail\Plugin\Mail\PhpMail</a> @group Mail

Namespace

Drupal\Tests\Core\Mail\Plugin\Mail

Code

protected function setUp() : void {
    parent::setUp();
    // Use the provided config for system.mail.interface settings.
    $this->configFactory = $this->getConfigFactoryStub([
        'system.mail' => [
            'interface' => [],
            'mailer_dsn' => [
                'scheme' => 'null',
                'host' => 'null',
                'user' => NULL,
                'password' => NULL,
                'port' => NULL,
                'options' => [],
            ],
        ],
        'system.site' => [
            'mail' => 'test@example.com',
        ],
    ]);
    $this->request = new Request();
    $this->requestStack = $this->prophesize(RequestStack::class);
    $this->requestStack
        ->getCurrentRequest()
        ->willReturn($this->request);
    $container = new ContainerBuilder();
    $container->set('config.factory', $this->configFactory);
    $container->set('request_stack', $this->requestStack
        ->reveal());
    \Drupal::setContainer($container);
}

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