ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilTermsOfServiceBaseTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
5 
11 {
15  protected $dic;
16 
20  protected function setUp()
21  {
22  $this->dic = new Container();
23  $GLOBALS['DIC'] = $this->dic;
24 
25  $initRefl = new \ReflectionClass(\ilInitialisation::class);
26  $method = $initRefl->getMethod('initUIFramework');
27  $method->setAccessible(true);
28  $method->invoke($initRefl, $this->dic);
29 
30  $this->setGlobalVariable('lng', $this->getLanguageMock());
31  $this->setGlobalVariable('ilCtrl', $this->getMockBuilder(\ilCtrl::class)->disableOriginalConstructor()->getMock());
32 
33  parent::setUp();
34  }
35 
39  protected function getLanguageMock() : \ilLanguage
40  {
41  $lng = $this
42  ->getMockBuilder(\ilLanguage::class)
43  ->disableOriginalConstructor()
44  ->setMethods(['txt', 'getInstalledLanguages', 'loadLanguageModule'])
45  ->getMock();
46 
47  return $lng;
48  }
49 
54  protected function setGlobalVariable(string $name, $value)
55  {
56  global $DIC;
57 
58  $GLOBALS[$name] = $value;
59 
60  unset($DIC[$name]);
61  $DIC[$name] = function ($c) use ($name) {
62  return $GLOBALS[$name];
63  };
64  }
65 
69  protected function assertException(string $exceptionClass)
70  {
71  if (version_compare(\PHPUnit_Runner_Version::id(), '5.0', '>=')) {
72  $this->setExpectedException($exceptionClass);
73  }
74  }
75 
80  protected function getCriterionConfig($value = null) : \ilTermsOfServiceCriterionConfig
81  {
82  if (null === $value) {
83  return new \ilTermsOfServiceCriterionConfig();
84  }
85 
86  return new \ilTermsOfServiceCriterionConfig($value);
87  }
88 }
setGlobalVariable(string $name, $value)
global $DIC
Definition: saml.php:7
assertException(string $exceptionClass)
Class ilTermsOfServiceCriterionConfig.
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:16
Class ilTermsOfServiceBaseTest.
$lng
language handling
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.