getDatabaseConnection(); $db->insertIfNotExist('*PREFIX*dav_shares', [ 'principaluri' => 'principal:unknown', 'type' => 'calendar', 'access' => 2, 'resourceid' => 666, ]); } public function test(): void { $db = \OC::$server->getDatabaseConnection(); /** @var Principal | \PHPUnit\Framework\MockObject\MockObject $principal */ $principal = $this->createMock(Principal::class); /** @var IOutput | \PHPUnit\Framework\MockObject\MockObject $output */ $output = $this->createMock(IOutput::class); $repair = new RemoveInvalidShares($db, $principal); $this->invokePrivate($repair, 'run', [$this->createMock(InputInterface::class), $this->createMock(OutputInterface::class)]); $query = $db->getQueryBuilder(); $result = $query->select('*')->from('dav_shares') ->where($query->expr()->eq('principaluri', $query->createNamedParameter('principal:unknown')))->execute(); $data = $result->fetchAll(); $result->closeCursor(); $this->assertEquals(0, count($data)); } }