-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathRestrictionServiceTest.php
More file actions
79 lines (59 loc) · 1.98 KB
/
RestrictionServiceTest.php
File metadata and controls
79 lines (59 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
namespace OCA\BigBlueButton\Tests\Integration\Service;
use OC;
use OCA\BigBlueButton\Db\RestrictionMapper;
use OCA\BigBlueButton\Service\RestrictionService;
use OCP\IDBConnection;
use PHPUnit\Framework\TestCase;
class RestrictionServiceTest extends TestCase {
/** @var IDBConnection */
private $db;
/** @var RestrictionService */
private $service;
/** @var string */
private $groupId;
public function setUp(): void {
parent::setUp();
$this->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->assertEqauls(false, $updatedRestriction->getAllowLogoutURL());
$this->service->delete($restriction->getId());
}
private function getRandomString(): string {
return \OC::$server->getSecureRandom()->generate(18, \OCP\Security\ISecureRandom::CHAR_HUMAN_READABLE);
}
}