19 declare(strict_types=1);
21 require_once __DIR__ .
'/ilMathJaxBaseTest.php';
32 $this->assertInstanceOf(
'ilMathJax', $mathjax);
39 public function testClientSideRendering(
int $limiter,
string $input, ?
string $start, ?
string $end,
string $expected): void
43 $result = $mathjax->insertLatexImages($input, $start, $end);
44 $this->assertEquals($expected, $result,
'input: ' . $input);
50 [0,
'[tex]e=m*c^2[/tex]', null, null,
'\(e=m*c^2\)'],
51 [1,
'[tex]e=m*c^2[/tex]', null, null,
'[tex]e=m*c^2[/tex]'],
52 [2,
'[tex]e=m*c^2[/tex]', null, null,
'<span class="math">e=m*c^2</span>'],
53 [1,
'<span class="math">e=m*c^2</span>',
'<span class="math">',
'</span>',
'[tex]e=m*c^2[/tex]'],
54 [0,
'[tex]e=m*c^2[/tex][tex]e=m*c^2[/tex]', null, null,
'\(e=m*c^2\)\(e=m*c^2\)'],
56 [0,
'[tex]e=m*c^2[/tex]#[tex]e=m*c^2[/tex]', null, null,
'\(e=m*c^2\)#\(e=m*c^2\)'],
57 [0,
'#[tex]e=m*c^2[/tex]#[tex]e=m*c^2[/tex]', null, null,
'#\(e=m*c^2\)#\(e=m*c^2\)'],
58 [0,
'#[tex]e=m*c^2[/tex]#[tex]e=m*c^2[/tex]#', null, null,
'#\(e=m*c^2\)#\(e=m*c^2\)#'],
60 [0,
'[tex]e=m*c^2[/tex]♥[tex]e=m*c^2[/tex]', null, null,
'\(e=m*c^2\)♥\(e=m*c^2\)'],
61 [0,
'♥[tex]e=m*c^2[/tex]♥[tex]e=m*c^2[/tex]', null, null,
'♥\(e=m*c^2\)♥\(e=m*c^2\)'],
62 [0,
'♥[tex]e=m*c^2[/tex]♥[tex]e=m*c^2[/tex]♥', null, null,
'♥\(e=m*c^2\)♥\(e=m*c^2\)♥'],
64 [0,
'[tex]e=m*c^2[tex]e=m*c^2[/tex]', null, null,
'\(e=m*c^2[tex]e=m*c^2\)'],
66 [0,
'[tex]e=m*c^2[/tex][tex]e=m*c^2', null, null,
'\(e=m*c^2\)[tex]e=m*c^2'],
76 $input =
'[tex]f(x)=\int_{-\infty}^x e^{-t^2}dt[/tex]';
79 ->withServerEnabled(
true)
80 ->withServerForBrowser($purpose ==
'browser')
81 ->withServerForExport($purpose ==
'export')
82 ->withServerForPdf($purpose ==
'pdf');
85 $result = $mathjax->insertLatexImages($input);
86 $head = substr($result, 0, 60);
87 $this->assertEquals($expected, $head,
'purpose: ' . $purpose);
93 [
'browser',
'example.svg',
'<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="17.47'],
94 [
'export',
'example.svg',
'<img src="data:image/svg+xml;base64,PHN2ZyB4bWxuczp4bGluaz0i'],
95 [
'pdf',
'example.png',
'<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYA'],
96 [
'deferred_pdf', null,
'[tex]f(x)=\int_{-\infty}^x e^{-t^2}dt[/tex]']
testClientSideRendering(int $limiter, string $input, ?string $start, ?string $end, string $expected)
testInstanceCanBeCreated clientSideData
testServerSideRendering(string $purpose, ?string $imagefile, string $expected)
testInstanceCanBeCreated serverSideData
testInstanceCanBeCreated()
getEmptyConfig()
Get a config without active settings.
Testing the MathJax class.
getFactoryMock(?string $imagefile=null)
Get a factory mockup that will deliver other mockups.
static getIndependent(ilMathJaxConfig $config, ilMathJaxFactory $factory)
Get an independent instance with a specific config for use in unit tests or on the mathjax settings p...