Exemple #1
0
 /**
  * @dataProvider dataProviderTestMailer
  */
 public function testMailer($pid, $injectOpenSpy, $injectLinksSpy, $inputFile, $expectedEmailFile)
 {
     $input = file_get_contents($inputFile);
     $expectedEmail = file_get_contents($expectedEmailFile);
     $this->mockNewsletter->method('getValidatedContent')->will($this->returnValue(['content' => $input, 'errors' => [], 'warnings' => [], 'infos' => []]));
     $this->mockNewsletter->method('getInjectOpenSpy')->will($this->returnValue($injectOpenSpy));
     $this->mockNewsletter->method('getInjectLinksSpy')->will($this->returnValue($injectLinksSpy));
     $this->mockNewsletter->method('getPid')->will($this->returnValue($pid));
     $this->mockEmail->method('getPid')->will($this->returnValue($pid));
     $mailer = $this->objectManager->get(\Ecodev\Newsletter\Mailer::class);
     $mailer->setNewsletter($this->mockNewsletter);
     $mailer->prepare($this->mockEmail);
     $message = $mailer->createMessage($this->mockEmail);
     $actualEmail = $message->toString();
     $this->assertSame($this->unrandomizeEmail($expectedEmail), $this->unrandomizeEmail($actualEmail));
     if ($injectLinksSpy) {
         $this->assertLinkWasCreated('http://www.example.com');
         $this->assertLinkWasCreated('http://###my_custom_field###');
         $this->assertLinkWasCreated('http://www.example.com?param=###my_custom_field###');
     }
 }