◆ createDBFunctionCalls()
ilNotificationOSDTest::createDBFunctionCalls |
( |
int |
$insert = 0 , |
|
|
int |
$queryF = 0 , |
|
|
int |
$fetchAssoc = 0 , |
|
|
int |
$manipulateF = 0 |
|
) |
| |
|
private |
Definition at line 34 of file ilNotificationOSDTest.php.
References $i, ILIAS\LTI\ToolProvider\$key, and $query.
Referenced by testCreateNotification(), testGet0Notification(), testGetNotification(), testRemoveNoNotification(), and testRemoveNotification().
38 $this->db->expects(self::exactly($insert))->method(
'nextId')->willReturnCallback(
function (
string $table):
int {
39 return count($this->database) + 1;
41 $this->db->expects(self::exactly($insert))->method(
'insert')->willReturnCallback(
function (
string $table, array $object):
int {
42 foreach ($object as &$value) {
46 $this->database[] = $object;
47 return $object[
'notification_osd_id'];
49 $this->db->expects(self::exactly($queryF))->method(
'queryF')->willReturnCallback(
function (
string $query, array $types, array $values):
ilPDOStatement {
51 if (strpos($query,
'WHERE usr_id') !==
false) {
52 foreach ($this->database as $row) {
53 if ($row[
'usr_id'] === $values[0]) {
54 $this->result[] = $row;
58 if (strpos($query,
'WHERE notification_osd_id') !==
false) {
59 foreach ($this->database as $row) {
60 if ($row[
'notification_osd_id'] === $values[0]) {
61 $this->result[] = $row;
65 if (strpos($query,
'SELECT count(*) AS count') !==
false) {
66 $this->result = [0 => [
'count' => count($this->result)]];
68 return $this->createMock(ilPDOStatement::class);
70 $this->db->expects(self::exactly($fetchAssoc))->method(
'fetchAssoc')->willReturnCallback(
function (
ilPDOStatement $rset): ?array {
71 return array_shift($this->result);
73 $this->db->expects(self::exactly($manipulateF))->method(
'manipulateF')->willReturnCallback(
function (
string $query, array $types, array $values):
int {
74 if (count($values) === 1) {
75 foreach ($this->database as
$key => $row) {
76 if ($row[
'notification_osd_id'] === $values[0]) {
77 unset($this->database[
$key]);
82 if (count($values) === 2) {
84 foreach ($this->database as
$key => $row) {
85 if ($row[
'usr_id'] === $values[0] && $row[
'type'] === $values[1]) {
86 unset($this->database[
$key]);
Class ilPDOStatement is a Wrapper Class for PDOStatement.
◆ setUp()
ilNotificationOSDTest::setUp |
( |
| ) |
|
|
protected |
Definition at line 96 of file ilNotificationOSDTest.php.
References ILIAS\Repository\user().
98 $this->db = $this->createMock(ilDBPdo::class);
99 $this->handler = new \ILIAS\Notifications\ilNotificationOSDHandler(
100 new ILIAS\Notifications\Repository\ilNotificationOSDRepository($this->db)
102 $this->
user = $this->createMock(ilObjUser::class);
103 $this->
user->method(
'getId')->willReturn(4);
Class ChatMainBarProvider .
◆ testCreateNotification()
ilNotificationOSDTest::testCreateNotification |
( |
| ) |
|
Definition at line 106 of file ilNotificationOSDTest.php.
References $config, createDBFunctionCalls(), and ILIAS\Repository\user().
109 $config = new \ILIAS\Notifications\Model\ilNotificationConfig(
'test_type');
110 $config->setTitleVar(
'Test Notification');
111 $config->setShortDescriptionVar(
'This is a test notification');
112 $test_obj = new \ILIAS\Notifications\Model\ilNotificationObject(
$config, $this->
user);
113 $this->handler->notify($test_obj);
115 $this->assertCount(1, $this->database);
createDBFunctionCalls(int $insert=0, int $queryF=0, int $fetchAssoc=0, int $manipulateF=0)
◆ testGet0Notification()
ilNotificationOSDTest::testGet0Notification |
( |
| ) |
|
Definition at line 118 of file ilNotificationOSDTest.php.
References createDBFunctionCalls().
121 $this->assertCount(0, $this->handler->getOSDNotificationsForUser($this->user->getId()));
createDBFunctionCalls(int $insert=0, int $queryF=0, int $fetchAssoc=0, int $manipulateF=0)
◆ testGetNotification()
ilNotificationOSDTest::testGetNotification |
( |
| ) |
|
Definition at line 124 of file ilNotificationOSDTest.php.
References $config, createDBFunctionCalls(), and ILIAS\Repository\user().
127 $config = new \ILIAS\Notifications\Model\ilNotificationConfig(
'test_type');
128 $test_obj = new \ILIAS\Notifications\Model\ilNotificationObject(
$config, $this->
user);
129 $this->handler->notify($test_obj);
131 $this->assertCount(1, $this->handler->getOSDNotificationsForUser($this->user->getId()));
createDBFunctionCalls(int $insert=0, int $queryF=0, int $fetchAssoc=0, int $manipulateF=0)
◆ testRemoveNoNotification()
ilNotificationOSDTest::testRemoveNoNotification |
( |
| ) |
|
Definition at line 148 of file ilNotificationOSDTest.php.
References createDBFunctionCalls().
151 $this->assertCount(0, $this->handler->getOSDNotificationsForUser($this->user->getId()));
152 $this->assertFalse($this->handler->removeOSDNotification(3));
createDBFunctionCalls(int $insert=0, int $queryF=0, int $fetchAssoc=0, int $manipulateF=0)
◆ testRemoveNotification()
ilNotificationOSDTest::testRemoveNotification |
( |
| ) |
|
Definition at line 134 of file ilNotificationOSDTest.php.
References $config, createDBFunctionCalls(), and ILIAS\Repository\user().
137 $config = new \ILIAS\Notifications\Model\ilNotificationConfig(
'test_type');
138 $test_obj = new \ILIAS\Notifications\Model\ilNotificationObject(
$config, $this->
user);
139 $this->handler->notify($test_obj);
141 $notifications = $this->handler->getOSDNotificationsForUser($this->
user->getId());
143 $this->assertCount(1, $notifications);
144 $this->assertTrue($this->handler->removeOSDNotification($notifications[0]->getId()));
145 $this->assertCount(0, $this->handler->getOSDNotificationsForUser($this->user->getId()));
createDBFunctionCalls(int $insert=0, int $queryF=0, int $fetchAssoc=0, int $manipulateF=0)
◆ $database
array ilNotificationOSDTest::$database |
|
private |
◆ $db
◆ $handler
ILIAS Notifications ilNotificationOSDHandler ilNotificationOSDTest::$handler |
|
private |
◆ $result
array ilNotificationOSDTest::$result |
|
private |
◆ $user
The documentation for this class was generated from the following file: