ILIAS  release_8 Revision v8.24
ilMailBaseTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22use PHPUnit\Framework\TestCase;
23
28abstract class ilMailBaseTest extends TestCase
29{
30 private ?Container $dic = null;
31
32 protected function brutallyTrimHTML(string $html): string
33 {
34 $html = str_replace(["\n", "\r", "\t"], "", $html);
35 $html = preg_replace('# {2,}#', " ", $html);
36 $html = preg_replace('/<!--(.|\s)*?-->/', '', $html);
37 $html = preg_replace("/>(\s+)</", "><", $html);
38 $html = str_replace([" >", " <"], [">", "<"], $html);
39
40 return trim($html);
41 }
42
43 protected function setUp(): void
44 {
45 if (!defined('ANONYMOUS_USER_ID')) {
46 define('ANONYMOUS_USER_ID', 13);
47 }
48
49 global $DIC;
50
51 $this->dic = is_object($DIC) ? clone $DIC : $DIC;
52
53 $DIC = new Container();
54
55 parent::setUp();
56 }
57
58 protected function tearDown(): void
59 {
60 global $DIC;
61
63
64 parent::tearDown();
65 }
66
67 protected function setGlobalVariable(string $name, $value): void
68 {
69 global $DIC;
70
71 $GLOBALS[$name] = $value;
72
73
74 unset($DIC[$name]);
75 $DIC[$name] = static function (Container $c) use ($name) {
76 return $GLOBALS[$name];
77 };
78 }
79}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:32
Class ilMailBaseTest.
brutallyTrimHTML(string $html)
setGlobalVariable(string $name, $value)
$c
Definition: cli.php:38
global $DIC
Definition: feed.php:28
if($format !==null) $name
Definition: metadata.php:247