Esempio n. 1
0
 /**
  * @dataProvider dataProviderTestMailer
  */
 public function testMailer($injectOpenSpy, $injectLinksSpy, $inputFile, $expectedHtmlFile, $expectedPlainFile)
 {
     $input = file_get_contents($inputFile);
     $expectedHtml = file_get_contents($expectedHtmlFile);
     $expectedPlain = file_get_contents($expectedPlainFile);
     $this->mockNewsletter->method('getValidatedContent')->will($this->returnValue(array('content' => $input, 'errors' => array(), 'warnings' => array(), 'infos' => array())));
     $this->mockNewsletter->method('getInjectOpenSpy')->will($this->returnValue($injectOpenSpy));
     $this->mockNewsletter->method('getInjectLinksSpy')->will($this->returnValue($injectLinksSpy));
     $mailer = $this->objectManager->get('Ecodev\\Newsletter\\Mailer');
     $mailer->setNewsletter($this->mockNewsletter);
     $mailer->prepare($this->mockEmail, true);
     $actualHtml = $mailer->getHtml();
     $actualPlain = $mailer->getPlain();
     $this->assertEquals($expectedHtml, $actualHtml);
     $this->assertEquals($expectedPlain, $actualPlain);
 }
Esempio n. 2
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###');
     }
 }
Esempio n. 3
0
 /**
  * @dataProvider dataProviderTestMailer
  */
 public function testMailer($injectOpenSpy, $injectLinksSpy, $inputFile, $expectedHtmlFile, $expectedPlainFile)
 {
     $input = file_get_contents($inputFile);
     $expectedHtml = file_get_contents($expectedHtmlFile);
     $expectedPlain = file_get_contents($expectedPlainFile);
     $this->mockNewsletter->method('getValidatedContent')->will($this->returnValue(array('content' => $input, 'errors' => array(), 'warnings' => array(), 'infos' => array())));
     $this->mockNewsletter->method('getInjectOpenSpy')->will($this->returnValue($injectOpenSpy));
     $this->mockNewsletter->method('getInjectLinksSpy')->will($this->returnValue($injectLinksSpy));
     $mailer = $this->objectManager->get('Ecodev\\Newsletter\\Mailer');
     $mailer->setNewsletter($this->mockNewsletter);
     $mailer->prepare($this->mockEmail);
     $actualHtml = $mailer->getHtml();
     $actualPlain = $mailer->getPlain();
     $this->assertSame($expectedHtml, $actualHtml);
     $this->assertSame($expectedPlain, $actualPlain);
     if ($injectLinksSpy) {
         $this->assertLinkWasCreated('http://www.example.com');
         $this->assertLinkWasCreated('http://###my_custom_field###');
         $this->assertLinkWasCreated('http://www.example.com?param=###my_custom_field###');
     }
 }