public function SMTPConfigFormTest::setup in SMTP Authentication Support 8
Test setup.
File
- tests/
src/ Unit/ SMTPConfigFormTest.php, line 29
Class
- SMTPConfigFormTest
- Validate requirements for SMTPConfigForm.
Namespace
Drupal\Tests\smtp\UnitCode
public function setup() {
$this->mockConfigFactory = $this
->prophesize(ConfigFactoryInterface::class);
$this->mockConfig = $this
->prophesize(Config::class);
$this->mockConfigFactory
->get('smtp.settings')
->willReturn($this->mockConfig
->reveal());
$this->mockConfigFactory
->getEditable('smtp.settings')
->willReturn($this->mockConfig
->reveal());
$this->mockConfigSystemSite = $this
->prophesize(Config::class);
$this->mockConfigSystemSite
->get('name')
->willReturn('Site name');
$this->mockConfigFactory
->get('system.site')
->willReturn($this->mockConfigSystemSite
->reveal());
$this->mockMessenger = $this
->prophesize(Messenger::class);
$this->mockEmailValidator = $this
->prophesize(EmailValidatorInterface::class);
$this->mockCurrentUser = $this
->prophesize(AccountProxyInterface::class);
$this->mockMailManager = $this
->prophesize(MailManagerInterface::class);
$this->mockModuleHandler = $this
->prophesize(ModuleHandlerInterface::class);
$mockContainer = $this->mockContainer = $this
->prophesize(ContainerInterface::class);
$mockContainer
->get('config.factory')
->willReturn($this->mockConfigFactory
->reveal());
$mockContainer
->get('messenger')
->willReturn($this->mockMessenger
->reveal());
$mockContainer
->get('email.validator')
->willReturn($this->mockEmailValidator
->reveal());
$mockContainer
->get('current_user')
->willReturn($this->mockCurrentUser
->reveal());
$mockContainer
->get('plugin.manager.mail')
->willReturn($this->mockMailManager
->reveal());
$mockContainer
->get('module_handler')
->willReturn($this->mockModuleHandler
->reveal());
$mockStringTranslation = $this
->prophesize(TranslationInterface::class);
$mockStringTranslation
->translate(Argument::any())
->willReturnArgument(0);
$mockStringTranslation
->translate(Argument::any(), Argument::any())
->willReturnArgument(0);
$mockStringTranslation
->translateString(Argument::any())
->willReturn('.');
$mockContainer
->get('string_translation')
->willReturn($mockStringTranslation
->reveal());
\Drupal::setContainer($this->mockContainer
->reveal());
}