FooterAnalyzerKernelTest.php in Mailhandler 8
File
tests/src/Kernel/FooterAnalyzerKernelTest.php
View source
<?php
namespace Drupal\Tests\mailhandler\Kernel;
use Drupal\inmail\DefaultAnalyzerResult;
use Drupal\inmail\Entity\AnalyzerConfig;
use Drupal\inmail\ProcessorResult;
class FooterAnalyzerKernelTest extends AnalyzerTestBase {
public function setUp() {
parent::setUp();
}
public function testFooterAnalyzer() {
$raw_message = $this
->getFileContent('eml/Plain.eml');
$message = $this->parser
->parseMessage($raw_message);
$result = new ProcessorResult();
$footer_analyzer = AnalyzerConfig::load('footer');
$analyzer = $this->analyzerManager
->createInstance($footer_analyzer
->getPluginId(), $footer_analyzer
->getConfiguration());
$analyzer
->analyze($message, $result);
$result = $result
->getAnalyzerResult();
$expected_processed_body = 'Hello, Drupal!';
$expected_footer = <<<EOF
Milos Bovan
milos@example.com
EOF;
$this
->assertEquals($expected_processed_body, $result
->getBody());
$this
->assertEquals($expected_footer, $result
->getFooter());
$signed_mail = $this
->getFileContent('eml/PGP_Signed_Inline.eml');
$message = $this->parser
->parseMessage($signed_mail);
$result = new ProcessorResult();
$analyzer = $this->analyzerManager
->createInstance($footer_analyzer
->getPluginId(), $footer_analyzer
->getConfiguration());
$analyzer
->analyze($message, $result);
$result = $result
->getAnalyzerResult();
$this
->assertEquals(NULL, $result
->getBody());
$this
->assertEquals(NULL, $result
->getFooter());
}
}