ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilMathJaxTest Class Reference

Testing the MathJax class. More...

+ Inheritance diagram for ilMathJaxTest:
+ Collaboration diagram for ilMathJaxTest:

Public Member Functions

 testInstanceCanBeCreated ()
 
 testClientSideRendering (int $limiter, string $input, ?string $start, ?string $end, string $expected)
 testInstanceCanBeCreated clientSideData More...
 
 testServerSideRendering (string $purpose, ?string $imagefile, string $expected)
 testInstanceCanBeCreated serverSideData More...
 

Static Public Member Functions

static clientSideData ()
 
static serverSideData ()
 

Additional Inherited Members

- Protected Member Functions inherited from ilMathJaxBaseTestCase
 getEmptyConfig ()
 Get a config without active settings. More...
 
 getFactoryMock (?string $imagefile=null)
 Get a factory mockup that will deliver other mockups. More...
 
 getTemplateMock ()
 Get a global template mockup. More...
 
 getImageMock (string $imagefile)
 Get a cached image mockup from an example file. More...
 
 getServerMock ()
 Get a mockup of the class for server calls. More...
 

Detailed Description

Testing the MathJax class.

Definition at line 24 of file ilMathJaxTest.php.

Member Function Documentation

◆ clientSideData()

static ilMathJaxTest::clientSideData ( )
static

Definition at line 45 of file ilMathJaxTest.php.

References null.

45  : array
46  {
47  return [
48  [0, '[tex]e=m*c^2[/tex]', null, null, '\(e=m*c^2\)'],
49  [1, '[tex]e=m*c^2[/tex]', null, null, '[tex]e=m*c^2[/tex]'],
50  [2, '[tex]e=m*c^2[/tex]', null, null, '<span class="math">e=m*c^2</span>'],
51  [1, '<span class="math">e=m*c^2</span>', '<span class="math">', '</span>', '[tex]e=m*c^2[/tex]'],
52  [0, '[tex]e=m*c^2[/tex][tex]e=m*c^2[/tex]', null, null, '\(e=m*c^2\)\(e=m*c^2\)'],
53  // char beween
54  [0, '[tex]e=m*c^2[/tex]#[tex]e=m*c^2[/tex]', null, null, '\(e=m*c^2\)#\(e=m*c^2\)'],
55  [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  // multibyte char
58  [0, '[tex]e=m*c^2[/tex]♥[tex]e=m*c^2[/tex]', null, null, '\(e=m*c^2\)♥\(e=m*c^2\)'],
59  [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  // start ignored until end is found
62  [0, '[tex]e=m*c^2[tex]e=m*c^2[/tex]', null, null, '\(e=m*c^2[tex]e=m*c^2\)'],
63  // whole expression ignored if no end is found
64  [0, '[tex]e=m*c^2[/tex][tex]e=m*c^2', null, null, '\(e=m*c^2\)[tex]e=m*c^2'],
65  ];
66  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ serverSideData()

static ilMathJaxTest::serverSideData ( )
static

Definition at line 88 of file ilMathJaxTest.php.

References null.

88  : array
89  {
90  return [
91  ['browser', 'example.svg', '<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="17.47'],
92  ['export', 'example.svg', '<img src="data:image/svg+xml;base64,PHN2ZyB4bWxuczp4bGluaz0i'],
93  ['pdf', 'example.png', '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYA'],
94  ['deferred_pdf', null, '[tex]f(x)=\int_{-\infty}^x e^{-t^2}dt[/tex]']
95  ];
96  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ testClientSideRendering()

ilMathJaxTest::testClientSideRendering ( int  $limiter,
string  $input,
?string  $start,
?string  $end,
string  $expected 
)

testInstanceCanBeCreated clientSideData

Definition at line 37 of file ilMathJaxTest.php.

References ilMathJaxBaseTestCase\getEmptyConfig(), ilMathJaxBaseTestCase\getFactoryMock(), and ilMathJax\getIndependent().

37  : void
38  {
39  $config = $this->getEmptyConfig()->withClientEnabled(true)->withClientLimiter($limiter);
40  $mathjax = ilMathJax::getIndependent($config, $this->getFactoryMock());
41  $result = $mathjax->insertLatexImages($input, $start, $end);
42  $this->assertEquals($expected, $result, 'input: ' . $input);
43  }
getFactoryMock(?string $imagefile=null)
Get a factory mockup that will deliver other mockups.
getEmptyConfig()
Get a config without active settings.
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...
+ Here is the call graph for this function:

◆ testInstanceCanBeCreated()

ilMathJaxTest::testInstanceCanBeCreated ( )

Definition at line 26 of file ilMathJaxTest.php.

References ilMathJaxBaseTestCase\getEmptyConfig(), ilMathJaxBaseTestCase\getFactoryMock(), and ilMathJax\getIndependent().

26  : void
27  {
28  $config = $this->getEmptyConfig();
29  $mathjax = ilMathJax::getIndependent($this->getEmptyConfig(), $this->getFactoryMock());
30  $this->assertInstanceOf('ilMathJax', $mathjax);
31  }
getFactoryMock(?string $imagefile=null)
Get a factory mockup that will deliver other mockups.
getEmptyConfig()
Get a config without active settings.
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...
+ Here is the call graph for this function:

◆ testServerSideRendering()

ilMathJaxTest::testServerSideRendering ( string  $purpose,
?string  $imagefile,
string  $expected 
)

testInstanceCanBeCreated serverSideData

Definition at line 72 of file ilMathJaxTest.php.

References ilMathJaxBaseTestCase\getEmptyConfig(), ilMathJaxBaseTestCase\getFactoryMock(), and ilMathJax\getIndependent().

72  : void
73  {
74  $input = '[tex]f(x)=\int_{-\infty}^x e^{-t^2}dt[/tex]';
75 
76  $config = $this->getEmptyConfig()
77  ->withServerEnabled(true)
78  ->withServerForBrowser($purpose == 'browser')
79  ->withServerForExport($purpose == 'export')
80  ->withServerForPdf($purpose == 'pdf');
81 
82  $mathjax = ilMathJax::getIndependent($config, $this->getFactoryMock($imagefile))->init($purpose);
83  $result = $mathjax->insertLatexImages($input);
84  $head = substr($result, 0, 60);
85  $this->assertEquals($expected, $head, 'purpose: ' . $purpose);
86  }
getFactoryMock(?string $imagefile=null)
Get a factory mockup that will deliver other mockups.
getEmptyConfig()
Get a config without active settings.
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...
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: