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