db = OC::$server->getDatabaseConnection(); $mapper = new RestrictionMapper($this->db); $this->service = new RestrictionService($mapper); $this->groupId = $this->getRandomString(); } public function testCreate() { $restriction = $this->service->create($this->groupId); $this->assertEquals($this->groupId, $restriction->getGroupId()); $this->service->delete($restriction->getId()); } /** * @depends testCreate */ public function testExistsByGroupId() { $restriction = $this->service->create($this->groupId); $this->assertTrue($this->service->existsByGroupId($this->groupId)); $this->assertFalse($this->service->existsByGroupId($this->getRandomString())); $this->service->delete($restriction->getId()); $this->assertFalse($this->service->existsByGroupId($this->groupId)); } /** * @depends testCreate */ public function testUpdate() { $restriction = $this->service->create($this->groupId); $updatedRestriction = $this->service->update( $restriction->getId(), $this->groupId, 10, ['public'], 15, false ); $this->assertEquals(10, $updatedRestriction->getMaxRooms()); $this->assertEquals(15, $updatedRestriction->getMaxParticipants()); $this->assertEquals(false, $updatedRestriction->getAllowRecording()); $this->service->delete($restriction->getId()); } private function getRandomString(): string { return \OC::$server->getSecureRandom()->generate(18, \OCP\Security\ISecureRandom::CHAR_HUMAN_READABLE); } }