ILIAS  release_8 Revision v8.24
class.ilChatroomAbstractTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22use PHPUnit\Framework\TestCase;
23use PHPUnit\Framework\MockObject\MockObject;
24
29abstract class ilChatroomAbstractTest extends TestCase
30{
32 protected $ilChatroomMock;
35 private ?Container $dic = null;
36
37 protected function setUp(): void
38 {
39 global $DIC;
40
41 $this->dic = is_object($DIC) ? clone $DIC : $DIC;
42
43 $DIC = new Container();
44
45 $this->setGlobalVariable(
46 'tpl',
47 $this->getMockBuilder(ilGlobalTemplateInterface::class)->getMock()
48 );
49
50 parent::setUp();
51 }
52
53 protected function tearDown(): void
54 {
55 global $DIC;
56
58
59 parent::tearDown();
60 }
61
65 protected function createIlChatroomMock(): ilChatroom
66 {
67 $this->ilChatroomMock = $this->getMockBuilder(ilChatroom::class)->disableOriginalConstructor()->onlyMethods(
68 ['isOwnerOfPrivateRoom', 'clearMessages']
69 )->getMock();
70
72 }
73
78 {
79 $this->ilChatroomUserMock = $this->getMockBuilder(ilChatroomUser::class)->disableOriginalConstructor()->onlyMethods(
80 ['getUserId', 'getUsername']
81 )->getMock();
82
84 }
85
89 protected function createGlobalIlDBMock(): ilDBInterface
90 {
91 $db = $this->getMockBuilder(ilDBInterface::class)->getMock();
92 $db->method('quote')->willReturnCallback(static function ($arg): string {
93 return "'" . $arg . "'";
94 });
95
96 $this->setGlobalVariable('ilDB', $db);
97
98 return $db;
99 }
100
101 protected function setGlobalVariable(string $name, $value): void
102 {
103 global $DIC;
104
105 $GLOBALS[$name] = $value;
106
107 $DIC[$name] = static function (Container $c) use ($name) {
108 return $GLOBALS[$name];
109 };
110 }
111}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:32
Class ilChatroomAbstractTest.
setGlobalVariable(string $name, $value)
Class ilChatroomUser.
Class ilChatroom.
$c
Definition: cli.php:38
global $DIC
Definition: feed.php:28
Interface ilDBInterface.
if($format !==null) $name
Definition: metadata.php:247