ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
NotificationTest.php
Go to the documentation of this file.
1<?php
2
19use PHPUnit\Framework\TestCase;
20
26class NotificationTest extends TestCase
27{
28 protected function setGlobalVariable(string $name, $value): void
29 {
30 global $DIC;
31
32 $GLOBALS[$name] = $value;
33
34 unset($DIC[$name]);
35 $DIC[$name] = static function (\ILIAS\DI\Container $c) use ($value) {
36 return $value;
37 };
38 }
39
40 protected function setUp(): void
41 {
42 parent::setUp();
44 $GLOBALS['DIC'] = $dic;
45 }
46
47 protected function tearDown(): void
48 {
49 }
50
51 protected function initDBMock(): \PHPUnit\Framework\MockObject\MockObject
52 {
53 $db_mock = $this->createMock(ilDBInterface::class);
54 $this->setGlobalVariable(
55 "ilDB",
56 $db_mock
57 );
58 return $db_mock;
59 }
60
61 public function testRemoveForUser(): void
62 {
63 $db_mock = $this->initDBMock();
64 $db_mock->expects($this->once())
65 ->method('query')
66 ->with($this->stringContains('DELETE FROM notification WHERE user_id ='));
67
69 }
70}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
Test clipboard repository.
setGlobalVariable(string $name, $value)
static removeForUser(int $user_id)
Remove all notifications for given user.
$c
Definition: deliver.php:25
$dic
Definition: ltiresult.php:33
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54