mirror of https://github.com/sualko/cloud_bbb
test: add RestrictionService test
parent
9e9784564e
commit
46ac4d1102
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\BigBlueButton\Tests\Integration\Service;
|
||||
|
||||
use OC;
|
||||
use OCA\BigBlueButton\Db\RestrictionMapper;
|
||||
use OCA\BigBlueButton\Service\RestrictionService;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use OCP\IDBConnection;
|
||||
|
||||
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->service->delete($restriction->getId());
|
||||
}
|
||||
|
||||
|
||||
private function getRandomString(): string {
|
||||
return \OC::$server->getSecureRandom()->generate(18, \OCP\Security\ISecureRandom::CHAR_HUMAN_READABLE);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue