You are here

public function GeshiFieldTest::setUp in GeSHi Filter for syntax highlighting 8

Same name and namespace in other branches
  1. 8.2 geshifield/tests/src/Functional/GeshiFieldTest.php \Drupal\Tests\geshifield\Functional\GeshiFieldTest::setUp()

Code run before each and every test method.

Overrides BrowserTestBase::setUp

File

geshifield/tests/src/Functional/GeshiFieldTest.php, line 50

Class

GeshiFieldTest
Tests for GeshiField in node content.

Namespace

Drupal\Tests\geshifield\Functional

Code

public function setUp() {
  parent::setUp();

  // Create object with configuration.
  $this->config = \Drupal::configFactory()
    ->getEditable('geshifilter.settings');

  // And set the path to the geshi library.
  $this->config
    ->set('geshi_dir', '/libraries/geshi');

  // Create a content type, as we will create nodes on test.
  $settings = [
    // Override default type (a random name).
    'type' => 'geshifilter_content_type',
    'name' => 'Geshifilter Content',
  ];
  $this
    ->drupalCreateContentType($settings);
  $this->adminUser = $this
    ->drupalCreateUser([], NULL, TRUE);

  // Log in with filter admin user.
  $this
    ->drupalLogin($this->adminUser);

  // Add an text format with only geshi filter.
  $this
    ->createTextFormat('geshifilter_text_format', [
    'filter_geshifilter',
  ]);

  // Set some default GeSHi filter admin settings.
  // Set default highlighting mode to "do nothing".
  $this->config
    ->set('default_highlighting', GeshiFilter::DEFAULT_PLAINTEXT);
  $this->config
    ->set('use_format_specific_options', FALSE);
  $this->config
    ->set('tag_styles', [
    GeshiFilter::BRACKETS_ANGLE => GeshiFilter::BRACKETS_ANGLE,
    GeshiFilter::BRACKETS_SQUARE => GeshiFilter::BRACKETS_SQUARE,
  ]);
  $this->config
    ->set('default_line_numbering', GeshiFilter::LINE_NUMBERS_DEFAULT_NONE);
  $this->config
    ->save();
}