34                                                                                                                       : void
   35    {
   36        $this->database = [];
   37        $this->result = [];
   38        $this->db->expects(self::exactly($insert))->method('nextId')->willReturnCallback(function (string $table): int {
   39            return count($this->database) + 1;
   40        });
   41        $this->db->expects(self::exactly($insert))->method('insert')->willReturnCallback(function (string $table, array $object): int {
   42            foreach ($object as &$value) {
   43                $value = $value[1];
   44            }
   45            unset($value);
   46            $this->database[] = $object;
   47            return $object['notification_osd_id'];
   48        });
   49        $this->db->expects(self::exactly($queryF))->method(
'queryF')->willReturnCallback(
function (
string $query, array $types, array $values): 
ilPDOStatement {
 
   50            $this->result = [];
   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;
   55                    }
   56                }
   57            }
   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;
   62                    }
   63                }
   64            }
   65            if (strpos(
$query, 
'SELECT count(*) AS count') !== 
false) {
 
   66                $this->result = [0 => ['count' => count($this->result)]];
   67            }
   68            return $this->createMock(ilPDOStatement::class);
   69        });
   70        $this->db->expects(self::exactly($fetchAssoc))->method(
'fetchAssoc')->willReturnCallback(
function (
ilPDOStatement $rset): ?array {
 
   71            return array_shift($this->result);
   72        });
   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]);
 
   78                        return 1;
   79                    }
   80                }
   81            }
   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]);
 
   88                    }
   89                }
   91            }
   92            return 0;
   93        });
   94    }
Class ilPDOStatement is a Wrapper Class for PDOStatement.