37 : void {
39 $this->result = [];
40 $this->db->expects(self::exactly($insert))->method('nextId')->willReturnCallback(function (string $table): int {
42 });
43 $this->db->expects(self::exactly($insert))->method('insert')->willReturnCallback(
44 function (string $table, array $object): int {
45 foreach ($object as &$value) {
46 $value = $value[1];
47 }
48 unset($value);
50 return $object['notification_osd_id'];
51 }
52 );
53 $this->db->expects(self::exactly($queryF))->method('queryF')->willReturnCallback(
54 function (
string $query, array $types, array $values):
ilPDOStatement {
55 $this->result = [];
56 if (str_contains($query, 'WHERE usr_id')) {
58 if ($row['usr_id'] === $values[0]) {
59 $this->result[] = $row;
60 }
61 }
62 }
63 if (str_contains($query, 'WHERE notification_osd_id')) {
65 if ($row['notification_osd_id'] === $values[0]) {
66 $this->result[] = $row;
67 }
68 }
69 }
70 if (str_contains($query, 'SELECT count(*) AS count')) {
71 $this->result = [0 => ['count' => count($this->result)]];
72 }
73 return $this->createMock(ilPDOStatement::class);
74 }
75 );
76 $this->db->expects(self::exactly($fetchAssoc))->method('fetchAssoc')->willReturnCallback(
78 return array_shift($this->result);
79 }
80 );
81 $this->db->expects(self::exactly($manipulateF))->method('manipulateF')->willReturnCallback(
82 function (string $query, array $types, array $values): int {
83 if (count($values) === 1) {
84 foreach ($this->
database as $key => $row) {
85 if ($row['notification_osd_id'] === $values[0]) {
87 return 1;
88 }
89 }
90 }
91 if (count($values) === 2) {
92 $i = 0;
93 foreach ($this->
database as $key => $row) {
94 if ($row['usr_id'] === $values[0] && $row['type'] === $values[1]) {
96 $i++;
97 }
98 }
99 return $i;
100 }
101 return 0;
102 }
103 );
104 }
Class ilPDOStatement is a Wrapper Class for PDOStatement.