ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilRTEBaseTestCase.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 
30 abstract class ilRTEBaseTestCase extends TestCase
31 {
32  protected function setUp(): void
33  {
34  $GLOBALS['DIC'] = new Container();
35  $this->setMocks();
36 
37  parent::setUp();
38  }
39 
44  protected function setGlobalVariable(string $name, $value): void
45  {
46  global $DIC;
47 
48  $GLOBALS[$name] = $value;
49 
50  unset($DIC[$name]);
51  $DIC[$name] = static function ($c) use ($name) {
52  return $GLOBALS[$name];
53  };
54  }
55 
56  protected function setMocks(): void
57  {
58  $tpl_mock = $this->createMock(ilGlobalTemplateInterface::class);
59  $this->setGlobalVariable('tpl', $tpl_mock);
60 
61  $lng = $this
62  ->getMockBuilder(ilLanguage::class)
63  ->disableOriginalConstructor()
64  ->onlyMethods(['txt', 'getInstalledLanguages', 'loadLanguageModule'])
65  ->getMock();
66  $this->setGlobalVariable('lng', $lng);
67 
68  $this->setGlobalVariable(
69  'ilCtrl',
70  $this->getMockBuilder(ilCtrlInterface::class)->disableOriginalConstructor()->getMock()
71  );
72 
73  $this->setGlobalVariable(
74  'ilClientIniFile',
75  $this->getMockBuilder(ilIniFile::class)->disableOriginalConstructor()->getMock()
76  );
77 
78  $this->setGlobalVariable(
79  'ilUser',
80  $this->getMockBuilder(ilObjUser::class)->disableOriginalConstructor()->getMock()
81  );
82 
83  $http = $this
84  ->getMockBuilder(HttpServiceImpl::class)
85  ->disableOriginalConstructor()
86  ->onlyMethods(['agent'])
87  ->getMock();
88  $http
89  ->method('agent')
90  ->willReturn(new AgentDetermination());
91  $this->setGlobalVariable('http', $http);
92  }
93 }
This library is borrowed from the phpGroupWare API http://www.phpgroupware.org/api Modifications made...
Class ilRTEBaseTestCase.
$http
Definition: deliver.php:30
$c
Definition: deliver.php:25
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
$GLOBALS["DIC"]
Definition: wac.php:53
global $DIC
Definition: shib_login.php:22
setGlobalVariable(string $name, $value)
global $lng
Definition: privfeed.php:31