ILIAS  release_8 Revision v8.24
NotificationTest.php
Go to the documentation of this file.
1<?php
2
3use PHPUnit\Framework\TestCase;
4
10class NotificationTest extends TestCase
11{
12 protected function setGlobalVariable(string $name, $value): void
13 {
14 global $DIC;
15
16 $GLOBALS[$name] = $value;
17
18 unset($DIC[$name]);
19 $DIC[$name] = static function (\ILIAS\DI\Container $c) use ($value) {
20 return $value;
21 };
22 }
23
24 protected function setUp(): void
25 {
26 parent::setUp();
28 $GLOBALS['DIC'] = $dic;
29 }
30
31 protected function tearDown(): void
32 {
33 }
34
35 protected function initDBMock(): \PHPUnit\Framework\MockObject\MockObject
36 {
37 $db_mock = $this->createMock(ilDBInterface::class);
38 $this->setGlobalVariable(
39 "ilDB",
40 $db_mock
41 );
42 return $db_mock;
43 }
44
45 public function testRemoveForUser(): void
46 {
47 $db_mock = $this->initDBMock();
48 $db_mock->expects($this->once())
49 ->method('query')
50 ->with($this->stringContains('DELETE FROM notification WHERE user_id ='));
51
53 }
54}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:32
Test clipboard repository.
setGlobalVariable(string $name, $value)
static removeForUser(int $user_id)
Remove all notifications for given user.
$c
Definition: cli.php:38
global $DIC
Definition: feed.php:28
if($format !==null) $name
Definition: metadata.php:247
$dic
Definition: result.php:32