You are here

protected function FilterSpamspanUnitTest::setUp in SpamSpan filter 8.2

Same name and namespace in other branches
  1. 8 tests/src/Kernel/FilterSpamspanUnitTest.php \Drupal\Tests\spamspan\Kernel\FilterSpamspanUnitTest::setUp()

Overrides KernelTestBase::setUp

File

tests/src/Kernel/FilterSpamspanUnitTest.php, line 60

Class

FilterSpamspanUnitTest
Tests spamspan filter.

Namespace

Drupal\Tests\spamspan\Kernel

Code

protected function setUp() : void {
  parent::setUp();
  $this
    ->installConfig([
    'system',
  ]);
  $manager = $this->container
    ->get('plugin.manager.filter');
  $bag = new FilterPluginCollection($manager, []);
  $filters = $bag
    ->getAll();
  $this->spamspanFilter = $filters['filter_spamspan'];
  $configuration = $this->spamspanFilter
    ->getConfiguration();
  $configuration['settings'] = [
    'spamspan_parse_dom' => $this->withDom,
  ] + $configuration['settings'];
  $this->spamspanFilter
    ->setConfiguration($configuration);

  // Spamspan filter that is set to use contact form.
  $configuration['settings'] = [
    'spamspan_use_form' => 1,
  ] + $configuration['settings'];
  $this->spamspanFilterForm = $manager
    ->createInstance('filter_spamspan', $configuration);

  // Spamspan filter that is set to use graphic at and dot enabled.
  $configuration['settings'] = [
    'spamspan_use_form' => 0,
    'spamspan_use_graphic' => 1,
    'spamspan_dot_enable' => 1,
  ] + $configuration['settings'];
  $this->spamspanFilterAtDot = $manager
    ->createInstance('filter_spamspan', $configuration);

  // Read the test image from the file provided.
  $this->base64Image = file_get_contents(drupal_get_path('module', 'spamspan') . '/tests/src/Kernel/base64image.txt');
}