/** * @test */ public function it_sets_locale() { $viewFactory = Mockery::mock(ViewFactory::class); $filesystem = Mockery::mock(Filesystem::class); $translator = Mockery::mock(Translator::class); $message = new Message(new Swift_Message(), $viewFactory, $filesystem, $translator); $message->setView('view'); $message->setCss('cssPath'); $message->setLocale('es'); $translator->shouldReceive('getLocale')->andReturn('en'); $translator->shouldReceive('setLocale')->once()->with('es'); $translator->shouldReceive('setLocale')->once()->with('en'); $viewFactory->shouldReceive('make')->with('view', [])->andReturn($viewFactory); $viewFactory->shouldReceive('render')->andReturn('<h1>Hola</h1>'); $filesystem->shouldReceive('get')->with(base_path('cssPath'))->andReturn('h1 { color: blue; }'); $html = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html><body><h1 style="color: blue;">Hola</h1></body></html> '; $this->assertEquals($html, $message->getBody()); }
/** * Return the HTML representation of the email to be sent. * * @return string */ public function show() { return $this->message->getBody(); }