You are here

public function MathjaxWebTest::testAdmin in MathJax: LaTeX for Drupal 8.2

Test the administration functions.

File

src/Tests/MathjaxWebTest.php, line 58

Class

MathjaxWebTest
Configuration test case for the module.

Namespace

Drupal\mathjax\Tests

Code

public function testAdmin() {
  $config = Drupal::config('mathjax.settings');
  $this
    ->drupalLogin($this->administrator);
  $this
    ->drupalGet('admin/config');
  $this
    ->assertText('Configure global settings for MathJax.');
  $this
    ->drupalGet('admin/config/content/formats/add');
  $this
    ->assertText('Mathematics inside the configured delimiters is rendered by MathJax');
  $this
    ->drupalGet('admin/config/content/mathjax');
  $this
    ->assertTitle('MathJax | Drupal', 'Page title set.');
  $this
    ->assertText('MathJax CDN URL');
  $this
    ->assertFieldByName('cdn_url', $config
    ->get('cdn_url'), 'Default CDN config string found.');
  $this
    ->assertText('Enter the Mathjax CDN url here or leave it unchanged to use the one provided by www.mathjax.org.');
  $this
    ->assertText('Configuration Type');
  $this
    ->assertFieldByName('config_type', 0);
  $custom = '{"tex2jax":{"inlineMath":[["#","#"],["\\(","\\)"]],"processEscapes":"true"},"showProcessingMessages":"false","messageStyle":"none"}';
  $path = 'admin/config/content/mathjax';
  $edit = array(
    'config_type' => 1,
    'config_string' => $custom,
  );
  $this
    ->drupalPostForm($path, $edit, t('Save configuration'));
  $this
    ->assertText('Enter a JSON configuration string as documented');
  $this
    ->assertRaw(htmlentities($custom), 'Custom configuration string found.');
}