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