ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilMailBaseTestCase.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22use PHPUnit\Framework\TestCase;
24
25abstract class ilMailBaseTestCase extends TestCase
26{
27 private ?Container $dic = null;
28
29 protected function brutallyTrimHTML(string $html): string
30 {
31 $html = str_replace(["\n", "\r", "\t"], '', $html);
32 $html = preg_replace('# {2,}#', ' ', $html);
33 $html = preg_replace('/<!--(.|\s)*?-->/', '', $html);
34 $html = preg_replace("/>(\s+)</", '><', $html);
35 $html = str_replace([' >', ' <'], ['>', '<'], $html);
36
37 return trim($html);
38 }
39
40 protected function setUp(): void
41 {
42 if (!defined('ANONYMOUS_USER_ID')) {
43 define('ANONYMOUS_USER_ID', 13);
44 }
45
46 global $DIC;
47
48 $this->dic = is_object($DIC) ? clone $DIC : $DIC;
49
50 $DIC = new Container();
51 $DIC['legalDocuments'] = fn() => $this->getMockBuilder(Conductor::class)->disableOriginalConstructor()->getMock();
52
53 parent::setUp();
54 }
55
56 protected function tearDown(): void
57 {
58 global $DIC;
59
61
62 parent::tearDown();
63 }
64
65 protected function setGlobalVariable(string $name, $value): void
66 {
67 global $DIC;
68
69 $GLOBALS[$name] = $value;
70
71
72 unset($DIC[$name]);
73 $DIC[$name] = static fn(Container $c) => $GLOBALS[$name];
74 }
75}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
brutallyTrimHTML(string $html)
setGlobalVariable(string $name, $value)
$c
Definition: deliver.php:25
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54