Files
deck/tests/unit/Db/BoardTest.php
dependabot[bot] ba3e97b73d Chore(deps-dev): Bump nextcloud/coding-standard from 1.2.1 to 1.2.3
Bumps [nextcloud/coding-standard](https://github.com/nextcloud/coding-standard) from 1.2.1 to 1.2.3.
- [Release notes](https://github.com/nextcloud/coding-standard/releases)
- [Changelog](https://github.com/nextcloud/coding-standard/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nextcloud/coding-standard/compare/v1.2.1...v1.2.3)

---
updated-dependencies:
- dependency-name: nextcloud/coding-standard
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-26 08:14:42 +02:00

116 lines
2.6 KiB
PHP

<?php
namespace OCA\Deck\Db;
use PHPUnit\Framework\TestCase;
class BoardTest extends TestCase {
private function createBoard() {
$board = new Board();
$board->setId(1);
$board->setTitle('My Board');
$board->setOwner('admin');
$board->setColor('000000');
$board->setArchived(false);
// TODO: relation shared labels acl
return $board;
}
public function testJsonSerialize() {
$board = $this->createBoard();
$board->setUsers(['user1', 'user2']);
$this->assertEquals([
'id' => 1,
'title' => 'My Board',
'owner' => 'admin',
'color' => '000000',
'labels' => [],
'permissions' => [],
'stacks' => [],
'deletedAt' => 0,
'lastModified' => 0,
'acl' => [],
'archived' => false,
'users' => ['user1', 'user2'],
'settings' => [],
'activeSessions' => [],
'ETag' => $board->getETag(),
], $board->jsonSerialize());
}
public function testUnfetchedValues() {
$board = $this->createBoard();
$board->setUsers(['user1', 'user2']);
self::assertNull($board->getAcl());
self::assertNull($board->getLabels());
$this->assertEquals([
'id' => 1,
'title' => 'My Board',
'owner' => 'admin',
'color' => '000000',
'labels' => [],
'permissions' => [],
'stacks' => [],
'deletedAt' => 0,
'lastModified' => 0,
'acl' => [],
'archived' => false,
'users' => ['user1', 'user2'],
'settings' => [],
'activeSessions' => [],
'ETag' => $board->getETag(),
], $board->jsonSerialize());
}
public function testSetLabels() {
$board = $this->createBoard();
$board->setLabels(['foo', 'bar']);
$this->assertEquals([
'id' => 1,
'title' => 'My Board',
'owner' => 'admin',
'color' => '000000',
'labels' => ['foo', 'bar'],
'permissions' => [],
'stacks' => [],
'deletedAt' => 0,
'lastModified' => 0,
'acl' => [],
'archived' => false,
'users' => [],
'settings' => [],
'activeSessions' => [],
'ETag' => $board->getETag(),
], $board->jsonSerialize());
}
public function testSetAcl() {
$acl = new Acl();
$acl->setId(1);
$board = $this->createBoard();
$board->setAcl([$acl]);
$result = $board->getAcl()[0];
$this->assertEquals($acl, $result);
}
public function testSetShared() {
$board = $this->createBoard();
$board->setShared(1);
$this->assertEquals([
'id' => 1,
'title' => 'My Board',
'owner' => 'admin',
'color' => '000000',
'labels' => [],
'permissions' => [],
'stacks' => [],
'deletedAt' => 0,
'lastModified' => 0,
'acl' => [],
'archived' => false,
'shared' => 1,
'users' => [],
'settings' => [],
'activeSessions' => [],
'ETag' => $board->getETag(),
], $board->jsonSerialize());
}
}