2017-03-31 19:27:59 +00:00
|
|
|
<?php
|
2017-11-17 01:23:18 +00:00
|
|
|
/** @license MIT
|
|
|
|
* Copyright 2017 J. King, Dustin Wilson et al.
|
|
|
|
* See LICENSE and AUTHORS files for details */
|
|
|
|
|
2017-03-31 19:27:59 +00:00
|
|
|
declare(strict_types=1);
|
2018-11-23 15:01:17 +00:00
|
|
|
namespace JKingWeb\Arsse\TestCase\Database;
|
2017-08-29 14:50:31 +00:00
|
|
|
|
2017-07-17 11:47:57 +00:00
|
|
|
use JKingWeb\Arsse\Arsse;
|
2017-03-31 19:27:59 +00:00
|
|
|
|
|
|
|
trait SeriesFolder {
|
2020-01-20 18:52:48 +00:00
|
|
|
protected function setUpSeriesFolder(): void {
|
2018-11-25 05:03:56 +00:00
|
|
|
$this->data = [
|
|
|
|
'arsse_users' => [
|
|
|
|
'columns' => [
|
|
|
|
'id' => 'str',
|
|
|
|
'password' => 'str',
|
2020-10-30 19:25:22 +00:00
|
|
|
'num' => 'int',
|
2018-11-25 05:03:56 +00:00
|
|
|
],
|
|
|
|
'rows' => [
|
2020-10-30 19:25:22 +00:00
|
|
|
["jane.doe@example.com", "",1],
|
|
|
|
["john.doe@example.com", "",2],
|
2018-11-25 05:03:56 +00:00
|
|
|
],
|
2017-06-18 16:24:19 +00:00
|
|
|
],
|
2018-11-25 05:03:56 +00:00
|
|
|
'arsse_folders' => [
|
|
|
|
'columns' => [
|
|
|
|
'id' => "int",
|
|
|
|
'owner' => "str",
|
|
|
|
'parent' => "int",
|
|
|
|
'name' => "str",
|
|
|
|
],
|
|
|
|
/* Layout translates to:
|
|
|
|
Jane
|
|
|
|
Politics
|
|
|
|
John
|
|
|
|
Technology
|
|
|
|
Software
|
|
|
|
Politics
|
|
|
|
Rocketry
|
|
|
|
Politics
|
|
|
|
*/
|
|
|
|
'rows' => [
|
|
|
|
[1, "john.doe@example.com", null, "Technology"],
|
|
|
|
[2, "john.doe@example.com", 1, "Software"],
|
|
|
|
[3, "john.doe@example.com", 1, "Rocketry"],
|
|
|
|
[4, "jane.doe@example.com", null, "Politics"],
|
|
|
|
[5, "john.doe@example.com", null, "Politics"],
|
|
|
|
[6, "john.doe@example.com", 2, "Politics"],
|
2020-03-01 20:16:50 +00:00
|
|
|
],
|
2017-06-18 16:24:19 +00:00
|
|
|
],
|
2019-03-06 00:22:01 +00:00
|
|
|
'arsse_feeds' => [
|
|
|
|
'columns' => [
|
|
|
|
'id' => "int",
|
|
|
|
'url' => "str",
|
|
|
|
'title' => "str",
|
|
|
|
],
|
|
|
|
'rows' => [
|
|
|
|
[1,"http://example.com/1", "Feed 1"],
|
|
|
|
[2,"http://example.com/2", "Feed 2"],
|
|
|
|
[3,"http://example.com/3", "Feed 3"],
|
|
|
|
[4,"http://example.com/4", "Feed 4"],
|
|
|
|
[5,"http://example.com/5", "Feed 5"],
|
|
|
|
[6,"http://example.com/6", "Feed 6"],
|
|
|
|
[7,"http://example.com/7", "Feed 7"],
|
|
|
|
[8,"http://example.com/8", "Feed 8"],
|
|
|
|
[9,"http://example.com/9", "Feed 9"],
|
|
|
|
[10,"http://example.com/10", "Feed 10"],
|
|
|
|
[11,"http://example.com/11", "Feed 11"],
|
|
|
|
[12,"http://example.com/12", "Feed 12"],
|
|
|
|
[13,"http://example.com/13", "Feed 13"],
|
2020-03-01 20:16:50 +00:00
|
|
|
],
|
2019-03-06 00:22:01 +00:00
|
|
|
],
|
|
|
|
'arsse_subscriptions' => [
|
|
|
|
'columns' => [
|
|
|
|
'id' => "int",
|
|
|
|
'owner' => "str",
|
|
|
|
'feed' => "int",
|
|
|
|
'folder' => "int",
|
|
|
|
],
|
|
|
|
'rows' => [
|
|
|
|
[1, "john.doe@example.com",1, null],
|
|
|
|
[2, "john.doe@example.com",2, null],
|
|
|
|
[3, "john.doe@example.com",3, 1],
|
|
|
|
[4, "john.doe@example.com",4, 6],
|
|
|
|
[5, "john.doe@example.com",5, 5],
|
|
|
|
[6, "john.doe@example.com",10, 5],
|
|
|
|
[7, "jane.doe@example.com",1, null],
|
|
|
|
[8, "jane.doe@example.com",10,null],
|
|
|
|
[9, "jane.doe@example.com",2, 4],
|
|
|
|
[10,"jane.doe@example.com",3, 4],
|
|
|
|
[11,"jane.doe@example.com",4, 4],
|
2020-03-01 20:16:50 +00:00
|
|
|
],
|
2019-03-06 00:22:01 +00:00
|
|
|
],
|
2018-11-25 05:03:56 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
protected function tearDownSeriesFolder(): void {
|
2018-11-25 05:03:56 +00:00
|
|
|
unset($this->data);
|
|
|
|
}
|
2017-03-31 19:27:59 +00:00
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testAddARootFolder(): void {
|
2017-03-31 19:27:59 +00:00
|
|
|
$user = "john.doe@example.com";
|
2017-05-11 01:21:23 +00:00
|
|
|
$folderID = $this->nextID("arsse_folders");
|
2017-07-17 11:47:57 +00:00
|
|
|
$this->assertSame($folderID, Arsse::$db->folderAdd($user, ['name' => "Entertainment"]));
|
2017-04-01 18:49:31 +00:00
|
|
|
$state = $this->primeExpectations($this->data, ['arsse_folders' => ['id','owner', 'parent', 'name']]);
|
2017-05-11 01:21:23 +00:00
|
|
|
$state['arsse_folders']['rows'][] = [$folderID, $user, null, "Entertainment"];
|
2019-06-21 22:52:27 +00:00
|
|
|
$this->compareExpectations(static::$drv, $state);
|
2017-03-31 19:27:59 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testAddADuplicateRootFolder(): void {
|
2017-03-31 19:27:59 +00:00
|
|
|
$this->assertException("constraintViolation", "Db", "ExceptionInput");
|
2017-07-17 11:47:57 +00:00
|
|
|
Arsse::$db->folderAdd("john.doe@example.com", ['name' => "Politics"]);
|
2017-03-31 19:27:59 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testAddANestedFolder(): void {
|
2017-03-31 19:27:59 +00:00
|
|
|
$user = "john.doe@example.com";
|
2017-05-11 01:21:23 +00:00
|
|
|
$folderID = $this->nextID("arsse_folders");
|
2017-07-17 11:47:57 +00:00
|
|
|
$this->assertSame($folderID, Arsse::$db->folderAdd($user, ['name' => "GNOME", 'parent' => 2]));
|
2017-04-01 18:49:31 +00:00
|
|
|
$state = $this->primeExpectations($this->data, ['arsse_folders' => ['id','owner', 'parent', 'name']]);
|
2017-05-11 01:21:23 +00:00
|
|
|
$state['arsse_folders']['rows'][] = [$folderID, $user, 2, "GNOME"];
|
2019-06-21 22:52:27 +00:00
|
|
|
$this->compareExpectations(static::$drv, $state);
|
2017-03-31 19:27:59 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testAddANestedFolderToAMissingParent(): void {
|
2017-03-31 19:27:59 +00:00
|
|
|
$this->assertException("idMissing", "Db", "ExceptionInput");
|
2017-07-17 11:47:57 +00:00
|
|
|
Arsse::$db->folderAdd("john.doe@example.com", ['name' => "Sociology", 'parent' => 2112]);
|
2017-03-31 19:27:59 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testAddANestedFolderToAnInvalidParent(): void {
|
2017-09-28 14:16:24 +00:00
|
|
|
$this->assertException("typeViolation", "Db", "ExceptionInput");
|
2017-09-26 20:45:41 +00:00
|
|
|
Arsse::$db->folderAdd("john.doe@example.com", ['name' => "Sociology", 'parent' => "stringFolderId"]);
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testAddANestedFolderForTheWrongOwner(): void {
|
2017-03-31 19:27:59 +00:00
|
|
|
$this->assertException("idMissing", "Db", "ExceptionInput");
|
2017-07-17 11:47:57 +00:00
|
|
|
Arsse::$db->folderAdd("john.doe@example.com", ['name' => "Sociology", 'parent' => 4]); // folder ID 4 belongs to Jane
|
2017-03-31 19:27:59 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testAddAFolderWithAMissingName(): void {
|
2017-03-31 19:27:59 +00:00
|
|
|
$this->assertException("missing", "Db", "ExceptionInput");
|
2017-07-17 11:47:57 +00:00
|
|
|
Arsse::$db->folderAdd("john.doe@example.com", []);
|
2017-03-31 19:27:59 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testAddAFolderWithABlankName(): void {
|
2017-03-31 19:27:59 +00:00
|
|
|
$this->assertException("missing", "Db", "ExceptionInput");
|
2017-07-17 11:47:57 +00:00
|
|
|
Arsse::$db->folderAdd("john.doe@example.com", ['name' => ""]);
|
2017-03-31 19:27:59 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testAddAFolderWithAWhitespaceName(): void {
|
2017-03-31 19:27:59 +00:00
|
|
|
$this->assertException("whitespace", "Db", "ExceptionInput");
|
2017-07-17 11:47:57 +00:00
|
|
|
Arsse::$db->folderAdd("john.doe@example.com", ['name' => " "]);
|
2017-03-31 19:27:59 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testListRootFolders(): void {
|
2017-03-31 21:42:28 +00:00
|
|
|
$exp = [
|
2019-03-06 00:22:01 +00:00
|
|
|
['id' => 5, 'name' => "Politics", 'parent' => null, 'children' => 0, 'feeds' => 2],
|
|
|
|
['id' => 1, 'name' => "Technology", 'parent' => null, 'children' => 2, 'feeds' => 1],
|
2017-03-31 21:42:28 +00:00
|
|
|
];
|
2017-10-07 16:46:05 +00:00
|
|
|
$this->assertResult($exp, Arsse::$db->folderList("john.doe@example.com", null, false));
|
2017-03-31 21:42:28 +00:00
|
|
|
$exp = [
|
2017-10-07 16:46:05 +00:00
|
|
|
['id' => 4, 'name' => "Politics", 'parent' => null, 'children' => 0],
|
2017-03-31 21:42:28 +00:00
|
|
|
];
|
2017-10-07 16:46:05 +00:00
|
|
|
$this->assertResult($exp, Arsse::$db->folderList("jane.doe@example.com", null, false));
|
2017-03-31 21:42:28 +00:00
|
|
|
$exp = [];
|
2017-10-07 16:46:05 +00:00
|
|
|
$this->assertResult($exp, Arsse::$db->folderList("admin@example.net", null, false));
|
2017-03-31 21:42:28 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testListFoldersRecursively(): void {
|
2017-03-31 21:42:28 +00:00
|
|
|
$exp = [
|
2019-03-06 00:22:01 +00:00
|
|
|
['id' => 5, 'name' => "Politics", 'parent' => null, 'children' => 0, 'feeds' => 2],
|
|
|
|
['id' => 6, 'name' => "Politics", 'parent' => 2, 'children' => 0, 'feeds' => 1],
|
|
|
|
['id' => 3, 'name' => "Rocketry", 'parent' => 1, 'children' => 0, 'feeds' => 0],
|
|
|
|
['id' => 2, 'name' => "Software", 'parent' => 1, 'children' => 1, 'feeds' => 0],
|
|
|
|
['id' => 1, 'name' => "Technology", 'parent' => null, 'children' => 2, 'feeds' => 1],
|
2017-03-31 21:42:28 +00:00
|
|
|
];
|
2017-10-07 16:46:05 +00:00
|
|
|
$this->assertResult($exp, Arsse::$db->folderList("john.doe@example.com", null, true));
|
2017-03-31 21:42:28 +00:00
|
|
|
$exp = [
|
2019-03-06 00:22:01 +00:00
|
|
|
['id' => 6, 'name' => "Politics", 'parent' => 2, 'children' => 0, 'feeds' => 1],
|
|
|
|
['id' => 3, 'name' => "Rocketry", 'parent' => 1, 'children' => 0, 'feeds' => 0],
|
|
|
|
['id' => 2, 'name' => "Software", 'parent' => 1, 'children' => 1, 'feeds' => 0],
|
2017-03-31 21:42:28 +00:00
|
|
|
];
|
2017-10-07 16:46:05 +00:00
|
|
|
$this->assertResult($exp, Arsse::$db->folderList("john.doe@example.com", 1, true));
|
2017-03-31 21:42:28 +00:00
|
|
|
$exp = [];
|
2017-10-07 16:46:05 +00:00
|
|
|
$this->assertResult($exp, Arsse::$db->folderList("jane.doe@example.com", 4, true));
|
2017-03-31 21:42:28 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testListFoldersOfAMissingParent(): void {
|
2017-03-31 21:42:28 +00:00
|
|
|
$this->assertException("idMissing", "Db", "ExceptionInput");
|
2017-07-17 11:47:57 +00:00
|
|
|
Arsse::$db->folderList("john.doe@example.com", 2112);
|
2017-03-31 21:42:28 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testListFoldersOfTheWrongOwner(): void {
|
2017-03-31 21:42:28 +00:00
|
|
|
$this->assertException("idMissing", "Db", "ExceptionInput");
|
2017-07-17 11:47:57 +00:00
|
|
|
Arsse::$db->folderList("john.doe@example.com", 4); // folder ID 4 belongs to Jane
|
2017-03-31 21:42:28 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testRemoveAFolder(): void {
|
2017-07-17 11:47:57 +00:00
|
|
|
$this->assertTrue(Arsse::$db->folderRemove("john.doe@example.com", 6));
|
2017-04-01 18:49:31 +00:00
|
|
|
$state = $this->primeExpectations($this->data, ['arsse_folders' => ['id','owner', 'parent', 'name']]);
|
2017-03-31 22:48:24 +00:00
|
|
|
array_pop($state['arsse_folders']['rows']);
|
2019-06-21 22:52:27 +00:00
|
|
|
$this->compareExpectations(static::$drv, $state);
|
2017-03-31 22:48:24 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testRemoveAFolderTree(): void {
|
2017-07-17 11:47:57 +00:00
|
|
|
$this->assertTrue(Arsse::$db->folderRemove("john.doe@example.com", 1));
|
2017-04-01 18:49:31 +00:00
|
|
|
$state = $this->primeExpectations($this->data, ['arsse_folders' => ['id','owner', 'parent', 'name']]);
|
2017-08-29 14:50:31 +00:00
|
|
|
foreach ([0,1,2,5] as $index) {
|
2017-03-31 22:48:24 +00:00
|
|
|
unset($state['arsse_folders']['rows'][$index]);
|
|
|
|
}
|
2019-06-21 22:52:27 +00:00
|
|
|
$this->compareExpectations(static::$drv, $state);
|
2017-03-31 22:48:24 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testRemoveAMissingFolder(): void {
|
2017-05-21 14:10:36 +00:00
|
|
|
$this->assertException("subjectMissing", "Db", "ExceptionInput");
|
2017-07-17 11:47:57 +00:00
|
|
|
Arsse::$db->folderRemove("john.doe@example.com", 2112);
|
2017-03-31 22:48:24 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testRemoveAnInvalidFolder(): void {
|
2017-09-28 14:16:24 +00:00
|
|
|
$this->assertException("typeViolation", "Db", "ExceptionInput");
|
|
|
|
Arsse::$db->folderRemove("john.doe@example.com", -1);
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testRemoveAFolderOfTheWrongOwner(): void {
|
2017-05-21 14:10:36 +00:00
|
|
|
$this->assertException("subjectMissing", "Db", "ExceptionInput");
|
2017-07-17 11:47:57 +00:00
|
|
|
Arsse::$db->folderRemove("john.doe@example.com", 4); // folder ID 4 belongs to Jane
|
2017-03-31 22:48:24 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testGetThePropertiesOfAFolder(): void {
|
2017-04-01 14:27:26 +00:00
|
|
|
$exp = [
|
|
|
|
'id' => 6,
|
|
|
|
'name' => "Politics",
|
|
|
|
'parent' => 2,
|
|
|
|
];
|
2017-07-17 11:47:57 +00:00
|
|
|
$this->assertArraySubset($exp, Arsse::$db->folderPropertiesGet("john.doe@example.com", 6));
|
2017-04-01 14:27:26 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testGetThePropertiesOfAMissingFolder(): void {
|
2017-05-21 14:10:36 +00:00
|
|
|
$this->assertException("subjectMissing", "Db", "ExceptionInput");
|
2017-07-17 11:47:57 +00:00
|
|
|
Arsse::$db->folderPropertiesGet("john.doe@example.com", 2112);
|
2017-04-01 14:27:26 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testGetThePropertiesOfAnInvalidFolder(): void {
|
2017-09-28 14:16:24 +00:00
|
|
|
$this->assertException("typeViolation", "Db", "ExceptionInput");
|
|
|
|
Arsse::$db->folderPropertiesGet("john.doe@example.com", -1);
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testGetThePropertiesOfAFolderOfTheWrongOwner(): void {
|
2017-05-21 14:10:36 +00:00
|
|
|
$this->assertException("subjectMissing", "Db", "ExceptionInput");
|
2017-07-17 11:47:57 +00:00
|
|
|
Arsse::$db->folderPropertiesGet("john.doe@example.com", 4); // folder ID 4 belongs to Jane
|
2017-04-01 14:27:26 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testMakeNoChangesToAFolder(): void {
|
2017-09-26 20:45:41 +00:00
|
|
|
$this->assertFalse(Arsse::$db->folderPropertiesSet("john.doe@example.com", 6, []));
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testRenameAFolder(): void {
|
2017-07-17 11:47:57 +00:00
|
|
|
$this->assertTrue(Arsse::$db->folderPropertiesSet("john.doe@example.com", 6, ['name' => "Opinion"]));
|
2017-04-01 18:49:31 +00:00
|
|
|
$state = $this->primeExpectations($this->data, ['arsse_folders' => ['id','owner', 'parent', 'name']]);
|
|
|
|
$state['arsse_folders']['rows'][5][3] = "Opinion";
|
2019-06-21 22:52:27 +00:00
|
|
|
$this->compareExpectations(static::$drv, $state);
|
2017-04-01 14:27:26 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testRenameTheRootFolder(): void {
|
2017-09-28 14:16:24 +00:00
|
|
|
$this->assertFalse(Arsse::$db->folderPropertiesSet("john.doe@example.com", null, ['name' => "Opinion"]));
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testRenameAFolderToTheEmptyString(): void {
|
2017-07-23 03:08:08 +00:00
|
|
|
$this->assertException("missing", "Db", "ExceptionInput");
|
|
|
|
$this->assertTrue(Arsse::$db->folderPropertiesSet("john.doe@example.com", 6, ['name' => ""]));
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testRenameAFolderToWhitespaceOnly(): void {
|
2017-07-23 03:08:08 +00:00
|
|
|
$this->assertException("whitespace", "Db", "ExceptionInput");
|
|
|
|
$this->assertTrue(Arsse::$db->folderPropertiesSet("john.doe@example.com", 6, ['name' => " "]));
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testRenameAFolderToAnInvalidValue(): void {
|
2017-09-26 20:45:41 +00:00
|
|
|
$this->assertException("typeViolation", "Db", "ExceptionInput");
|
|
|
|
$this->assertTrue(Arsse::$db->folderPropertiesSet("john.doe@example.com", 6, ['name' => []]));
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testMoveAFolder(): void {
|
2017-07-17 11:47:57 +00:00
|
|
|
$this->assertTrue(Arsse::$db->folderPropertiesSet("john.doe@example.com", 6, ['parent' => 5]));
|
2017-04-01 18:49:31 +00:00
|
|
|
$state = $this->primeExpectations($this->data, ['arsse_folders' => ['id','owner', 'parent', 'name']]);
|
2017-04-01 14:27:26 +00:00
|
|
|
$state['arsse_folders']['rows'][5][2] = 5; // parent should have changed
|
2019-06-21 22:52:27 +00:00
|
|
|
$this->compareExpectations(static::$drv, $state);
|
2017-04-01 14:27:26 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testMoveTheRootFolder(): void {
|
2017-09-26 20:45:41 +00:00
|
|
|
$this->assertException("circularDependence", "Db", "ExceptionInput");
|
|
|
|
Arsse::$db->folderPropertiesSet("john.doe@example.com", 0, ['parent' => 1]);
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testMoveAFolderToItsDescendant(): void {
|
2017-04-01 14:27:26 +00:00
|
|
|
$this->assertException("circularDependence", "Db", "ExceptionInput");
|
2017-07-17 11:47:57 +00:00
|
|
|
Arsse::$db->folderPropertiesSet("john.doe@example.com", 1, ['parent' => 3]);
|
2017-04-01 14:27:26 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testMoveAFolderToItself(): void {
|
2017-04-01 14:27:26 +00:00
|
|
|
$this->assertException("circularDependence", "Db", "ExceptionInput");
|
2017-07-17 11:47:57 +00:00
|
|
|
Arsse::$db->folderPropertiesSet("john.doe@example.com", 1, ['parent' => 1]);
|
2017-04-01 14:27:26 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testMoveAFolderToAMissingParent(): void {
|
2017-04-01 14:27:26 +00:00
|
|
|
$this->assertException("idMissing", "Db", "ExceptionInput");
|
2017-07-17 11:47:57 +00:00
|
|
|
Arsse::$db->folderPropertiesSet("john.doe@example.com", 1, ['parent' => 2112]);
|
2017-04-01 14:27:26 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testMoveAFolderToAnInvalidParent(): void {
|
2017-09-26 20:45:41 +00:00
|
|
|
$this->assertException("idMissing", "Db", "ExceptionInput");
|
|
|
|
Arsse::$db->folderPropertiesSet("john.doe@example.com", 1, ['parent' => "ThisFolderDoesNotExist"]);
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testCauseAFolderCollision(): void {
|
2017-04-01 14:27:26 +00:00
|
|
|
$this->assertException("constraintViolation", "Db", "ExceptionInput");
|
2017-07-17 11:47:57 +00:00
|
|
|
Arsse::$db->folderPropertiesSet("john.doe@example.com", 6, ['parent' => null]);
|
2017-04-01 14:27:26 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testCauseACompoundFolderCollision(): void {
|
2017-09-26 20:45:41 +00:00
|
|
|
$this->assertException("constraintViolation", "Db", "ExceptionInput");
|
|
|
|
Arsse::$db->folderPropertiesSet("john.doe@example.com", 3, ['parent' => null, 'name' => "Technology"]);
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testSetThePropertiesOfAMissingFolder(): void {
|
2017-05-21 14:10:36 +00:00
|
|
|
$this->assertException("subjectMissing", "Db", "ExceptionInput");
|
2017-07-17 11:47:57 +00:00
|
|
|
Arsse::$db->folderPropertiesSet("john.doe@example.com", 2112, ['parent' => null]);
|
2017-04-01 14:27:26 +00:00
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testSetThePropertiesOfAnInvalidFolder(): void {
|
2017-09-28 14:16:24 +00:00
|
|
|
$this->assertException("typeViolation", "Db", "ExceptionInput");
|
|
|
|
Arsse::$db->folderPropertiesSet("john.doe@example.com", -1, ['parent' => null]);
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:52:48 +00:00
|
|
|
public function testSetThePropertiesOfAFolderForTheWrongOwner(): void {
|
2017-05-21 14:10:36 +00:00
|
|
|
$this->assertException("subjectMissing", "Db", "ExceptionInput");
|
2017-07-17 11:47:57 +00:00
|
|
|
Arsse::$db->folderPropertiesSet("john.doe@example.com", 4, ['parent' => null]); // folder ID 4 belongs to Jane
|
2017-04-01 14:27:26 +00:00
|
|
|
}
|
2017-08-29 14:50:31 +00:00
|
|
|
}
|