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