ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilMailBaseTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
28 abstract 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 
62  $DIC = $this->dic;
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 }
$c
Definition: cli.php:38
brutallyTrimHTML(string $html)
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:31
global $DIC
Definition: feed.php:28
Class ilMailBaseTest.
if($format !==null) $name
Definition: metadata.php:247
setGlobalVariable(string $name, $value)
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64