public function testRetrieve() { $userId = 'abc'; $identifier = 'foo'; $this->crypto->expects($this->once())->method('decrypt')->with('baz')->willReturn(json_encode('bar')); $qb = $this->getMockBuilder('\\OC\\DB\\QueryBuilder\\QueryBuilder')->setConstructorArgs([$this->dbConnection])->setMethods(['execute'])->getMock(); $qb->expects($this->once())->method('execute')->willReturn($this->getQeuryResult(['credentials' => 'baz'])); $this->dbConnection->expects($this->once())->method('getQueryBuilder')->willReturn($qb); $this->manager->retrieve($userId, $identifier); }