makePartial(); $this->assertSame('mock-to', $template->getTo()); $this->assertSame('mock-locale', $template->getLocale()); $this->assertInstanceOf(MailerInterface::class, $template->getMailer()); $this->assertInstanceOf(Component::class, $template->getRenderer()); } public function testCreateMessage() { /** @var TemplateBuilder|\Mockery\MockInterface $templateBuilder */ $templateBuilder = mock(TemplateBuilder::class)->makePartial(); $templateBuilder->shouldReceive('render')->andReturn('mock-html'); /** @var Component|\Mockery\MockInterface $renderer */ $renderer = mock(Component::class)->makePartial(); $renderer->shouldReceive('getTemplate')->with('mock-template')->andReturn($templateBuilder); /** @var TemplateWithRenderer|\Mockery\MockInterface $template */ $template = mock(TemplateWithRenderer::class, [['to@ely.by' => 'To'], 'mock-locale']); $template->makePartial(); $template->shouldReceive('getEmailRenderer')->andReturn($renderer); $template->shouldReceive('getFrom')->andReturn(['from@ely.by' => 'From']); $template->shouldReceive('getSubject')->andReturn('mock-subject'); $template->shouldReceive('getTemplateName')->andReturn('mock-template'); /** @var \yii\swiftmailer\Message $message */ $message = $this->callProtected($template, 'createMessage'); $this->assertInstanceOf(MessageInterface::class, $message); $this->assertSame(['to@ely.by' => 'To'], $message->getTo()); $this->assertSame(['from@ely.by' => 'From'], $message->getFrom()); $this->assertSame('mock-subject', $message->getSubject()); $this->assertSame('mock-html', $message->getSwiftMessage()->getBody()); } }