ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilMathJaxBaseTestCase.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 abstract class ilMathJaxBaseTestCase extends TestCase
27 {
31  protected function getEmptyConfig(): ilMathJaxConfig
32  {
33  return new ilMathJaxConfig(
34  false,
35  '',
36  '',
37  0,
38  false,
39  '',
40  0,
41  false,
42  false,
43  false
44  );
45  }
46 
50  protected function getFactoryMock(?string $imagefile = null): ilMathJaxFactory
51  {
52  $factory = $this
53  ->getMockBuilder(ilMathJaxFactory::class)
54  ->disableOriginalConstructor()
55  ->onlyMethods(['template', 'image', 'server'])
56  ->getMock();
57  $factory->method('template')->willReturn($this->getTemplateMock());
58  $factory->method('server')->willReturn($this->getServerMock());
59  if (isset($imagefile)) {
60  $factory->method('image')->willReturn($this->getImageMock($imagefile));
61  }
62  return $factory;
63  }
64 
68  protected function getTemplateMock(): ilGlobalTemplate
69  {
70  $template = $this
71  ->getMockBuilder(ilGlobalTemplate::class)
72  ->disableOriginalConstructor()
73  ->onlyMethods(['addJavaScript'])
74  ->getMock();
75  return $template;
76  }
77 
82  protected function getImageMock(string $imagefile): ilMathJaxImage
83  {
84  $image = $this
85  ->getMockBuilder(ilMathJaxImage::class)
86  ->disableOriginalConstructor()
87  ->onlyMethods(['exists', 'read', 'write', 'absolutePath', 'getCacheSize'])
88  ->getMock();
89  $image->method('exists')->willReturn(false);
90  $image->method('read')->willReturn(file_get_contents(__DIR__ . '/' . $imagefile));
91  $image->method('absolutePath')->willReturn(__DIR__ . '/' . $imagefile);
92  $image->method('getCacheSize')->willReturn('10 KB');
93  return $image;
94  }
95 
99  protected function getServerMock(): ilMathJaxServer
100  {
101  $server = $this
102  ->getMockBuilder(ilMathJaxServer::class)
103  ->disableOriginalConstructor()
104  ->onlyMethods(['call'])
105  ->getMock();
106  $server->method('call')->willReturn('server call result');
107  return $server;
108  }
109 }
getTemplateMock()
Get a global template mockup.
getImageMock(string $imagefile)
Get a cached image mockup from an example file.
getFactoryMock(?string $imagefile=null)
Get a factory mockup that will deliver other mockups.
Rendered MathJax image Supports image types SVG or PNG Files are stored in the web file system of ili...
special template class to simplify handling of ITX/PEAR
Factory for objects used by ilMathJax.
getEmptyConfig()
Get a config without active settings.
Global Mathjax configuration.
getServerMock()
Get a mockup of the class for server calls.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Class for calling theMathJax server The server calls use cURL, if the extension is loaded...
Base class for al tests.
$server
Definition: shib_login.php:24