ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilTermsOfServiceBaseTest.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
5use PHPUnit\Framework\MockObject\MockObject;
6use PHPUnit\Framework\TestCase;
7
12abstract class ilTermsOfServiceBaseTest extends TestCase
13{
15 protected $dic;
16
21 protected function setUp() : void
22 {
23 $this->dic = new Container();
24 $GLOBALS['DIC'] = $this->dic;
25
26 $this->setGlobalVariable('lng', $this->getLanguageMock());
27 $this->setGlobalVariable(
28 'ilCtrl',
29 $this->getMockBuilder(ilCtrl::class)->disableOriginalConstructor()->getMock()
30 );
31
32 parent::setUp();
33 }
34
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
53 protected function getUiFactoryMock() : \ILIAS\UI\Factory
54 {
55 $ui = $this
56 ->getMockBuilder(\ILIAS\UI\Factory::class)
57 ->getMock();
58
59 $ui->expects($this->any())->method('legacy')->will($this->returnCallback(function ($content) {
60 $legacyMock = $this
61 ->getMockBuilder(\ILIAS\UI\Component\Legacy\Legacy::class)
62 ->getMock();
63 $legacyMock->expects($this->any())->method('getContent')->willReturn($content);
64
65 return $legacyMock;
66 }));
67
68 return $ui;
69 }
70
75 protected function setGlobalVariable(string $name, $value) : void
76 {
77 global $DIC;
78
79 $GLOBALS[$name] = $value;
80
81 unset($DIC[$name]);
82 $DIC[$name] = function ($c) use ($name) {
83 return $GLOBALS[$name];
84 };
85 }
86
91 protected function getCriterionConfig($value = null) : ilTermsOfServiceCriterionConfig
92 {
93 if (null === $value) {
95 }
96
97 return new ilTermsOfServiceCriterionConfig($value);
98 }
99}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:18
language handling
Class ilTermsOfServiceBaseTest.
setGlobalVariable(string $name, $value)
Class ilTermsOfServiceCriterionConfig.
if($format !==null) $name
Definition: metadata.php:230
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.
$lng
$DIC
Definition: xapitoken.php:46