function PhpMailTest::setUp

Same name 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 \Drupal\Core\Mail\Plugin\Mail\PhpMail @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.