1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 13:12:41 +00:00

Be more specific about coverage of Database class

This has uncovered a bug with nextFetch calculation, it seems. Fixing it is deferred for now.
This commit is contained in:
J. King 2024-07-10 16:28:19 -04:00
parent aed3749da8
commit 1ae3c33344
21 changed files with 1170 additions and 22 deletions

View file

@ -86,11 +86,16 @@ class Database {
/** Returns the bare name of the calling context's calling method, when __FUNCTION__ is not appropriate */ /** Returns the bare name of the calling context's calling method, when __FUNCTION__ is not appropriate */
protected function caller(): string { protected function caller(): string {
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 4); $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 10);
if ($trace[2]['function'] === "articleQuery") { $out = "";
return $trace[3]['function']; foreach ($trace as $step) {
if (($step['class'] ?? "") === __CLASS__) {
$out = $step['function'];
} else {
break;
} }
return $trace[2]['function']; }
return $out;
} }
/** Returns the current (actual) schema version of the database; compared against self::SCHEMA_VERSION to know when an upgrade is required */ /** Returns the current (actual) schema version of the database; compared against self::SCHEMA_VERSION to know when an upgrade is required */

View file

@ -427,7 +427,15 @@ trait SeriesArticle {
unset($this->data, $this->matches, $this->fields, $this->checkTables, $this->user); unset($this->data, $this->matches, $this->fields, $this->checkTables, $this->user);
} }
/** @dataProvider provideContextMatches */ /**
* @dataProvider provideContextMatches
* @covers \JKingWeb\Arsse\Database::articleList
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testListArticlesCheckingContext(RootContext $c, array $exp): void { public function testListArticlesCheckingContext(RootContext $c, array $exp): void {
$ids = array_column($ids = Arsse::$db->articleList("john.doe@example.com", $c, ["id"], ["id"])->getAll(), "id"); $ids = array_column($ids = Arsse::$db->articleList("john.doe@example.com", $c, ["id"], ["id"])->getAll(), "id");
sort($ids); sort($ids);
@ -547,6 +555,14 @@ trait SeriesArticle {
]; ];
} }
/**
* @covers \JKingWeb\Arsse\Database::editionArticle
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testRetrieveArticleIdsForEditions(): void { public function testRetrieveArticleIdsForEditions(): void {
$exp = [ $exp = [
1 => 1, 1 => 1,
@ -584,16 +600,40 @@ trait SeriesArticle {
$this->assertEquals($exp, Arsse::$db->editionArticle(...range(1, 1001))); $this->assertEquals($exp, Arsse::$db->editionArticle(...range(1, 1001)));
} }
/**
* @covers \JKingWeb\Arsse\Database::articleList
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testListArticlesOfAMissingFolder(): void { public function testListArticlesOfAMissingFolder(): void {
$this->assertException("idMissing", "Db", "ExceptionInput"); $this->assertException("idMissing", "Db", "ExceptionInput");
Arsse::$db->articleList($this->user, (new Context)->folder(1)); Arsse::$db->articleList($this->user, (new Context)->folder(1));
} }
/**
* @covers \JKingWeb\Arsse\Database::articleList
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testListArticlesOfAMissingSubscription(): void { public function testListArticlesOfAMissingSubscription(): void {
$this->assertException("idMissing", "Db", "ExceptionInput"); $this->assertException("idMissing", "Db", "ExceptionInput");
Arsse::$db->articleList($this->user, (new Context)->subscription(1)); Arsse::$db->articleList($this->user, (new Context)->subscription(1));
} }
/**
* @covers \JKingWeb\Arsse\Database::articleList
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testListArticlesCheckingProperties(): void { public function testListArticlesCheckingProperties(): void {
$this->user = "john.doe@example.org"; $this->user = "john.doe@example.org";
// check that the different fieldset groups return the expected columns // check that the different fieldset groups return the expected columns
@ -607,7 +647,15 @@ trait SeriesArticle {
$this->assertEquals($this->fields, $test); $this->assertEquals($this->fields, $test);
} }
/** @dataProvider provideOrderedLists */ /**
* @dataProvider provideOrderedLists
* @covers \JKingWeb\Arsse\Database::articleList
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testListArticlesCheckingOrder(array $sortCols, array $exp): void { public function testListArticlesCheckingOrder(array $sortCols, array $exp): void {
$act = ValueInfo::normalize(array_column(iterator_to_array(Arsse::$db->articleList("john.doe@example.com", null, ["id"], $sortCols)), "id"), ValueInfo::T_INT | ValueInfo::M_ARRAY); $act = ValueInfo::normalize(array_column(iterator_to_array(Arsse::$db->articleList("john.doe@example.com", null, ["id"], $sortCols)), "id"), ValueInfo::T_INT | ValueInfo::M_ARRAY);
$this->assertSame($exp, $act); $this->assertSame($exp, $act);
@ -626,10 +674,26 @@ trait SeriesArticle {
]; ];
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkNothing(): void { public function testMarkNothing(): void {
$this->assertSame(0, Arsse::$db->articleMark($this->user, [])); $this->assertSame(0, Arsse::$db->articleMark($this->user, []));
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAllArticlesUnread(): void { public function testMarkAllArticlesUnread(): void {
Arsse::$db->articleMark($this->user, ['read' => false]); Arsse::$db->articleMark($this->user, ['read' => false]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -641,6 +705,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAllArticlesRead(): void { public function testMarkAllArticlesRead(): void {
Arsse::$db->articleMark($this->user, ['read' => true]); Arsse::$db->articleMark($this->user, ['read' => true]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -656,6 +728,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAllArticlesUnstarred(): void { public function testMarkAllArticlesUnstarred(): void {
Arsse::$db->articleMark($this->user, ['starred' => false]); Arsse::$db->articleMark($this->user, ['starred' => false]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -667,6 +747,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAllArticlesStarred(): void { public function testMarkAllArticlesStarred(): void {
Arsse::$db->articleMark($this->user, ['starred' => true]); Arsse::$db->articleMark($this->user, ['starred' => true]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -682,6 +770,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAllArticlesUnreadAndUnstarred(): void { public function testMarkAllArticlesUnreadAndUnstarred(): void {
Arsse::$db->articleMark($this->user, ['read' => false,'starred' => false]); Arsse::$db->articleMark($this->user, ['read' => false,'starred' => false]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -696,6 +792,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAllArticlesReadAndStarred(): void { public function testMarkAllArticlesReadAndStarred(): void {
Arsse::$db->articleMark($this->user, ['read' => true,'starred' => true]); Arsse::$db->articleMark($this->user, ['read' => true,'starred' => true]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -714,6 +818,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAllArticlesUnreadAndStarred(): void { public function testMarkAllArticlesUnreadAndStarred(): void {
Arsse::$db->articleMark($this->user, ['read' => false,'starred' => true]); Arsse::$db->articleMark($this->user, ['read' => false,'starred' => true]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -732,6 +844,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAllArticlesReadAndUnstarred(): void { public function testMarkAllArticlesReadAndUnstarred(): void {
Arsse::$db->articleMark($this->user, ['read' => true,'starred' => false]); Arsse::$db->articleMark($this->user, ['read' => true,'starred' => false]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -750,6 +870,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testSetNoteForAllArticles(): void { public function testSetNoteForAllArticles(): void {
Arsse::$db->articleMark($this->user, ['note' => "New note"]); Arsse::$db->articleMark($this->user, ['note' => "New note"]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -769,6 +897,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkATreeFolder(): void { public function testMarkATreeFolder(): void {
Arsse::$db->articleMark($this->user, ['read' => true], (new Context)->folder(7)); Arsse::$db->articleMark($this->user, ['read' => true], (new Context)->folder(7));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -780,6 +916,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkALeafFolder(): void { public function testMarkALeafFolder(): void {
Arsse::$db->articleMark($this->user, ['read' => true], (new Context)->folder(8)); Arsse::$db->articleMark($this->user, ['read' => true], (new Context)->folder(8));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -789,6 +933,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAMissingFolder(): void { public function testMarkAMissingFolder(): void {
$this->assertException("idMissing", "Db", "ExceptionInput"); $this->assertException("idMissing", "Db", "ExceptionInput");
Arsse::$db->articleMark($this->user, ['read' => true], (new Context)->folder(42)); Arsse::$db->articleMark($this->user, ['read' => true], (new Context)->folder(42));
@ -803,11 +955,27 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAMissingSubscription(): void { public function testMarkAMissingSubscription(): void {
$this->assertException("idMissing", "Db", "ExceptionInput"); $this->assertException("idMissing", "Db", "ExceptionInput");
Arsse::$db->articleMark($this->user, ['read' => true], (new Context)->folder(2112)); Arsse::$db->articleMark($this->user, ['read' => true], (new Context)->folder(2112));
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAnArticle(): void { public function testMarkAnArticle(): void {
Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->article(20)); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->article(20));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -817,6 +985,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkMultipleArticles(): void { public function testMarkMultipleArticles(): void {
Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->articles([2,4,7,20])); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->articles([2,4,7,20]));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -827,6 +1003,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkMultipleArticlessUnreadAndStarred(): void { public function testMarkMultipleArticlessUnreadAndStarred(): void {
Arsse::$db->articleMark($this->user, ['read' => false,'starred' => true], (new Context)->articles([2,4,7,20])); Arsse::$db->articleMark($this->user, ['read' => false,'starred' => true], (new Context)->articles([2,4,7,20]));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -840,16 +1024,40 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkTooManyMultipleArticles(): void { public function testMarkTooManyMultipleArticles(): void {
$setSize = (new \ReflectionClassConstant(Database::class, "LIMIT_SET_SIZE"))->getValue(); $setSize = (new \ReflectionClassConstant(Database::class, "LIMIT_SET_SIZE"))->getValue();
$this->assertSame(7, Arsse::$db->articleMark($this->user, ['read' => false,'starred' => true], (new Context)->articles(range(1, $setSize * 3)))); $this->assertSame(7, Arsse::$db->articleMark($this->user, ['read' => false,'starred' => true], (new Context)->articles(range(1, $setSize * 3))));
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAMissingArticle(): void { public function testMarkAMissingArticle(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->article(1)); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->article(1));
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAnEdition(): void { public function testMarkAnEdition(): void {
Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->edition(1001)); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->edition(1001));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -859,6 +1067,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkMultipleEditions(): void { public function testMarkMultipleEditions(): void {
Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->editions([2,4,7,20])); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->editions([2,4,7,20]));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -869,12 +1085,28 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkMultipleMissingEditions(): void { public function testMarkMultipleMissingEditions(): void {
$this->assertSame(0, Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->editions([500,501]))); $this->assertSame(0, Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->editions([500,501])));
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkMultipleEditionsUnread(): void { public function testMarkMultipleEditionsUnread(): void {
Arsse::$db->articleMark($this->user, ['read' => false], (new Context)->editions([2,4,7,1001])); Arsse::$db->articleMark($this->user, ['read' => false], (new Context)->editions([2,4,7,1001]));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -886,6 +1118,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkMultipleEditionsUnreadWithStale(): void { public function testMarkMultipleEditionsUnreadWithStale(): void {
Arsse::$db->articleMark($this->user, ['read' => false], (new Context)->editions([2,4,7,20])); Arsse::$db->articleMark($this->user, ['read' => false], (new Context)->editions([2,4,7,20]));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -895,6 +1135,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkMultipleEditionsUnreadAndStarredWithStale(): void { public function testMarkMultipleEditionsUnreadAndStarredWithStale(): void {
Arsse::$db->articleMark($this->user, ['read' => false,'starred' => true], (new Context)->editions([2,4,7,20])); Arsse::$db->articleMark($this->user, ['read' => false,'starred' => true], (new Context)->editions([2,4,7,20]));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -907,16 +1155,39 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkTooManyMultipleEditions(): void { public function testMarkTooManyMultipleEditions(): void {
$this->assertSame(7, Arsse::$db->articleMark($this->user, ['read' => false,'starred' => true], (new Context)->editions(range(1, 51)))); $this->assertSame(7, Arsse::$db->articleMark($this->user, ['read' => false,'starred' => true], (new Context)->editions(range(1, 51))));
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAStaleEditionUnread(): void { public function testMarkAStaleEditionUnread(): void {
Arsse::$db->articleMark($this->user, ['read' => false], (new Context)->edition(20)); // no changes occur Arsse::$db->articleMark($this->user, ['read' => false], (new Context)->edition(20)); // no changes occur
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAStaleEditionStarred(): void { public function testMarkAStaleEditionStarred(): void {
Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->edition(20)); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->edition(20));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -926,6 +1197,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAStaleEditionUnreadAndStarred(): void { public function testMarkAStaleEditionUnreadAndStarred(): void {
Arsse::$db->articleMark($this->user, ['read' => false,'starred' => true], (new Context)->edition(20)); // only starred is changed Arsse::$db->articleMark($this->user, ['read' => false,'starred' => true], (new Context)->edition(20)); // only starred is changed
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -935,17 +1214,41 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAStaleEditionUnreadAndUnstarred(): void { public function testMarkAStaleEditionUnreadAndUnstarred(): void {
Arsse::$db->articleMark($this->user, ['read' => false,'starred' => false], (new Context)->edition(20)); // no changes occur Arsse::$db->articleMark($this->user, ['read' => false,'starred' => false], (new Context)->edition(20)); // no changes occur
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAMissingEdition(): void { public function testMarkAMissingEdition(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->edition(2)); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->edition(2));
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkByOldestEdition(): void { public function testMarkByOldestEdition(): void {
Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->editionRange(19, null)); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->editionRange(19, null));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -957,6 +1260,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkByLatestEdition(): void { public function testMarkByLatestEdition(): void {
Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->editionRange(null, 20)); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->editionRange(null, 20));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -970,6 +1281,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkByLastMarked(): void { public function testMarkByLastMarked(): void {
Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->markedRange('2017-01-01T00:00:00Z', null)); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->markedRange('2017-01-01T00:00:00Z', null));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -981,6 +1300,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkByNotLastMarked(): void { public function testMarkByNotLastMarked(): void {
Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->markedRange(null, '2000-01-01T00:00:00Z')); Arsse::$db->articleMark($this->user, ['starred' => true], (new Context)->markedRange(null, '2000-01-01T00:00:00Z'));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -990,6 +1317,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleCount
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testCountArticles(): void { public function testCountArticles(): void {
$setSize = (new \ReflectionClassConstant(Database::class, "LIMIT_SET_SIZE"))->getValue(); $setSize = (new \ReflectionClassConstant(Database::class, "LIMIT_SET_SIZE"))->getValue();
$this->assertSame(2, Arsse::$db->articleCount("john.doe@example.com", (new Context)->starred(true))); $this->assertSame(2, Arsse::$db->articleCount("john.doe@example.com", (new Context)->starred(true)));
@ -998,6 +1333,7 @@ trait SeriesArticle {
$this->assertSame(10, Arsse::$db->articleCount("john.doe@example.com", (new Context)->articles(range(1, $setSize * 3)))); $this->assertSame(10, Arsse::$db->articleCount("john.doe@example.com", (new Context)->articles(range(1, $setSize * 3))));
} }
/** @covers \JKingWeb\Arsse\Database::articleStarred */
public function testFetchStarredCounts(): void { public function testFetchStarredCounts(): void {
$exp1 = ['total' => 2, 'unread' => 1, 'read' => 1]; $exp1 = ['total' => 2, 'unread' => 1, 'read' => 1];
$exp2 = ['total' => 0, 'unread' => 0, 'read' => 0]; $exp2 = ['total' => 0, 'unread' => 0, 'read' => 0];
@ -1005,17 +1341,20 @@ trait SeriesArticle {
$this->assertEquals($exp2, Arsse::$db->articleStarred("jane.doe@example.com")); $this->assertEquals($exp2, Arsse::$db->articleStarred("jane.doe@example.com"));
} }
/** @covers \JKingWeb\Arsse\Database::editionLatest */
public function testFetchLatestEdition(): void { public function testFetchLatestEdition(): void {
$this->assertSame(1001, Arsse::$db->editionLatest($this->user)); $this->assertSame(1001, Arsse::$db->editionLatest($this->user));
$this->assertSame(4, Arsse::$db->editionLatest($this->user, (new Context)->subscription(12))); $this->assertSame(4, Arsse::$db->editionLatest($this->user, (new Context)->subscription(12)));
$this->assertSame(5, Arsse::$db->editionLatest("john.doe@example.com", (new Context)->subscription(3)->hidden(false))); $this->assertSame(5, Arsse::$db->editionLatest("john.doe@example.com", (new Context)->subscription(3)->hidden(false)));
} }
/** @covers \JKingWeb\Arsse\Database::editionLatest */
public function testFetchLatestEditionOfMissingSubscription(): void { public function testFetchLatestEditionOfMissingSubscription(): void {
$this->assertException("idMissing", "Db", "ExceptionInput"); $this->assertException("idMissing", "Db", "ExceptionInput");
Arsse::$db->editionLatest($this->user, (new Context)->subscription(1)); Arsse::$db->editionLatest($this->user, (new Context)->subscription(1));
} }
/** @covers \JKingWeb\Arsse\Database::articleLabelsGet */
public function testListTheLabelsOfAnArticle(): void { public function testListTheLabelsOfAnArticle(): void {
$this->assertEquals([1,2], Arsse::$db->articleLabelsGet("john.doe@example.com", 1)); $this->assertEquals([1,2], Arsse::$db->articleLabelsGet("john.doe@example.com", 1));
$this->assertEquals([2], Arsse::$db->articleLabelsGet("john.doe@example.com", 5)); $this->assertEquals([2], Arsse::$db->articleLabelsGet("john.doe@example.com", 5));
@ -1025,11 +1364,13 @@ trait SeriesArticle {
$this->assertEquals([], Arsse::$db->articleLabelsGet("john.doe@example.com", 2, true)); $this->assertEquals([], Arsse::$db->articleLabelsGet("john.doe@example.com", 2, true));
} }
/** @covers \JKingWeb\Arsse\Database::articleLabelsGet */
public function testListTheLabelsOfAMissingArticle(): void { public function testListTheLabelsOfAMissingArticle(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->articleLabelsGet($this->user, 101); Arsse::$db->articleLabelsGet($this->user, 101);
} }
/** @covers \JKingWeb\Arsse\Database::articleCategoriesGet */
public function testListTheCategoriesOfAnArticle(): void { public function testListTheCategoriesOfAnArticle(): void {
$exp = ["Fascinating", "Logical"]; $exp = ["Fascinating", "Logical"];
$this->assertSame($exp, Arsse::$db->articleCategoriesGet($this->user, 19)); $this->assertSame($exp, Arsse::$db->articleCategoriesGet($this->user, 19));
@ -1039,12 +1380,21 @@ trait SeriesArticle {
$this->assertSame($exp, Arsse::$db->articleCategoriesGet($this->user, 4)); $this->assertSame($exp, Arsse::$db->articleCategoriesGet($this->user, 4));
} }
/** @covers \JKingWeb\Arsse\Database::articleCategoriesGet */
public function testListTheCategoriesOfAMissingArticle(): void { public function testListTheCategoriesOfAMissingArticle(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->articleCategoriesGet($this->user, 101); Arsse::$db->articleCategoriesGet($this->user, 101);
} }
/** @dataProvider provideArrayContextOptions */ /**
* @dataProvider provideArrayContextOptions
* @covers \JKingWeb\Arsse\Database::articleList
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testUseTooFewValuesInArrayContext(string $option): void { public function testUseTooFewValuesInArrayContext(string $option): void {
$this->assertException("tooShort", "Db", "ExceptionInput"); $this->assertException("tooShort", "Db", "ExceptionInput");
Arsse::$db->articleList($this->user, (new Context)->$option([])); Arsse::$db->articleList($this->user, (new Context)->$option([]));
@ -1062,6 +1412,14 @@ trait SeriesArticle {
} }
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAllArticlesNotHidden(): void { public function testMarkAllArticlesNotHidden(): void {
Arsse::$db->articleMark("jane.doe@example.com", ['hidden' => false]); Arsse::$db->articleMark("jane.doe@example.com", ['hidden' => false]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -1073,6 +1431,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAllArticlesHidden(): void { public function testMarkAllArticlesHidden(): void {
Arsse::$db->articleMark("jane.doe@example.com", ['hidden' => true]); Arsse::$db->articleMark("jane.doe@example.com", ['hidden' => true]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -1083,6 +1449,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAllArticlesUnreadAndNotHidden(): void { public function testMarkAllArticlesUnreadAndNotHidden(): void {
Arsse::$db->articleMark("jane.doe@example.com", ['read' => false, 'hidden' => false]); Arsse::$db->articleMark("jane.doe@example.com", ['read' => false, 'hidden' => false]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -1097,6 +1471,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAllArticlesReadAndHidden(): void { public function testMarkAllArticlesReadAndHidden(): void {
Arsse::$db->articleMark("jane.doe@example.com", ['read' => true, 'hidden' => true]); Arsse::$db->articleMark("jane.doe@example.com", ['read' => true, 'hidden' => true]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -1109,6 +1491,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAllArticlesUnreadAndHidden(): void { public function testMarkAllArticlesUnreadAndHidden(): void {
Arsse::$db->articleMark("jane.doe@example.com", ['read' => false,'hidden' => true]); Arsse::$db->articleMark("jane.doe@example.com", ['read' => false,'hidden' => true]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -1122,6 +1512,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAllArticlesReadAndNotHidden(): void { public function testMarkAllArticlesReadAndNotHidden(): void {
Arsse::$db->articleMark("jane.doe@example.com", ['read' => true,'hidden' => false]); Arsse::$db->articleMark("jane.doe@example.com", ['read' => true,'hidden' => false]);
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -1135,6 +1533,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkMultipleEditionsUnreadAndHiddenWithStale(): void { public function testMarkMultipleEditionsUnreadAndHiddenWithStale(): void {
Arsse::$db->articleMark("jane.doe@example.com", ['read' => false,'hidden' => true], (new Context)->editions([1,2,19,20])); Arsse::$db->articleMark("jane.doe@example.com", ['read' => false,'hidden' => true], (new Context)->editions([1,2,19,20]));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -1148,6 +1554,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAStaleEditionHidden(): void { public function testMarkAStaleEditionHidden(): void {
Arsse::$db->articleMark("jane.doe@example.com", ['hidden' => true], (new Context)->edition(20)); Arsse::$db->articleMark("jane.doe@example.com", ['hidden' => true], (new Context)->edition(20));
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -1157,6 +1571,14 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAStaleEditionUnreadAndHidden(): void { public function testMarkAStaleEditionUnreadAndHidden(): void {
Arsse::$db->articleMark("jane.doe@example.com", ['read' => false,'hidden' => true], (new Context)->edition(20)); // only starred is changed Arsse::$db->articleMark("jane.doe@example.com", ['read' => false,'hidden' => true], (new Context)->edition(20)); // only starred is changed
$now = Date::transform(time(), "sql"); $now = Date::transform(time(), "sql");
@ -1166,12 +1588,28 @@ trait SeriesArticle {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleMark
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testMarkAStaleEditionUnreadAndNotHidden(): void { public function testMarkAStaleEditionUnreadAndNotHidden(): void {
Arsse::$db->articleMark("jane.doe@example.com", ['read' => false,'hidden' => false], (new Context)->edition(20)); // no changes occur Arsse::$db->articleMark("jane.doe@example.com", ['read' => false,'hidden' => false], (new Context)->edition(20)); // no changes occur
$state = $this->primeExpectations($this->data, $this->checkTables); $state = $this->primeExpectations($this->data, $this->checkTables);
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::articleList
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testSelectScrapedContent(): void { public function testSelectScrapedContent(): void {
$exp = [ $exp = [
['id' => 101, 'content' => "<p>Article content 1</p>"], ['id' => 101, 'content' => "<p>Article content 1</p>"],
@ -1185,6 +1623,14 @@ trait SeriesArticle {
$this->assertResult($exp, Arsse::$db->articleList("jill.doe@example.com", (new Context)->subscription(15), ["id", "content"])); $this->assertResult($exp, Arsse::$db->articleList("jill.doe@example.com", (new Context)->subscription(15), ["id", "content"]));
} }
/**
* @covers \JKingWeb\Arsse\Database::articleList
* @covers \JKingWeb\Arsse\Database::articleQuery
* @covers \JKingWeb\Arsse\Database::articleValidateId
* @covers \JKingWeb\Arsse\Database::articleValidateEdition
* @covers \JKingWeb\Arsse\Database::articleColumns
* @covers \JKingWeb\Arsse\Database::articleFilter
*/
public function testSearchScrapedContent(): void { public function testSearchScrapedContent(): void {
$exp = [ $exp = [
['id' => 101, 'content' => "<p>Scraped content 1</p>"], ['id' => 101, 'content' => "<p>Scraped content 1</p>"],

View file

@ -170,6 +170,7 @@ trait SeriesCleanup {
unset($this->data); unset($this->data);
} }
/** @covers \JKingWeb\Arsse\Database::feedCleanup */
public function testCleanUpOrphanedFeeds(): void { public function testCleanUpOrphanedFeeds(): void {
Arsse::$db->feedCleanup(); Arsse::$db->feedCleanup();
$now = gmdate("Y-m-d H:i:s"); $now = gmdate("Y-m-d H:i:s");
@ -182,6 +183,7 @@ trait SeriesCleanup {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::feedCleanup */
public function testCleanUpOrphanedFeedsWithUnlimitedRetention(): void { public function testCleanUpOrphanedFeedsWithUnlimitedRetention(): void {
Arsse::$conf->import([ Arsse::$conf->import([
'purgeFeeds' => null, 'purgeFeeds' => null,
@ -196,6 +198,7 @@ trait SeriesCleanup {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::iconCleanup */
public function testCleanUpOrphanedIcons(): void { public function testCleanUpOrphanedIcons(): void {
Arsse::$db->iconCleanup(); Arsse::$db->iconCleanup();
$now = gmdate("Y-m-d H:i:s"); $now = gmdate("Y-m-d H:i:s");
@ -208,6 +211,7 @@ trait SeriesCleanup {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::iconCleanup */
public function testCleanUpOrphanedIconsWithUnlimitedRetention(): void { public function testCleanUpOrphanedIconsWithUnlimitedRetention(): void {
Arsse::$conf->import([ Arsse::$conf->import([
'purgeFeeds' => null, 'purgeFeeds' => null,
@ -222,6 +226,7 @@ trait SeriesCleanup {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::articleCleanup */
public function testCleanUpOldArticlesWithStandardRetention(): void { public function testCleanUpOldArticlesWithStandardRetention(): void {
Arsse::$db->articleCleanup(); Arsse::$db->articleCleanup();
$state = $this->primeExpectations($this->data, [ $state = $this->primeExpectations($this->data, [
@ -233,6 +238,7 @@ trait SeriesCleanup {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::articleCleanup */
public function testCleanUpOldArticlesWithUnlimitedReadRetention(): void { public function testCleanUpOldArticlesWithUnlimitedReadRetention(): void {
Arsse::$conf->import([ Arsse::$conf->import([
'purgeArticlesRead' => null, 'purgeArticlesRead' => null,
@ -247,6 +253,7 @@ trait SeriesCleanup {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::articleCleanup */
public function testCleanUpOldArticlesWithUnlimitedUnreadRetention(): void { public function testCleanUpOldArticlesWithUnlimitedUnreadRetention(): void {
Arsse::$conf->import([ Arsse::$conf->import([
'purgeArticlesUnread' => null, 'purgeArticlesUnread' => null,
@ -261,6 +268,7 @@ trait SeriesCleanup {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::articleCleanup */
public function testCleanUpOldArticlesWithUnlimitedRetention(): void { public function testCleanUpOldArticlesWithUnlimitedRetention(): void {
Arsse::$conf->import([ Arsse::$conf->import([
'purgeArticlesRead' => null, 'purgeArticlesRead' => null,
@ -273,6 +281,7 @@ trait SeriesCleanup {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::sessionCleanup */
public function testCleanUpExpiredSessions(): void { public function testCleanUpExpiredSessions(): void {
Arsse::$db->sessionCleanup(); Arsse::$db->sessionCleanup();
$state = $this->primeExpectations($this->data, [ $state = $this->primeExpectations($this->data, [
@ -284,6 +293,7 @@ trait SeriesCleanup {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::tokenCleanup */
public function testCleanUpExpiredTokens(): void { public function testCleanUpExpiredTokens(): void {
Arsse::$db->tokenCleanup(); Arsse::$db->tokenCleanup();
$state = $this->primeExpectations($this->data, [ $state = $this->primeExpectations($this->data, [

View file

@ -192,10 +192,12 @@ trait SeriesFeed {
unset($this->data, $this->matches); unset($this->data, $this->matches);
} }
/** @covers \JKingWeb\Arsse\Database::feedMatchLatest */
public function testListLatestItems(): void { public function testListLatestItems(): void {
$this->assertResult($this->matches, Arsse::$db->feedMatchLatest(1, 2)); $this->assertResult($this->matches, Arsse::$db->feedMatchLatest(1, 2));
} }
/** @covers \JKingWeb\Arsse\Database::feedMatchIds */
public function testMatchItemsById(): void { public function testMatchItemsById(): void {
$this->assertResult($this->matches, Arsse::$db->feedMatchIds(1, ['804e517d623390e71497982c77cf6823180342ebcd2e7d5e32da1e55b09dd180','db3e736c2c492f5def5c5da33ddcbea1824040e9ced2142069276b0a6e291a41'])); $this->assertResult($this->matches, Arsse::$db->feedMatchIds(1, ['804e517d623390e71497982c77cf6823180342ebcd2e7d5e32da1e55b09dd180','db3e736c2c492f5def5c5da33ddcbea1824040e9ced2142069276b0a6e291a41']));
foreach ($this->matches as $m) { foreach ($this->matches as $m) {
@ -207,7 +209,10 @@ trait SeriesFeed {
$this->assertResult([['id' => 1]], Arsse::$db->feedMatchIds(1, ['e433653cef2e572eee4215fa299a4a5af9137b2cefd6283c85bd69a32915beda'])); // this ID appears in both feed 1 and feed 2; only one result should be returned $this->assertResult([['id' => 1]], Arsse::$db->feedMatchIds(1, ['e433653cef2e572eee4215fa299a4a5af9137b2cefd6283c85bd69a32915beda'])); // this ID appears in both feed 1 and feed 2; only one result should be returned
} }
/** @dataProvider provideFilterRules */ /**
* @dataProvider provideFilterRules
* @covers \JKingWeb\Arsse\Database::feedRulesGet
*/
public function testGetRules(int $in, array $exp): void { public function testGetRules(int $in, array $exp): void {
$this->assertSame($exp, Arsse::$db->feedRulesGet($in)); $this->assertSame($exp, Arsse::$db->feedRulesGet($in));
} }
@ -222,6 +227,7 @@ trait SeriesFeed {
]; ];
} }
/** @covers \JKingWeb\Arsse\Database::feedUpdate */
public function testUpdateAFeed(): void { public function testUpdateAFeed(): void {
// update a valid feed with both new and changed items // update a valid feed with both new and changed items
Arsse::$db->feedUpdate(1); Arsse::$db->feedUpdate(1);
@ -263,21 +269,25 @@ trait SeriesFeed {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::feedUpdate */
public function testUpdateAMissingFeed(): void { public function testUpdateAMissingFeed(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->feedUpdate(2112); Arsse::$db->feedUpdate(2112);
} }
/** @covers \JKingWeb\Arsse\Database::feedUpdate */
public function testUpdateAnInvalidFeed(): void { public function testUpdateAnInvalidFeed(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->feedUpdate(-1); Arsse::$db->feedUpdate(-1);
} }
/** @covers \JKingWeb\Arsse\Database::feedUpdate */
public function testUpdateAFeedThrowingExceptions(): void { public function testUpdateAFeedThrowingExceptions(): void {
$this->assertException("invalidUrl", "Feed"); $this->assertException("invalidUrl", "Feed");
Arsse::$db->feedUpdate(3, true); Arsse::$db->feedUpdate(3, true);
} }
/** @covers \JKingWeb\Arsse\Database::feedUpdate */
public function testUpdateAFeedWithEnclosuresAndCategories(): void { public function testUpdateAFeedWithEnclosuresAndCategories(): void {
Arsse::$db->feedUpdate(5); Arsse::$db->feedUpdate(5);
$state = $this->primeExpectations($this->data, [ $state = $this->primeExpectations($this->data, [
@ -298,6 +308,7 @@ trait SeriesFeed {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::feedListStale */
public function testListStaleFeeds(): void { public function testListStaleFeeds(): void {
$this->assertEquals([1,3,4], Arsse::$db->feedListStale()); $this->assertEquals([1,3,4], Arsse::$db->feedListStale());
Arsse::$db->feedUpdate(3); Arsse::$db->feedUpdate(3);
@ -305,6 +316,7 @@ trait SeriesFeed {
$this->assertEquals([1], Arsse::$db->feedListStale()); $this->assertEquals([1], Arsse::$db->feedListStale());
} }
/** @covers \JKingWeb\Arsse\Database::feedUpdate */
public function testCheckIconDuringFeedUpdate(): void { public function testCheckIconDuringFeedUpdate(): void {
Arsse::$db->feedUpdate(6); Arsse::$db->feedUpdate(6);
$state = $this->primeExpectations($this->data, [ $state = $this->primeExpectations($this->data, [
@ -314,6 +326,7 @@ trait SeriesFeed {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::feedUpdate */
public function testAssignIconDuringFeedUpdate(): void { public function testAssignIconDuringFeedUpdate(): void {
Arsse::$db->feedUpdate(7); Arsse::$db->feedUpdate(7);
$state = $this->primeExpectations($this->data, [ $state = $this->primeExpectations($this->data, [
@ -324,6 +337,7 @@ trait SeriesFeed {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::feedUpdate */
public function testChangeIconDuringFeedUpdate(): void { public function testChangeIconDuringFeedUpdate(): void {
Arsse::$db->feedUpdate(8); Arsse::$db->feedUpdate(8);
$state = $this->primeExpectations($this->data, [ $state = $this->primeExpectations($this->data, [
@ -334,6 +348,7 @@ trait SeriesFeed {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::feedUpdate */
public function testAddIconDuringFeedUpdate(): void { public function testAddIconDuringFeedUpdate(): void {
Arsse::$db->feedUpdate(9); Arsse::$db->feedUpdate(9);
$state = $this->primeExpectations($this->data, [ $state = $this->primeExpectations($this->data, [
@ -344,4 +359,21 @@ trait SeriesFeed {
$state['arsse_icons']['rows'][] = [4,'http://localhost:8000/Icon/SVG2','image/svg+xml','<svg xmlns="http://www.w3.org/2000/svg" width="900" height="600"><rect width="900" height="600" fill="#ED2939"/><rect width="600" height="600" fill="#fff"/><rect width="300" height="600" fill="#002395"/></svg>']; $state['arsse_icons']['rows'][] = [4,'http://localhost:8000/Icon/SVG2','image/svg+xml','<svg xmlns="http://www.w3.org/2000/svg" width="900" height="600"><rect width="900" height="600" fill="#ED2939"/><rect width="600" height="600" fill="#fff"/><rect width="300" height="600" fill="#002395"/></svg>'];
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::feedUpdate */
public function testUpdateUnmodifiedFeed(): void {
$this->markTestIncomplete("FIXME: there is a bug here around calculation of nextFetch date");
$state = $this->primeExpectations($this->data, [
'arsse_icons' => ["id", "url", "type", "data"],
'arsse_feeds' => ["id", "url", "title", "err_count", "err_msg", "modified", "next_fetch", "size", "icon"],
'arsse_subscriptions' => ["id", "owner", "feed", "keep_rule", "block_rule"],
'arsse_articles' => ["id", "feed", "url", "title", "author", "published", "edited", "content", "guid", "url_title_hash", "url_content_hash", "title_content_hash", "modified"],
'arsse_editions' => ["id", "article", "modified"],
'arsse_marks' => ["article", "subscription", "read", "starred", "hidden", "modified"],
'arsse_enclosures' => ["article", "url", "type"],
'arsse_categories' => ["article", "name"],
]);
Arsse::$db->feedUpdate(4);
$this->compareExpectations(static::$drv, $state);
}
} }

View file

@ -99,6 +99,11 @@ trait SeriesFolder {
unset($this->data); unset($this->data);
} }
/**
* @covers \JKingWeb\Arsse\Database::folderAdd
* @covers \JKingWeb\Arsse\Database::folderValidateId
* @covers \JKingWeb\Arsse\Database::folderValidateName
*/
public function testAddARootFolder(): void { public function testAddARootFolder(): void {
$user = "john.doe@example.com"; $user = "john.doe@example.com";
$folderID = $this->nextID("arsse_folders"); $folderID = $this->nextID("arsse_folders");
@ -108,11 +113,21 @@ trait SeriesFolder {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::folderAdd
* @covers \JKingWeb\Arsse\Database::folderValidateId
* @covers \JKingWeb\Arsse\Database::folderValidateName
*/
public function testAddADuplicateRootFolder(): void { public function testAddADuplicateRootFolder(): void {
$this->assertException("constraintViolation", "Db", "ExceptionInput"); $this->assertException("constraintViolation", "Db", "ExceptionInput");
Arsse::$db->folderAdd("john.doe@example.com", ['name' => "Politics"]); Arsse::$db->folderAdd("john.doe@example.com", ['name' => "Politics"]);
} }
/**
* @covers \JKingWeb\Arsse\Database::folderAdd
* @covers \JKingWeb\Arsse\Database::folderValidateId
* @covers \JKingWeb\Arsse\Database::folderValidateName
*/
public function testAddANestedFolder(): void { public function testAddANestedFolder(): void {
$user = "john.doe@example.com"; $user = "john.doe@example.com";
$folderID = $this->nextID("arsse_folders"); $folderID = $this->nextID("arsse_folders");
@ -122,36 +137,70 @@ trait SeriesFolder {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::folderAdd
* @covers \JKingWeb\Arsse\Database::folderValidateId
* @covers \JKingWeb\Arsse\Database::folderValidateName
*/
public function testAddANestedFolderToAMissingParent(): void { public function testAddANestedFolderToAMissingParent(): void {
$this->assertException("idMissing", "Db", "ExceptionInput"); $this->assertException("idMissing", "Db", "ExceptionInput");
Arsse::$db->folderAdd("john.doe@example.com", ['name' => "Sociology", 'parent' => 2112]); Arsse::$db->folderAdd("john.doe@example.com", ['name' => "Sociology", 'parent' => 2112]);
} }
/**
* @covers \JKingWeb\Arsse\Database::folderAdd
* @covers \JKingWeb\Arsse\Database::folderValidateId
* @covers \JKingWeb\Arsse\Database::folderValidateName
*/
public function testAddANestedFolderToAnInvalidParent(): void { public function testAddANestedFolderToAnInvalidParent(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->folderAdd("john.doe@example.com", ['name' => "Sociology", 'parent' => "stringFolderId"]); Arsse::$db->folderAdd("john.doe@example.com", ['name' => "Sociology", 'parent' => "stringFolderId"]);
} }
/**
* @covers \JKingWeb\Arsse\Database::folderAdd
* @covers \JKingWeb\Arsse\Database::folderValidateId
* @covers \JKingWeb\Arsse\Database::folderValidateName
*/
public function testAddANestedFolderForTheWrongOwner(): void { public function testAddANestedFolderForTheWrongOwner(): void {
$this->assertException("idMissing", "Db", "ExceptionInput"); $this->assertException("idMissing", "Db", "ExceptionInput");
Arsse::$db->folderAdd("john.doe@example.com", ['name' => "Sociology", 'parent' => 4]); // folder ID 4 belongs to Jane Arsse::$db->folderAdd("john.doe@example.com", ['name' => "Sociology", 'parent' => 4]); // folder ID 4 belongs to Jane
} }
/**
* @covers \JKingWeb\Arsse\Database::folderAdd
* @covers \JKingWeb\Arsse\Database::folderValidateId
* @covers \JKingWeb\Arsse\Database::folderValidateName
*/
public function testAddAFolderWithAMissingName(): void { public function testAddAFolderWithAMissingName(): void {
$this->assertException("missing", "Db", "ExceptionInput"); $this->assertException("missing", "Db", "ExceptionInput");
Arsse::$db->folderAdd("john.doe@example.com", []); Arsse::$db->folderAdd("john.doe@example.com", []);
} }
/**
* @covers \JKingWeb\Arsse\Database::folderAdd
* @covers \JKingWeb\Arsse\Database::folderValidateId
* @covers \JKingWeb\Arsse\Database::folderValidateName
*/
public function testAddAFolderWithABlankName(): void { public function testAddAFolderWithABlankName(): void {
$this->assertException("missing", "Db", "ExceptionInput"); $this->assertException("missing", "Db", "ExceptionInput");
Arsse::$db->folderAdd("john.doe@example.com", ['name' => ""]); Arsse::$db->folderAdd("john.doe@example.com", ['name' => ""]);
} }
/**
* @covers \JKingWeb\Arsse\Database::folderAdd
* @covers \JKingWeb\Arsse\Database::folderValidateId
* @covers \JKingWeb\Arsse\Database::folderValidateName
*/
public function testAddAFolderWithAWhitespaceName(): void { public function testAddAFolderWithAWhitespaceName(): void {
$this->assertException("whitespace", "Db", "ExceptionInput"); $this->assertException("whitespace", "Db", "ExceptionInput");
Arsse::$db->folderAdd("john.doe@example.com", ['name' => " "]); Arsse::$db->folderAdd("john.doe@example.com", ['name' => " "]);
} }
/**
* @covers \JKingWeb\Arsse\Database::folderList
* @covers \JKingWeb\Arsse\Database::folderValidateId
*/
public function testListRootFolders(): void { public function testListRootFolders(): void {
$exp = [ $exp = [
['id' => 5, 'name' => "Politics", 'parent' => null, 'children' => 0, 'feeds' => 2], ['id' => 5, 'name' => "Politics", 'parent' => null, 'children' => 0, 'feeds' => 2],
@ -166,6 +215,10 @@ trait SeriesFolder {
$this->assertResult($exp, Arsse::$db->folderList("admin@example.net", null, false)); $this->assertResult($exp, Arsse::$db->folderList("admin@example.net", null, false));
} }
/**
* @covers \JKingWeb\Arsse\Database::folderList
* @covers \JKingWeb\Arsse\Database::folderValidateId
*/
public function testListFoldersRecursively(): void { public function testListFoldersRecursively(): void {
$exp = [ $exp = [
['id' => 5, 'name' => "Politics", 'parent' => null, 'children' => 0, 'feeds' => 2], ['id' => 5, 'name' => "Politics", 'parent' => null, 'children' => 0, 'feeds' => 2],
@ -185,16 +238,25 @@ trait SeriesFolder {
$this->assertResult($exp, Arsse::$db->folderList("jane.doe@example.com", 4, true)); $this->assertResult($exp, Arsse::$db->folderList("jane.doe@example.com", 4, true));
} }
/**
* @covers \JKingWeb\Arsse\Database::folderList
* @covers \JKingWeb\Arsse\Database::folderValidateId
*/
public function testListFoldersOfAMissingParent(): void { public function testListFoldersOfAMissingParent(): void {
$this->assertException("idMissing", "Db", "ExceptionInput"); $this->assertException("idMissing", "Db", "ExceptionInput");
Arsse::$db->folderList("john.doe@example.com", 2112); Arsse::$db->folderList("john.doe@example.com", 2112);
} }
/**
* @covers \JKingWeb\Arsse\Database::folderList
* @covers \JKingWeb\Arsse\Database::folderValidateId
*/
public function testListFoldersOfTheWrongOwner(): void { public function testListFoldersOfTheWrongOwner(): void {
$this->assertException("idMissing", "Db", "ExceptionInput"); $this->assertException("idMissing", "Db", "ExceptionInput");
Arsse::$db->folderList("john.doe@example.com", 4); // folder ID 4 belongs to Jane Arsse::$db->folderList("john.doe@example.com", 4); // folder ID 4 belongs to Jane
} }
/** @covers \JKingWeb\Arsse\Database::folderRemove */
public function testRemoveAFolder(): void { public function testRemoveAFolder(): void {
$this->assertTrue(Arsse::$db->folderRemove("john.doe@example.com", 6)); $this->assertTrue(Arsse::$db->folderRemove("john.doe@example.com", 6));
$state = $this->primeExpectations($this->data, ['arsse_folders' => ['id','owner', 'parent', 'name']]); $state = $this->primeExpectations($this->data, ['arsse_folders' => ['id','owner', 'parent', 'name']]);
@ -202,6 +264,7 @@ trait SeriesFolder {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::folderRemove */
public function testRemoveAFolderTree(): void { public function testRemoveAFolderTree(): void {
$this->assertTrue(Arsse::$db->folderRemove("john.doe@example.com", 1)); $this->assertTrue(Arsse::$db->folderRemove("john.doe@example.com", 1));
$state = $this->primeExpectations($this->data, ['arsse_folders' => ['id','owner', 'parent', 'name']]); $state = $this->primeExpectations($this->data, ['arsse_folders' => ['id','owner', 'parent', 'name']]);
@ -211,21 +274,25 @@ trait SeriesFolder {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::folderRemove */
public function testRemoveAMissingFolder(): void { public function testRemoveAMissingFolder(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->folderRemove("john.doe@example.com", 2112); Arsse::$db->folderRemove("john.doe@example.com", 2112);
} }
/** @covers \JKingWeb\Arsse\Database::folderRemove */
public function testRemoveAnInvalidFolder(): void { public function testRemoveAnInvalidFolder(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->folderRemove("john.doe@example.com", -1); Arsse::$db->folderRemove("john.doe@example.com", -1);
} }
/** @covers \JKingWeb\Arsse\Database::folderRemove */
public function testRemoveAFolderOfTheWrongOwner(): void { public function testRemoveAFolderOfTheWrongOwner(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->folderRemove("john.doe@example.com", 4); // folder ID 4 belongs to Jane Arsse::$db->folderRemove("john.doe@example.com", 4); // folder ID 4 belongs to Jane
} }
/** @covers \JKingWeb\Arsse\Database::folderPropertiesGet */
public function testGetThePropertiesOfAFolder(): void { public function testGetThePropertiesOfAFolder(): void {
$exp = [ $exp = [
'id' => 6, 'id' => 6,
@ -235,25 +302,33 @@ trait SeriesFolder {
$this->assertArraySubset($exp, Arsse::$db->folderPropertiesGet("john.doe@example.com", 6)); $this->assertArraySubset($exp, Arsse::$db->folderPropertiesGet("john.doe@example.com", 6));
} }
/** @covers \JKingWeb\Arsse\Database::folderPropertiesGet */
public function testGetThePropertiesOfAMissingFolder(): void { public function testGetThePropertiesOfAMissingFolder(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->folderPropertiesGet("john.doe@example.com", 2112); Arsse::$db->folderPropertiesGet("john.doe@example.com", 2112);
} }
/** @covers \JKingWeb\Arsse\Database::folderPropertiesGet */
public function testGetThePropertiesOfAnInvalidFolder(): void { public function testGetThePropertiesOfAnInvalidFolder(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->folderPropertiesGet("john.doe@example.com", -1); Arsse::$db->folderPropertiesGet("john.doe@example.com", -1);
} }
/** @covers \JKingWeb\Arsse\Database::folderPropertiesGet */
public function testGetThePropertiesOfAFolderOfTheWrongOwner(): void { public function testGetThePropertiesOfAFolderOfTheWrongOwner(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->folderPropertiesGet("john.doe@example.com", 4); // folder ID 4 belongs to Jane Arsse::$db->folderPropertiesGet("john.doe@example.com", 4); // folder ID 4 belongs to Jane
} }
/** @covers \JKingWeb\Arsse\Database::folderPropertiesSet */
public function testMakeNoChangesToAFolder(): void { public function testMakeNoChangesToAFolder(): void {
$this->assertFalse(Arsse::$db->folderPropertiesSet("john.doe@example.com", 6, [])); $this->assertFalse(Arsse::$db->folderPropertiesSet("john.doe@example.com", 6, []));
} }
/**
* @covers \JKingWeb\Arsse\Database::folderPropertiesSet
* @covers \JKingWeb\Arsse\Database::folderValidateName
*/
public function testRenameAFolder(): void { public function testRenameAFolder(): void {
$this->assertTrue(Arsse::$db->folderPropertiesSet("john.doe@example.com", 6, ['name' => "Opinion"])); $this->assertTrue(Arsse::$db->folderPropertiesSet("john.doe@example.com", 6, ['name' => "Opinion"]));
$state = $this->primeExpectations($this->data, ['arsse_folders' => ['id','owner', 'parent', 'name']]); $state = $this->primeExpectations($this->data, ['arsse_folders' => ['id','owner', 'parent', 'name']]);
@ -261,25 +336,45 @@ trait SeriesFolder {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::folderPropertiesSet
* @covers \JKingWeb\Arsse\Database::folderValidateName
*/
public function testRenameTheRootFolder(): void { public function testRenameTheRootFolder(): void {
$this->assertFalse(Arsse::$db->folderPropertiesSet("john.doe@example.com", null, ['name' => "Opinion"])); $this->assertFalse(Arsse::$db->folderPropertiesSet("john.doe@example.com", null, ['name' => "Opinion"]));
} }
/**
* @covers \JKingWeb\Arsse\Database::folderPropertiesSet
* @covers \JKingWeb\Arsse\Database::folderValidateName
*/
public function testRenameAFolderToTheEmptyString(): void { public function testRenameAFolderToTheEmptyString(): void {
$this->assertException("missing", "Db", "ExceptionInput"); $this->assertException("missing", "Db", "ExceptionInput");
$this->assertTrue(Arsse::$db->folderPropertiesSet("john.doe@example.com", 6, ['name' => ""])); $this->assertTrue(Arsse::$db->folderPropertiesSet("john.doe@example.com", 6, ['name' => ""]));
} }
/**
* @covers \JKingWeb\Arsse\Database::folderPropertiesSet
* @covers \JKingWeb\Arsse\Database::folderValidateName
*/
public function testRenameAFolderToWhitespaceOnly(): void { public function testRenameAFolderToWhitespaceOnly(): void {
$this->assertException("whitespace", "Db", "ExceptionInput"); $this->assertException("whitespace", "Db", "ExceptionInput");
$this->assertTrue(Arsse::$db->folderPropertiesSet("john.doe@example.com", 6, ['name' => " "])); $this->assertTrue(Arsse::$db->folderPropertiesSet("john.doe@example.com", 6, ['name' => " "]));
} }
/**
* @covers \JKingWeb\Arsse\Database::folderPropertiesSet
* @covers \JKingWeb\Arsse\Database::folderValidateName
*/
public function testRenameAFolderToAnInvalidValue(): void { public function testRenameAFolderToAnInvalidValue(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
$this->assertTrue(Arsse::$db->folderPropertiesSet("john.doe@example.com", 6, ['name' => []])); $this->assertTrue(Arsse::$db->folderPropertiesSet("john.doe@example.com", 6, ['name' => []]));
} }
/**
* @covers \JKingWeb\Arsse\Database::folderPropertiesSet
* @covers \JKingWeb\Arsse\Database::folderValidateMove
*/
public function testMoveAFolder(): void { public function testMoveAFolder(): void {
$this->assertTrue(Arsse::$db->folderPropertiesSet("john.doe@example.com", 6, ['parent' => 5])); $this->assertTrue(Arsse::$db->folderPropertiesSet("john.doe@example.com", 6, ['parent' => 5]));
$state = $this->primeExpectations($this->data, ['arsse_folders' => ['id','owner', 'parent', 'name']]); $state = $this->primeExpectations($this->data, ['arsse_folders' => ['id','owner', 'parent', 'name']]);
@ -287,51 +382,83 @@ trait SeriesFolder {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::folderPropertiesSet
* @covers \JKingWeb\Arsse\Database::folderValidateMove
*/
public function testMoveTheRootFolder(): void { public function testMoveTheRootFolder(): void {
$this->assertException("circularDependence", "Db", "ExceptionInput"); $this->assertException("circularDependence", "Db", "ExceptionInput");
Arsse::$db->folderPropertiesSet("john.doe@example.com", 0, ['parent' => 1]); Arsse::$db->folderPropertiesSet("john.doe@example.com", 0, ['parent' => 1]);
} }
/**
* @covers \JKingWeb\Arsse\Database::folderPropertiesSet
* @covers \JKingWeb\Arsse\Database::folderValidateMove
*/
public function testMoveAFolderToItsDescendant(): void { public function testMoveAFolderToItsDescendant(): void {
$this->assertException("circularDependence", "Db", "ExceptionInput"); $this->assertException("circularDependence", "Db", "ExceptionInput");
Arsse::$db->folderPropertiesSet("john.doe@example.com", 1, ['parent' => 3]); Arsse::$db->folderPropertiesSet("john.doe@example.com", 1, ['parent' => 3]);
} }
/**
* @covers \JKingWeb\Arsse\Database::folderPropertiesSet
* @covers \JKingWeb\Arsse\Database::folderValidateMove
*/
public function testMoveAFolderToItself(): void { public function testMoveAFolderToItself(): void {
$this->assertException("circularDependence", "Db", "ExceptionInput"); $this->assertException("circularDependence", "Db", "ExceptionInput");
Arsse::$db->folderPropertiesSet("john.doe@example.com", 1, ['parent' => 1]); Arsse::$db->folderPropertiesSet("john.doe@example.com", 1, ['parent' => 1]);
} }
/**
* @covers \JKingWeb\Arsse\Database::folderPropertiesSet
* @covers \JKingWeb\Arsse\Database::folderValidateMove
*/
public function testMoveAFolderToAMissingParent(): void { public function testMoveAFolderToAMissingParent(): void {
$this->assertException("idMissing", "Db", "ExceptionInput"); $this->assertException("idMissing", "Db", "ExceptionInput");
Arsse::$db->folderPropertiesSet("john.doe@example.com", 1, ['parent' => 2112]); Arsse::$db->folderPropertiesSet("john.doe@example.com", 1, ['parent' => 2112]);
} }
/**
* @covers \JKingWeb\Arsse\Database::folderPropertiesSet
* @covers \JKingWeb\Arsse\Database::folderValidateMove
*/
public function testMoveAFolderToAnInvalidParent(): void { public function testMoveAFolderToAnInvalidParent(): void {
$this->assertException("idMissing", "Db", "ExceptionInput"); $this->assertException("idMissing", "Db", "ExceptionInput");
Arsse::$db->folderPropertiesSet("john.doe@example.com", 1, ['parent' => "ThisFolderDoesNotExist"]); Arsse::$db->folderPropertiesSet("john.doe@example.com", 1, ['parent' => "ThisFolderDoesNotExist"]);
} }
/**
* @covers \JKingWeb\Arsse\Database::folderPropertiesSet
* @covers \JKingWeb\Arsse\Database::folderValidateMove
*/
public function testCauseAFolderCollision(): void { public function testCauseAFolderCollision(): void {
$this->assertException("constraintViolation", "Db", "ExceptionInput"); $this->assertException("constraintViolation", "Db", "ExceptionInput");
Arsse::$db->folderPropertiesSet("john.doe@example.com", 6, ['parent' => null]); Arsse::$db->folderPropertiesSet("john.doe@example.com", 6, ['parent' => null]);
} }
/**
* @covers \JKingWeb\Arsse\Database::folderPropertiesSet
* @covers \JKingWeb\Arsse\Database::folderValidateName
* @covers \JKingWeb\Arsse\Database::folderValidateMove
*/
public function testCauseACompoundFolderCollision(): void { public function testCauseACompoundFolderCollision(): void {
$this->assertException("constraintViolation", "Db", "ExceptionInput"); $this->assertException("constraintViolation", "Db", "ExceptionInput");
Arsse::$db->folderPropertiesSet("john.doe@example.com", 3, ['parent' => null, 'name' => "Technology"]); Arsse::$db->folderPropertiesSet("john.doe@example.com", 3, ['parent' => null, 'name' => "Technology"]);
} }
/** @covers \JKingWeb\Arsse\Database::folderPropertiesSet */
public function testSetThePropertiesOfAMissingFolder(): void { public function testSetThePropertiesOfAMissingFolder(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->folderPropertiesSet("john.doe@example.com", 2112, ['parent' => null]); Arsse::$db->folderPropertiesSet("john.doe@example.com", 2112, ['parent' => null]);
} }
/** @covers \JKingWeb\Arsse\Database::folderPropertiesSet */
public function testSetThePropertiesOfAnInvalidFolder(): void { public function testSetThePropertiesOfAnInvalidFolder(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->folderPropertiesSet("john.doe@example.com", -1, ['parent' => null]); Arsse::$db->folderPropertiesSet("john.doe@example.com", -1, ['parent' => null]);
} }
/** @covers \JKingWeb\Arsse\Database::folderPropertiesSet */
public function testSetThePropertiesOfAFolderForTheWrongOwner(): void { public function testSetThePropertiesOfAFolderForTheWrongOwner(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->folderPropertiesSet("john.doe@example.com", 4, ['parent' => null]); // folder ID 4 belongs to Jane Arsse::$db->folderPropertiesSet("john.doe@example.com", 4, ['parent' => null]); // folder ID 4 belongs to Jane

View file

@ -83,6 +83,7 @@ trait SeriesIcon {
unset($this->data); unset($this->data);
} }
/** @covers \JKingWeb\Arsse\Database::iconList */
public function testListTheIconsOfAUser() { public function testListTheIconsOfAUser() {
$exp = [ $exp = [
['id' => 1,'url' => 'http://localhost:8000/Icon/PNG', 'type' => 'image/png', 'data' => base64_decode("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMjHxIGmVAAAADUlEQVQYV2NgYGBgAAAABQABijPjAAAAAABJRU5ErkJggg==")], ['id' => 1,'url' => 'http://localhost:8000/Icon/PNG', 'type' => 'image/png', 'data' => base64_decode("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMjHxIGmVAAAADUlEQVQYV2NgYGBgAAAABQABijPjAAAAAABJRU5ErkJggg==")],

View file

@ -255,6 +255,10 @@ trait SeriesLabel {
unset($this->data, $this->checkLabels, $this->checkMembers, $this->user); unset($this->data, $this->checkLabels, $this->checkMembers, $this->user);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelAdd
* @covers \JKingWeb\Arsse\Database::labelValidateName
*/
public function testAddALabel(): void { public function testAddALabel(): void {
$user = "john.doe@example.com"; $user = "john.doe@example.com";
$labelID = $this->nextID("arsse_labels"); $labelID = $this->nextID("arsse_labels");
@ -264,26 +268,43 @@ trait SeriesLabel {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelAdd
* @covers \JKingWeb\Arsse\Database::labelValidateName
*/
public function testAddADuplicateLabel(): void { public function testAddADuplicateLabel(): void {
$this->assertException("constraintViolation", "Db", "ExceptionInput"); $this->assertException("constraintViolation", "Db", "ExceptionInput");
Arsse::$db->labelAdd("john.doe@example.com", ['name' => "Interesting"]); Arsse::$db->labelAdd("john.doe@example.com", ['name' => "Interesting"]);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelAdd
* @covers \JKingWeb\Arsse\Database::labelValidateName
*/
public function testAddALabelWithAMissingName(): void { public function testAddALabelWithAMissingName(): void {
$this->assertException("missing", "Db", "ExceptionInput"); $this->assertException("missing", "Db", "ExceptionInput");
Arsse::$db->labelAdd("john.doe@example.com", []); Arsse::$db->labelAdd("john.doe@example.com", []);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelAdd
* @covers \JKingWeb\Arsse\Database::labelValidateName
*/
public function testAddALabelWithABlankName(): void { public function testAddALabelWithABlankName(): void {
$this->assertException("missing", "Db", "ExceptionInput"); $this->assertException("missing", "Db", "ExceptionInput");
Arsse::$db->labelAdd("john.doe@example.com", ['name' => ""]); Arsse::$db->labelAdd("john.doe@example.com", ['name' => ""]);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelAdd
* @covers \JKingWeb\Arsse\Database::labelValidateName
*/
public function testAddALabelWithAWhitespaceName(): void { public function testAddALabelWithAWhitespaceName(): void {
$this->assertException("whitespace", "Db", "ExceptionInput"); $this->assertException("whitespace", "Db", "ExceptionInput");
Arsse::$db->labelAdd("john.doe@example.com", ['name' => " "]); Arsse::$db->labelAdd("john.doe@example.com", ['name' => " "]);
} }
/** @covers \JKingWeb\Arsse\Database::labelList */
public function testListLabels(): void { public function testListLabels(): void {
$exp = [ $exp = [
['id' => 2, 'name' => "Fascinating", 'articles' => 3, 'read' => 1], ['id' => 2, 'name' => "Fascinating", 'articles' => 3, 'read' => 1],
@ -299,6 +320,10 @@ trait SeriesLabel {
$this->assertResult($exp, Arsse::$db->labelList("jane.doe@example.com", false)); $this->assertResult($exp, Arsse::$db->labelList("jane.doe@example.com", false));
} }
/**
* @covers \JKingWeb\Arsse\Database::labelRemove
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testRemoveALabel(): void { public function testRemoveALabel(): void {
$this->assertTrue(Arsse::$db->labelRemove("john.doe@example.com", 1)); $this->assertTrue(Arsse::$db->labelRemove("john.doe@example.com", 1));
$state = $this->primeExpectations($this->data, $this->checkLabels); $state = $this->primeExpectations($this->data, $this->checkLabels);
@ -306,6 +331,10 @@ trait SeriesLabel {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelRemove
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testRemoveALabelByName(): void { public function testRemoveALabelByName(): void {
$this->assertTrue(Arsse::$db->labelRemove("john.doe@example.com", "Interesting", true)); $this->assertTrue(Arsse::$db->labelRemove("john.doe@example.com", "Interesting", true));
$state = $this->primeExpectations($this->data, $this->checkLabels); $state = $this->primeExpectations($this->data, $this->checkLabels);
@ -313,26 +342,46 @@ trait SeriesLabel {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelRemove
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testRemoveAMissingLabel(): void { public function testRemoveAMissingLabel(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->labelRemove("john.doe@example.com", 2112); Arsse::$db->labelRemove("john.doe@example.com", 2112);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelRemove
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testRemoveAnInvalidLabel(): void { public function testRemoveAnInvalidLabel(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->labelRemove("john.doe@example.com", -1); Arsse::$db->labelRemove("john.doe@example.com", -1);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelRemove
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testRemoveAnInvalidLabelByName(): void { public function testRemoveAnInvalidLabelByName(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->labelRemove("john.doe@example.com", [], true); Arsse::$db->labelRemove("john.doe@example.com", [], true);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelRemove
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testRemoveALabelOfTheWrongOwner(): void { public function testRemoveALabelOfTheWrongOwner(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->labelRemove("john.doe@example.com", 3); // label ID 3 belongs to Jane Arsse::$db->labelRemove("john.doe@example.com", 3); // label ID 3 belongs to Jane
} }
/**
* @covers \JKingWeb\Arsse\Database::labelPropertiesGet
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testGetThePropertiesOfALabel(): void { public function testGetThePropertiesOfALabel(): void {
$exp = [ $exp = [
'id' => 2, 'id' => 2,
@ -344,30 +393,56 @@ trait SeriesLabel {
$this->assertArraySubset($exp, Arsse::$db->labelPropertiesGet("john.doe@example.com", "Fascinating", true)); $this->assertArraySubset($exp, Arsse::$db->labelPropertiesGet("john.doe@example.com", "Fascinating", true));
} }
/**
* @covers \JKingWeb\Arsse\Database::labelPropertiesGet
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testGetThePropertiesOfAMissingLabel(): void { public function testGetThePropertiesOfAMissingLabel(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->labelPropertiesGet("john.doe@example.com", 2112); Arsse::$db->labelPropertiesGet("john.doe@example.com", 2112);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelPropertiesGet
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testGetThePropertiesOfAnInvalidLabel(): void { public function testGetThePropertiesOfAnInvalidLabel(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->labelPropertiesGet("john.doe@example.com", -1); Arsse::$db->labelPropertiesGet("john.doe@example.com", -1);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelPropertiesGet
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testGetThePropertiesOfAnInvalidLabelByName(): void { public function testGetThePropertiesOfAnInvalidLabelByName(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->labelPropertiesGet("john.doe@example.com", [], true); Arsse::$db->labelPropertiesGet("john.doe@example.com", [], true);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelPropertiesGet
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testGetThePropertiesOfALabelOfTheWrongOwner(): void { public function testGetThePropertiesOfALabelOfTheWrongOwner(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->labelPropertiesGet("john.doe@example.com", 3); // label ID 3 belongs to Jane Arsse::$db->labelPropertiesGet("john.doe@example.com", 3); // label ID 3 belongs to Jane
} }
/**
* @covers \JKingWeb\Arsse\Database::labelPropertiesSet
* @covers \JKingWeb\Arsse\Database::labelValidateId
* @covers \JKingWeb\Arsse\Database::labelValidateName
*/
public function testMakeNoChangesToALabel(): void { public function testMakeNoChangesToALabel(): void {
$this->assertFalse(Arsse::$db->labelPropertiesSet("john.doe@example.com", 1, [])); $this->assertFalse(Arsse::$db->labelPropertiesSet("john.doe@example.com", 1, []));
} }
/**
* @covers \JKingWeb\Arsse\Database::labelPropertiesSet
* @covers \JKingWeb\Arsse\Database::labelValidateId
* @covers \JKingWeb\Arsse\Database::labelValidateName
*/
public function testRenameALabel(): void { public function testRenameALabel(): void {
$this->assertTrue(Arsse::$db->labelPropertiesSet("john.doe@example.com", 1, ['name' => "Curious"])); $this->assertTrue(Arsse::$db->labelPropertiesSet("john.doe@example.com", 1, ['name' => "Curious"]));
$state = $this->primeExpectations($this->data, $this->checkLabels); $state = $this->primeExpectations($this->data, $this->checkLabels);
@ -375,6 +450,11 @@ trait SeriesLabel {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelPropertiesSet
* @covers \JKingWeb\Arsse\Database::labelValidateId
* @covers \JKingWeb\Arsse\Database::labelValidateName
*/
public function testRenameALabelByName(): void { public function testRenameALabelByName(): void {
$this->assertTrue(Arsse::$db->labelPropertiesSet("john.doe@example.com", "Interesting", ['name' => "Curious"], true)); $this->assertTrue(Arsse::$db->labelPropertiesSet("john.doe@example.com", "Interesting", ['name' => "Curious"], true));
$state = $this->primeExpectations($this->data, $this->checkLabels); $state = $this->primeExpectations($this->data, $this->checkLabels);
@ -382,46 +462,90 @@ trait SeriesLabel {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelPropertiesSet
* @covers \JKingWeb\Arsse\Database::labelValidateId
* @covers \JKingWeb\Arsse\Database::labelValidateName
*/
public function testRenameALabelToTheEmptyString(): void { public function testRenameALabelToTheEmptyString(): void {
$this->assertException("missing", "Db", "ExceptionInput"); $this->assertException("missing", "Db", "ExceptionInput");
$this->assertTrue(Arsse::$db->labelPropertiesSet("john.doe@example.com", 1, ['name' => ""])); $this->assertTrue(Arsse::$db->labelPropertiesSet("john.doe@example.com", 1, ['name' => ""]));
} }
/**
* @covers \JKingWeb\Arsse\Database::labelPropertiesSet
* @covers \JKingWeb\Arsse\Database::labelValidateId
* @covers \JKingWeb\Arsse\Database::labelValidateName
*/
public function testRenameALabelToWhitespaceOnly(): void { public function testRenameALabelToWhitespaceOnly(): void {
$this->assertException("whitespace", "Db", "ExceptionInput"); $this->assertException("whitespace", "Db", "ExceptionInput");
$this->assertTrue(Arsse::$db->labelPropertiesSet("john.doe@example.com", 1, ['name' => " "])); $this->assertTrue(Arsse::$db->labelPropertiesSet("john.doe@example.com", 1, ['name' => " "]));
} }
/**
* @covers \JKingWeb\Arsse\Database::labelPropertiesSet
* @covers \JKingWeb\Arsse\Database::labelValidateId
* @covers \JKingWeb\Arsse\Database::labelValidateName
*/
public function testRenameALabelToAnInvalidValue(): void { public function testRenameALabelToAnInvalidValue(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
$this->assertTrue(Arsse::$db->labelPropertiesSet("john.doe@example.com", 1, ['name' => []])); $this->assertTrue(Arsse::$db->labelPropertiesSet("john.doe@example.com", 1, ['name' => []]));
} }
/**
* @covers \JKingWeb\Arsse\Database::labelPropertiesSet
* @covers \JKingWeb\Arsse\Database::labelValidateId
* @covers \JKingWeb\Arsse\Database::labelValidateName
*/
public function testCauseALabelCollision(): void { public function testCauseALabelCollision(): void {
$this->assertException("constraintViolation", "Db", "ExceptionInput"); $this->assertException("constraintViolation", "Db", "ExceptionInput");
Arsse::$db->labelPropertiesSet("john.doe@example.com", 1, ['name' => "Fascinating"]); Arsse::$db->labelPropertiesSet("john.doe@example.com", 1, ['name' => "Fascinating"]);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelPropertiesSet
* @covers \JKingWeb\Arsse\Database::labelValidateId
* @covers \JKingWeb\Arsse\Database::labelValidateName
*/
public function testSetThePropertiesOfAMissingLabel(): void { public function testSetThePropertiesOfAMissingLabel(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->labelPropertiesSet("john.doe@example.com", 2112, ['name' => "Exciting"]); Arsse::$db->labelPropertiesSet("john.doe@example.com", 2112, ['name' => "Exciting"]);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelPropertiesSet
* @covers \JKingWeb\Arsse\Database::labelValidateId
* @covers \JKingWeb\Arsse\Database::labelValidateName
*/
public function testSetThePropertiesOfAnInvalidLabel(): void { public function testSetThePropertiesOfAnInvalidLabel(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->labelPropertiesSet("john.doe@example.com", -1, ['name' => "Exciting"]); Arsse::$db->labelPropertiesSet("john.doe@example.com", -1, ['name' => "Exciting"]);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelPropertiesSet
* @covers \JKingWeb\Arsse\Database::labelValidateId
* @covers \JKingWeb\Arsse\Database::labelValidateName
*/
public function testSetThePropertiesOfAnInvalidLabelByName(): void { public function testSetThePropertiesOfAnInvalidLabelByName(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->labelPropertiesSet("john.doe@example.com", [], ['name' => "Exciting"], true); Arsse::$db->labelPropertiesSet("john.doe@example.com", [], ['name' => "Exciting"], true);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelPropertiesSet
* @covers \JKingWeb\Arsse\Database::labelValidateId
* @covers \JKingWeb\Arsse\Database::labelValidateName
*/
public function testSetThePropertiesOfALabelForTheWrongOwner(): void { public function testSetThePropertiesOfALabelForTheWrongOwner(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->labelPropertiesSet("john.doe@example.com", 3, ['name' => "Exciting"]); // label ID 3 belongs to Jane Arsse::$db->labelPropertiesSet("john.doe@example.com", 3, ['name' => "Exciting"]); // label ID 3 belongs to Jane
} }
/**
* @covers \JKingWeb\Arsse\Database::labelArticlesGet
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testListLabelledArticles(): void { public function testListLabelledArticles(): void {
$exp = [1,19]; $exp = [1,19];
$this->assertEquals($exp, Arsse::$db->labelArticlesGet("john.doe@example.com", 1)); $this->assertEquals($exp, Arsse::$db->labelArticlesGet("john.doe@example.com", 1));
@ -434,16 +558,28 @@ trait SeriesLabel {
$this->assertEquals($exp, Arsse::$db->labelArticlesGet("john.doe@example.com", "Lonely", true)); $this->assertEquals($exp, Arsse::$db->labelArticlesGet("john.doe@example.com", "Lonely", true));
} }
/**
* @covers \JKingWeb\Arsse\Database::labelArticlesGet
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testListLabelledArticlesForAMissingLabel(): void { public function testListLabelledArticlesForAMissingLabel(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->labelArticlesGet("john.doe@example.com", 3); Arsse::$db->labelArticlesGet("john.doe@example.com", 3);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelArticlesGet
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testListLabelledArticlesForAnInvalidLabel(): void { public function testListLabelledArticlesForAnInvalidLabel(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->labelArticlesGet("john.doe@example.com", -1); Arsse::$db->labelArticlesGet("john.doe@example.com", -1);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelArticlesSet
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testApplyALabelToArticles(): void { public function testApplyALabelToArticles(): void {
Arsse::$db->labelArticlesSet("john.doe@example.com", 1, (new Context)->articles([2,5])); Arsse::$db->labelArticlesSet("john.doe@example.com", 1, (new Context)->articles([2,5]));
$state = $this->primeExpectations($this->data, $this->checkMembers); $state = $this->primeExpectations($this->data, $this->checkMembers);
@ -452,6 +588,10 @@ trait SeriesLabel {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelArticlesSet
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testClearALabelFromArticles(): void { public function testClearALabelFromArticles(): void {
Arsse::$db->labelArticlesSet("john.doe@example.com", 1, (new Context)->articles([1,5]), Database::ASSOC_REMOVE); Arsse::$db->labelArticlesSet("john.doe@example.com", 1, (new Context)->articles([1,5]), Database::ASSOC_REMOVE);
$state = $this->primeExpectations($this->data, $this->checkMembers); $state = $this->primeExpectations($this->data, $this->checkMembers);
@ -459,6 +599,10 @@ trait SeriesLabel {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelArticlesSet
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testApplyALabelToArticlesByName(): void { public function testApplyALabelToArticlesByName(): void {
Arsse::$db->labelArticlesSet("john.doe@example.com", "Interesting", (new Context)->articles([2,5]), Database::ASSOC_ADD, true); Arsse::$db->labelArticlesSet("john.doe@example.com", "Interesting", (new Context)->articles([2,5]), Database::ASSOC_ADD, true);
$state = $this->primeExpectations($this->data, $this->checkMembers); $state = $this->primeExpectations($this->data, $this->checkMembers);
@ -467,6 +611,10 @@ trait SeriesLabel {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelArticlesSet
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testClearALabelFromArticlesByName(): void { public function testClearALabelFromArticlesByName(): void {
Arsse::$db->labelArticlesSet("john.doe@example.com", "Interesting", (new Context)->articles([1,5]), Database::ASSOC_REMOVE, true); Arsse::$db->labelArticlesSet("john.doe@example.com", "Interesting", (new Context)->articles([1,5]), Database::ASSOC_REMOVE, true);
$state = $this->primeExpectations($this->data, $this->checkMembers); $state = $this->primeExpectations($this->data, $this->checkMembers);
@ -474,18 +622,30 @@ trait SeriesLabel {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelArticlesSet
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testApplyALabelToNoArticles(): void { public function testApplyALabelToNoArticles(): void {
Arsse::$db->labelArticlesSet("john.doe@example.com", 1, (new Context)->articles([10000])); Arsse::$db->labelArticlesSet("john.doe@example.com", 1, (new Context)->articles([10000]));
$state = $this->primeExpectations($this->data, $this->checkMembers); $state = $this->primeExpectations($this->data, $this->checkMembers);
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelArticlesSet
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testClearALabelFromNoArticles(): void { public function testClearALabelFromNoArticles(): void {
Arsse::$db->labelArticlesSet("john.doe@example.com", 1, (new Context)->articles([10000]), Database::ASSOC_REMOVE); Arsse::$db->labelArticlesSet("john.doe@example.com", 1, (new Context)->articles([10000]), Database::ASSOC_REMOVE);
$state = $this->primeExpectations($this->data, $this->checkMembers); $state = $this->primeExpectations($this->data, $this->checkMembers);
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelArticlesSet
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testReplaceArticlesOfALabel(): void { public function testReplaceArticlesOfALabel(): void {
Arsse::$db->labelArticlesSet("john.doe@example.com", 1, (new Context)->articles([2,5]), Database::ASSOC_REPLACE); Arsse::$db->labelArticlesSet("john.doe@example.com", 1, (new Context)->articles([2,5]), Database::ASSOC_REPLACE);
$state = $this->primeExpectations($this->data, $this->checkMembers); $state = $this->primeExpectations($this->data, $this->checkMembers);
@ -496,6 +656,10 @@ trait SeriesLabel {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::labelArticlesSet
* @covers \JKingWeb\Arsse\Database::labelValidateId
*/
public function testPurgeArticlesOfALabel(): void { public function testPurgeArticlesOfALabel(): void {
Arsse::$db->labelArticlesSet("john.doe@example.com", 1, (new Context)->articles([10000]), Database::ASSOC_REPLACE); Arsse::$db->labelArticlesSet("john.doe@example.com", 1, (new Context)->articles([10000]), Database::ASSOC_REPLACE);
$state = $this->primeExpectations($this->data, $this->checkMembers); $state = $this->primeExpectations($this->data, $this->checkMembers);

View file

@ -36,6 +36,7 @@ trait SeriesMeta {
unset($this->data); unset($this->data);
} }
/** @covers \JKingWeb\Arsse\Database::metaSet */
public function testAddANewValue(): void { public function testAddANewValue(): void {
$this->assertTrue(Arsse::$db->metaSet("favourite", "Cygnus X-1")); $this->assertTrue(Arsse::$db->metaSet("favourite", "Cygnus X-1"));
$state = $this->primeExpectations($this->data, ['arsse_meta' => ['key','value']]); $state = $this->primeExpectations($this->data, ['arsse_meta' => ['key','value']]);
@ -43,6 +44,7 @@ trait SeriesMeta {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::metaSet */
public function testAddANewTypedValue(): void { public function testAddANewTypedValue(): void {
$this->assertTrue(Arsse::$db->metaSet("answer", 42, "int")); $this->assertTrue(Arsse::$db->metaSet("answer", 42, "int"));
$this->assertTrue(Arsse::$db->metaSet("true", true, "bool")); $this->assertTrue(Arsse::$db->metaSet("true", true, "bool"));
@ -56,6 +58,7 @@ trait SeriesMeta {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::metaSet */
public function testChangeAnExistingValue(): void { public function testChangeAnExistingValue(): void {
$this->assertTrue(Arsse::$db->metaSet("album", "Hemispheres")); $this->assertTrue(Arsse::$db->metaSet("album", "Hemispheres"));
$state = $this->primeExpectations($this->data, ['arsse_meta' => ['key','value']]); $state = $this->primeExpectations($this->data, ['arsse_meta' => ['key','value']]);
@ -63,6 +66,7 @@ trait SeriesMeta {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::metaRemove */
public function testRemoveAValue(): void { public function testRemoveAValue(): void {
$this->assertTrue(Arsse::$db->metaRemove("album")); $this->assertTrue(Arsse::$db->metaRemove("album"));
$this->assertFalse(Arsse::$db->metaRemove("album")); $this->assertFalse(Arsse::$db->metaRemove("album"));
@ -71,6 +75,7 @@ trait SeriesMeta {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::metaGet */
public function testRetrieveAValue(): void { public function testRetrieveAValue(): void {
$this->assertSame("".Database::SCHEMA_VERSION, Arsse::$db->metaGet("schema_version")); $this->assertSame("".Database::SCHEMA_VERSION, Arsse::$db->metaGet("schema_version"));
$this->assertSame("A Farewell to Kings", Arsse::$db->metaGet("album")); $this->assertSame("A Farewell to Kings", Arsse::$db->metaGet("album"));

View file

@ -20,12 +20,22 @@ trait SeriesMiscellany {
protected function tearDownSeriesMiscellany(): void { protected function tearDownSeriesMiscellany(): void {
} }
/**
* @covers \JKingWeb\Arsse\Database::__construct
* @covers \JKingWeb\Arsse\Database::driverSchemaVersion
* @covers \JKingWeb\Arsse\Database::driverSchemaUpdate
*/
public function testInitializeDatabase(): void { public function testInitializeDatabase(): void {
static::dbRaze(static::$drv); static::dbRaze(static::$drv);
$d = new Database(true); $d = new Database(true);
$this->assertSame(Database::SCHEMA_VERSION, $d->driverSchemaVersion()); $this->assertSame(Database::SCHEMA_VERSION, $d->driverSchemaVersion());
} }
/**
* @covers \JKingWeb\Arsse\Database::__construct
* @covers \JKingWeb\Arsse\Database::driverSchemaVersion
* @covers \JKingWeb\Arsse\Database::driverSchemaUpdate
*/
public function testManuallyInitializeDatabase(): void { public function testManuallyInitializeDatabase(): void {
static::dbRaze(static::$drv); static::dbRaze(static::$drv);
$d = new Database(false); $d = new Database(false);
@ -35,10 +45,12 @@ trait SeriesMiscellany {
$this->assertFalse($d->driverSchemaUpdate()); $this->assertFalse($d->driverSchemaUpdate());
} }
/** @covers \JKingWeb\Arsse\Database::driverCharsetAcceptable */
public function testCheckCharacterSetAcceptability(): void { public function testCheckCharacterSetAcceptability(): void {
$this->assertIsBool(Arsse::$db->driverCharsetAcceptable()); $this->assertIsBool(Arsse::$db->driverCharsetAcceptable());
} }
/** @covers \JKingWeb\Arsse\Database::driverMaintenance */
public function testPerformMaintenance(): void { public function testPerformMaintenance(): void {
$this->assertTrue(Arsse::$db->driverMaintenance()); $this->assertTrue(Arsse::$db->driverMaintenance());
} }

View file

@ -55,6 +55,10 @@ trait SeriesSession {
unset($this->data); unset($this->data);
} }
/**
* @covers \JKingWeb\Arsse\Database::sessionResume
* @covers \JKingWeb\Arsse\Database::sessionExpiringSoon
*/
public function testResumeAValidSession(): void { public function testResumeAValidSession(): void {
$exp1 = [ $exp1 = [
'id' => "80fa94c1a11f11e78667001e673b2560", 'id' => "80fa94c1a11f11e78667001e673b2560",
@ -73,21 +77,34 @@ trait SeriesSession {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::sessionResume
* @covers \JKingWeb\Arsse\Database::sessionExpiringSoon
*/
public function testResumeAMissingSession(): void { public function testResumeAMissingSession(): void {
$this->assertException("invalid", "User", "ExceptionSession"); $this->assertException("invalid", "User", "ExceptionSession");
Arsse::$db->sessionResume("thisSessionDoesNotExist"); Arsse::$db->sessionResume("thisSessionDoesNotExist");
} }
/**
* @covers \JKingWeb\Arsse\Database::sessionResume
* @covers \JKingWeb\Arsse\Database::sessionExpiringSoon
*/
public function testResumeAnExpiredSession(): void { public function testResumeAnExpiredSession(): void {
$this->assertException("invalid", "User", "ExceptionSession"); $this->assertException("invalid", "User", "ExceptionSession");
Arsse::$db->sessionResume("27c6de8da13311e78667001e673b2560"); Arsse::$db->sessionResume("27c6de8da13311e78667001e673b2560");
} }
/**
* @covers \JKingWeb\Arsse\Database::sessionResume
* @covers \JKingWeb\Arsse\Database::sessionExpiringSoon
*/
public function testResumeAStaleSession(): void { public function testResumeAStaleSession(): void {
$this->assertException("invalid", "User", "ExceptionSession"); $this->assertException("invalid", "User", "ExceptionSession");
Arsse::$db->sessionResume("ab3b3eb8a13311e78667001e673b2560"); Arsse::$db->sessionResume("ab3b3eb8a13311e78667001e673b2560");
} }
/** @covers \JKingWeb\Arsse\Database::sessionCreate */
public function testCreateASession(): void { public function testCreateASession(): void {
$user = "jane.doe@example.com"; $user = "jane.doe@example.com";
$id = Arsse::$db->sessionCreate($user); $id = Arsse::$db->sessionCreate($user);
@ -97,6 +114,7 @@ trait SeriesSession {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::sessionDestroy */
public function testDestroyASession(): void { public function testDestroyASession(): void {
$user = "jane.doe@example.com"; $user = "jane.doe@example.com";
$id = "80fa94c1a11f11e78667001e673b2560"; $id = "80fa94c1a11f11e78667001e673b2560";
@ -108,6 +126,7 @@ trait SeriesSession {
$this->assertFalse(Arsse::$db->sessionDestroy($user, $id)); $this->assertFalse(Arsse::$db->sessionDestroy($user, $id));
} }
/** @covers \JKingWeb\Arsse\Database::sessionDestroy */
public function testDestroyAllSessions(): void { public function testDestroyAllSessions(): void {
$user = "jane.doe@example.com"; $user = "jane.doe@example.com";
$this->assertTrue(Arsse::$db->sessionDestroy($user)); $this->assertTrue(Arsse::$db->sessionDestroy($user));
@ -118,6 +137,7 @@ trait SeriesSession {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::sessionDestroy */
public function testDestroyASessionForTheWrongUser(): void { public function testDestroyASessionForTheWrongUser(): void {
$user = "john.doe@example.com"; $user = "john.doe@example.com";
$id = "80fa94c1a11f11e78667001e673b2560"; $id = "80fa94c1a11f11e78667001e673b2560";

View file

@ -204,6 +204,10 @@ trait SeriesSubscription {
unset($this->data, $this->user); unset($this->data, $this->user);
} }
/**
* @covers \JKingWeb\Arsse\Database::subscriptionAdd
* @covers \JKingWeb\Arsse\Database::feedAdd
*/
public function testAddASubscriptionToAnExistingFeed(): void { public function testAddASubscriptionToAnExistingFeed(): void {
$url = "http://example.com/feed1"; $url = "http://example.com/feed1";
$subID = $this->nextID("arsse_subscriptions"); $subID = $this->nextID("arsse_subscriptions");
@ -220,6 +224,10 @@ trait SeriesSubscription {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::subscriptionAdd
* @covers \JKingWeb\Arsse\Database::feedAdd
*/
public function testAddASubscriptionToANewFeed(): void { public function testAddASubscriptionToANewFeed(): void {
$url = "http://example.org/feed1"; $url = "http://example.org/feed1";
$feedID = $this->nextID("arsse_feeds"); $feedID = $this->nextID("arsse_feeds");
@ -238,6 +246,10 @@ trait SeriesSubscription {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::subscriptionAdd
* @covers \JKingWeb\Arsse\Database::feedAdd
*/
public function testAddASubscriptionToANewFeedViaDiscovery(): void { public function testAddASubscriptionToANewFeedViaDiscovery(): void {
$url = "http://localhost:8000/Feed/Discovery/Valid"; $url = "http://localhost:8000/Feed/Discovery/Valid";
$discovered = "http://localhost:8000/Feed/Discovery/Feed"; $discovered = "http://localhost:8000/Feed/Discovery/Feed";
@ -257,6 +269,10 @@ trait SeriesSubscription {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::subscriptionAdd
* @covers \JKingWeb\Arsse\Database::feedAdd
*/
public function testAddASubscriptionToAnInvalidFeed(): void { public function testAddASubscriptionToAnInvalidFeed(): void {
$url = "http://example.org/feed1"; $url = "http://example.org/feed1";
$feedID = $this->nextID("arsse_feeds"); $feedID = $this->nextID("arsse_feeds");
@ -276,18 +292,30 @@ trait SeriesSubscription {
} }
} }
/**
* @covers \JKingWeb\Arsse\Database::subscriptionAdd
* @covers \JKingWeb\Arsse\Database::feedAdd
*/
public function testAddADuplicateSubscription(): void { public function testAddADuplicateSubscription(): void {
$url = "http://example.com/feed2"; $url = "http://example.com/feed2";
$this->assertException("constraintViolation", "Db", "ExceptionInput"); $this->assertException("constraintViolation", "Db", "ExceptionInput");
Arsse::$db->subscriptionAdd($this->user, $url); Arsse::$db->subscriptionAdd($this->user, $url);
} }
/**
* @covers \JKingWeb\Arsse\Database::subscriptionAdd
* @covers \JKingWeb\Arsse\Database::feedAdd
*/
public function testAddADuplicateSubscriptionWithEquivalentUrl(): void { public function testAddADuplicateSubscriptionWithEquivalentUrl(): void {
$url = "http://EXAMPLE.COM/feed2"; $url = "http://EXAMPLE.COM/feed2";
$this->assertException("constraintViolation", "Db", "ExceptionInput"); $this->assertException("constraintViolation", "Db", "ExceptionInput");
Arsse::$db->subscriptionAdd($this->user, $url); Arsse::$db->subscriptionAdd($this->user, $url);
} }
/**
* @covers \JKingWeb\Arsse\Database::subscriptionAdd
* @covers \JKingWeb\Arsse\Database::feedAdd
*/
public function testAddADuplicateSubscriptionViaRedirection(): void { public function testAddADuplicateSubscriptionViaRedirection(): void {
$url = "http://localhost:8000/Feed/Parsing/Valid"; $url = "http://localhost:8000/Feed/Parsing/Valid";
Arsse::$db->subscriptionAdd($this->user, $url); Arsse::$db->subscriptionAdd($this->user, $url);
@ -296,6 +324,7 @@ trait SeriesSubscription {
$this->assertSame($subID, Arsse::$db->subscriptionAdd($this->user, $url)); $this->assertSame($subID, Arsse::$db->subscriptionAdd($this->user, $url));
} }
/** @covers \JKingWeb\Arsse\Database::subscriptionRemove */
public function testRemoveASubscription(): void { public function testRemoveASubscription(): void {
$this->assertTrue(Arsse::$db->subscriptionRemove($this->user, 1)); $this->assertTrue(Arsse::$db->subscriptionRemove($this->user, 1));
$state = $this->primeExpectations($this->data, [ $state = $this->primeExpectations($this->data, [
@ -306,22 +335,29 @@ trait SeriesSubscription {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::subscriptionRemove */
public function testRemoveAMissingSubscription(): void { public function testRemoveAMissingSubscription(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->subscriptionRemove($this->user, 2112); Arsse::$db->subscriptionRemove($this->user, 2112);
} }
/** @covers \JKingWeb\Arsse\Database::subscriptionRemove */
public function testRemoveAnInvalidSubscription(): void { public function testRemoveAnInvalidSubscription(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->subscriptionRemove($this->user, -1); Arsse::$db->subscriptionRemove($this->user, -1);
} }
/** @covers \JKingWeb\Arsse\Database::subscriptionRemove */
public function testRemoveASubscriptionForTheWrongOwner(): void { public function testRemoveASubscriptionForTheWrongOwner(): void {
$this->user = "jane.doe@example.com"; $this->user = "jane.doe@example.com";
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->subscriptionRemove($this->user, 1); Arsse::$db->subscriptionRemove($this->user, 1);
} }
/**
* @covers \JKingWeb\Arsse\Database::subscriptionList
* @covers \JKingWeb\Arsse\Database::subscriptionPropertiesGet
*/
public function testListSubscriptions(): void { public function testListSubscriptions(): void {
$exp = [ $exp = [
[ [
@ -382,6 +418,7 @@ trait SeriesSubscription {
$this->assertResult($exp, Arsse::$db->subscriptionList("jill.doe@example.com")); $this->assertResult($exp, Arsse::$db->subscriptionList("jill.doe@example.com"));
} }
/** @covers \JKingWeb\Arsse\Database::subscriptionList */
public function testListSubscriptionsInAFolder(): void { public function testListSubscriptionsInAFolder(): void {
$exp = [ $exp = [
[ [
@ -397,6 +434,7 @@ trait SeriesSubscription {
$this->assertResult($exp, Arsse::$db->subscriptionList($this->user, null, false)); $this->assertResult($exp, Arsse::$db->subscriptionList($this->user, null, false));
} }
/** @covers \JKingWeb\Arsse\Database::subscriptionList */
public function testListSubscriptionsWithRecursion(): void { public function testListSubscriptionsWithRecursion(): void {
$exp = [ $exp = [
[ [
@ -412,31 +450,41 @@ trait SeriesSubscription {
$this->assertResult($exp, Arsse::$db->subscriptionList($this->user, 2)); $this->assertResult($exp, Arsse::$db->subscriptionList($this->user, 2));
} }
/** @covers \JKingWeb\Arsse\Database::subscriptionList */
public function testListSubscriptionsInAMissingFolder(): void { public function testListSubscriptionsInAMissingFolder(): void {
$this->assertException("idMissing", "Db", "ExceptionInput"); $this->assertException("idMissing", "Db", "ExceptionInput");
Arsse::$db->subscriptionList($this->user, 4); Arsse::$db->subscriptionList($this->user, 4);
} }
/** @covers \JKingWeb\Arsse\Database::subscriptionCount */
public function testCountSubscriptions(): void { public function testCountSubscriptions(): void {
$this->assertSame(3, Arsse::$db->subscriptionCount($this->user)); $this->assertSame(3, Arsse::$db->subscriptionCount($this->user));
$this->assertSame(1, Arsse::$db->subscriptionCount($this->user, 2)); $this->assertSame(1, Arsse::$db->subscriptionCount($this->user, 2));
} }
/** @covers \JKingWeb\Arsse\Database::subscriptionCount */
public function testCountSubscriptionsInAMissingFolder(): void { public function testCountSubscriptionsInAMissingFolder(): void {
$this->assertException("idMissing", "Db", "ExceptionInput"); $this->assertException("idMissing", "Db", "ExceptionInput");
Arsse::$db->subscriptionCount($this->user, 4); Arsse::$db->subscriptionCount($this->user, 4);
} }
/** @covers \JKingWeb\Arsse\Database::subscriptionPropertiesGet */
public function testGetThePropertiesOfAMissingSubscription(): void { public function testGetThePropertiesOfAMissingSubscription(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->subscriptionPropertiesGet($this->user, 2112); Arsse::$db->subscriptionPropertiesGet($this->user, 2112);
} }
/** @covers \JKingWeb\Arsse\Database::subscriptionPropertiesGet */
public function testGetThePropertiesOfAnInvalidSubscription(): void { public function testGetThePropertiesOfAnInvalidSubscription(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->subscriptionPropertiesGet($this->user, -1); Arsse::$db->subscriptionPropertiesGet($this->user, -1);
} }
/**
* @covers \JKingWeb\Arsse\Database::subscriptionPropertiesSet
* @covers \JKingWeb\Arsse\Database::subscriptionValidateId
* @covers \JKingWeb\Arsse\Database::subscriptionRulesApply
*/
public function testSetThePropertiesOfASubscription(): void { public function testSetThePropertiesOfASubscription(): void {
Arsse::$db->subscriptionPropertiesSet($this->user, 1, [ Arsse::$db->subscriptionPropertiesSet($this->user, 1, [
'title' => "Ook Ook", 'title' => "Ook Ook",
@ -465,16 +513,31 @@ trait SeriesSubscription {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::subscriptionPropertiesSet
* @covers \JKingWeb\Arsse\Database::subscriptionValidateId
* @covers \JKingWeb\Arsse\Database::subscriptionRulesApply
*/
public function testMoveASubscriptionToAMissingFolder(): void { public function testMoveASubscriptionToAMissingFolder(): void {
$this->assertException("idMissing", "Db", "ExceptionInput"); $this->assertException("idMissing", "Db", "ExceptionInput");
Arsse::$db->subscriptionPropertiesSet($this->user, 1, ['folder' => 4]); Arsse::$db->subscriptionPropertiesSet($this->user, 1, ['folder' => 4]);
} }
/**
* @covers \JKingWeb\Arsse\Database::subscriptionPropertiesSet
* @covers \JKingWeb\Arsse\Database::subscriptionValidateId
* @covers \JKingWeb\Arsse\Database::subscriptionRulesApply
*/
public function testMoveASubscriptionToTheRootFolder(): void { public function testMoveASubscriptionToTheRootFolder(): void {
$this->assertTrue(Arsse::$db->subscriptionPropertiesSet($this->user, 3, ['folder' => null])); $this->assertTrue(Arsse::$db->subscriptionPropertiesSet($this->user, 3, ['folder' => null]));
} }
/** @dataProvider provideInvalidSubscriptionProperties */ /**
* @dataProvider provideInvalidSubscriptionProperties
* @covers \JKingWeb\Arsse\Database::subscriptionPropertiesSet
* @covers \JKingWeb\Arsse\Database::subscriptionValidateId
* @covers \JKingWeb\Arsse\Database::subscriptionRulesApply
*/
public function testSetThePropertiesOfASubscriptionToInvalidValues(array $data, string $exp): void { public function testSetThePropertiesOfASubscriptionToInvalidValues(array $data, string $exp): void {
$this->assertException($exp, "Db", "ExceptionInput"); $this->assertException($exp, "Db", "ExceptionInput");
Arsse::$db->subscriptionPropertiesSet($this->user, 1, $data); Arsse::$db->subscriptionPropertiesSet($this->user, 1, $data);
@ -492,20 +555,36 @@ trait SeriesSubscription {
]; ];
} }
/**
* @covers \JKingWeb\Arsse\Database::subscriptionPropertiesSet
* @covers \JKingWeb\Arsse\Database::subscriptionValidateId
* @covers \JKingWeb\Arsse\Database::subscriptionRulesApply
*/
public function testRenameASubscriptionToZero(): void { public function testRenameASubscriptionToZero(): void {
$this->assertTrue(Arsse::$db->subscriptionPropertiesSet($this->user, 1, ['title' => 0])); $this->assertTrue(Arsse::$db->subscriptionPropertiesSet($this->user, 1, ['title' => 0]));
} }
/**
* @covers \JKingWeb\Arsse\Database::subscriptionPropertiesSet
* @covers \JKingWeb\Arsse\Database::subscriptionValidateId
* @covers \JKingWeb\Arsse\Database::subscriptionRulesApply
*/
public function testSetThePropertiesOfAMissingSubscription(): void { public function testSetThePropertiesOfAMissingSubscription(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->subscriptionPropertiesSet($this->user, 2112, ['folder' => null]); Arsse::$db->subscriptionPropertiesSet($this->user, 2112, ['folder' => null]);
} }
/**
* @covers \JKingWeb\Arsse\Database::subscriptionPropertiesSet
* @covers \JKingWeb\Arsse\Database::subscriptionValidateId
* @covers \JKingWeb\Arsse\Database::subscriptionRulesApply
*/
public function testSetThePropertiesOfAnInvalidSubscription(): void { public function testSetThePropertiesOfAnInvalidSubscription(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->subscriptionPropertiesSet($this->user, -1, ['folder' => null]); Arsse::$db->subscriptionPropertiesSet($this->user, -1, ['folder' => null]);
} }
/** @covers \JKingWeb\Arsse\Database::subscriptionIcon */
public function testRetrieveTheFaviconOfASubscription(): void { public function testRetrieveTheFaviconOfASubscription(): void {
$exp = "http://example.com/favicon.ico"; $exp = "http://example.com/favicon.ico";
$this->assertSame($exp, Arsse::$db->subscriptionIcon(null, 1)['url']); $this->assertSame($exp, Arsse::$db->subscriptionIcon(null, 1)['url']);
@ -513,11 +592,13 @@ trait SeriesSubscription {
$this->assertSame(null, Arsse::$db->subscriptionIcon(null, 6)); $this->assertSame(null, Arsse::$db->subscriptionIcon(null, 6));
} }
/** @covers \JKingWeb\Arsse\Database::subscriptionIcon */
public function testRetrieveTheFaviconOfAMissingSubscription(): void { public function testRetrieveTheFaviconOfAMissingSubscription(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->subscriptionIcon(null, -2112); Arsse::$db->subscriptionIcon(null, -2112);
} }
/** @covers \JKingWeb\Arsse\Database::subscriptionIcon */
public function testRetrieveTheFaviconOfASubscriptionWithUser(): void { public function testRetrieveTheFaviconOfASubscriptionWithUser(): void {
$exp = "http://example.com/favicon.ico"; $exp = "http://example.com/favicon.ico";
$user = "john.doe@example.com"; $user = "john.doe@example.com";
@ -527,12 +608,14 @@ trait SeriesSubscription {
$this->assertSame($exp, Arsse::$db->subscriptionIcon($user, 2)['url']); $this->assertSame($exp, Arsse::$db->subscriptionIcon($user, 2)['url']);
} }
/** @covers \JKingWeb\Arsse\Database::subscriptionIcon */
public function testRetrieveTheFaviconOfASubscriptionOfTheWrongUser(): void { public function testRetrieveTheFaviconOfASubscriptionOfTheWrongUser(): void {
$user = "john.doe@example.com"; $user = "john.doe@example.com";
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->subscriptionIcon($user, 2); Arsse::$db->subscriptionIcon($user, 2);
} }
/** @covers \JKingWeb\Arsse\Database::subscriptionTagsGet */
public function testListTheTagsOfASubscription(): void { public function testListTheTagsOfASubscription(): void {
$this->assertEquals([1,2], Arsse::$db->subscriptionTagsGet("john.doe@example.com", 1)); $this->assertEquals([1,2], Arsse::$db->subscriptionTagsGet("john.doe@example.com", 1));
$this->assertEquals([2], Arsse::$db->subscriptionTagsGet("john.doe@example.com", 3)); $this->assertEquals([2], Arsse::$db->subscriptionTagsGet("john.doe@example.com", 3));
@ -540,22 +623,30 @@ trait SeriesSubscription {
$this->assertEquals(["Fascinating"], Arsse::$db->subscriptionTagsGet("john.doe@example.com", 3, true)); $this->assertEquals(["Fascinating"], Arsse::$db->subscriptionTagsGet("john.doe@example.com", 3, true));
} }
/** @covers \JKingWeb\Arsse\Database::subscriptionTagsGet */
public function testListTheTagsOfAMissingSubscription(): void { public function testListTheTagsOfAMissingSubscription(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->subscriptionTagsGet($this->user, 101); Arsse::$db->subscriptionTagsGet($this->user, 101);
} }
/** @covers \JKingWeb\Arsse\Database::subscriptionRefreshed */
public function testGetRefreshTimeOfASubscription(): void { public function testGetRefreshTimeOfASubscription(): void {
$user = "john.doe@example.com"; $user = "john.doe@example.com";
$this->assertTime(strtotime("now + 1 hour"), Arsse::$db->subscriptionRefreshed($user)); $this->assertTime(strtotime("now + 1 hour"), Arsse::$db->subscriptionRefreshed($user));
$this->assertTime(strtotime("now - 1 hour"), Arsse::$db->subscriptionRefreshed($user, 1)); $this->assertTime(strtotime("now - 1 hour"), Arsse::$db->subscriptionRefreshed($user, 1));
} }
/** @covers \JKingWeb\Arsse\Database::subscriptionRefreshed */
public function testGetRefreshTimeOfAMissingSubscription(): void { public function testGetRefreshTimeOfAMissingSubscription(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
$this->assertTime(strtotime("now - 1 hour"), Arsse::$db->subscriptionRefreshed("john.doe@example.com", 2)); $this->assertTime(strtotime("now - 1 hour"), Arsse::$db->subscriptionRefreshed("john.doe@example.com", 2));
} }
/**
* @covers \JKingWeb\Arsse\Database::subscriptionPropertiesSet
* @covers \JKingWeb\Arsse\Database::subscriptionValidateId
* @covers \JKingWeb\Arsse\Database::subscriptionRulesApply
*/
public function testSetTheFilterRulesOfASubscriptionCheckingMarks(): void { public function testSetTheFilterRulesOfASubscriptionCheckingMarks(): void {
Arsse::$db->subscriptionPropertiesSet("jack.doe@example.com", 5, ['keep_rule' => "1|B|3|D", 'block_rule' => "4"]); Arsse::$db->subscriptionPropertiesSet("jack.doe@example.com", 5, ['keep_rule' => "1|B|3|D", 'block_rule' => "4"]);
$state = $this->primeExpectations($this->data, ['arsse_marks' => ['article', 'subscription', 'hidden']]); $state = $this->primeExpectations($this->data, ['arsse_marks' => ['article', 'subscription', 'hidden']]);

View file

@ -113,6 +113,10 @@ trait SeriesTag {
unset($this->data, $this->checkTags, $this->checkMembers, $this->user); unset($this->data, $this->checkTags, $this->checkMembers, $this->user);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagAdd
* @covers \JKingWeb\Arsse\Database::tagValidateName
*/
public function testAddATag(): void { public function testAddATag(): void {
$user = "john.doe@example.com"; $user = "john.doe@example.com";
$tagID = $this->nextID("arsse_tags"); $tagID = $this->nextID("arsse_tags");
@ -122,26 +126,43 @@ trait SeriesTag {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagAdd
* @covers \JKingWeb\Arsse\Database::tagValidateName
*/
public function testAddADuplicateTag(): void { public function testAddADuplicateTag(): void {
$this->assertException("constraintViolation", "Db", "ExceptionInput"); $this->assertException("constraintViolation", "Db", "ExceptionInput");
Arsse::$db->tagAdd("john.doe@example.com", ['name' => "Interesting"]); Arsse::$db->tagAdd("john.doe@example.com", ['name' => "Interesting"]);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagAdd
* @covers \JKingWeb\Arsse\Database::tagValidateName
*/
public function testAddATagWithAMissingName(): void { public function testAddATagWithAMissingName(): void {
$this->assertException("missing", "Db", "ExceptionInput"); $this->assertException("missing", "Db", "ExceptionInput");
Arsse::$db->tagAdd("john.doe@example.com", []); Arsse::$db->tagAdd("john.doe@example.com", []);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagAdd
* @covers \JKingWeb\Arsse\Database::tagValidateName
*/
public function testAddATagWithABlankName(): void { public function testAddATagWithABlankName(): void {
$this->assertException("missing", "Db", "ExceptionInput"); $this->assertException("missing", "Db", "ExceptionInput");
Arsse::$db->tagAdd("john.doe@example.com", ['name' => ""]); Arsse::$db->tagAdd("john.doe@example.com", ['name' => ""]);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagAdd
* @covers \JKingWeb\Arsse\Database::tagValidateName
*/
public function testAddATagWithAWhitespaceName(): void { public function testAddATagWithAWhitespaceName(): void {
$this->assertException("whitespace", "Db", "ExceptionInput"); $this->assertException("whitespace", "Db", "ExceptionInput");
Arsse::$db->tagAdd("john.doe@example.com", ['name' => " "]); Arsse::$db->tagAdd("john.doe@example.com", ['name' => " "]);
} }
/** @covers \JKingWeb\Arsse\Database::tagList */
public function testListTags(): void { public function testListTags(): void {
$exp = [ $exp = [
['id' => 2, 'name' => "Fascinating"], ['id' => 2, 'name' => "Fascinating"],
@ -157,6 +178,10 @@ trait SeriesTag {
$this->assertResult($exp, Arsse::$db->tagList("jane.doe@example.com", false)); $this->assertResult($exp, Arsse::$db->tagList("jane.doe@example.com", false));
} }
/**
* @covers \JKingWeb\Arsse\Database::tagRemove
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testRemoveATag(): void { public function testRemoveATag(): void {
$this->assertTrue(Arsse::$db->tagRemove("john.doe@example.com", 1)); $this->assertTrue(Arsse::$db->tagRemove("john.doe@example.com", 1));
$state = $this->primeExpectations($this->data, $this->checkTags); $state = $this->primeExpectations($this->data, $this->checkTags);
@ -164,6 +189,10 @@ trait SeriesTag {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagRemove
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testRemoveATagByName(): void { public function testRemoveATagByName(): void {
$this->assertTrue(Arsse::$db->tagRemove("john.doe@example.com", "Interesting", true)); $this->assertTrue(Arsse::$db->tagRemove("john.doe@example.com", "Interesting", true));
$state = $this->primeExpectations($this->data, $this->checkTags); $state = $this->primeExpectations($this->data, $this->checkTags);
@ -171,26 +200,46 @@ trait SeriesTag {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagRemove
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testRemoveAMissingTag(): void { public function testRemoveAMissingTag(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->tagRemove("john.doe@example.com", 2112); Arsse::$db->tagRemove("john.doe@example.com", 2112);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagRemove
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testRemoveAnInvalidTag(): void { public function testRemoveAnInvalidTag(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->tagRemove("john.doe@example.com", -1); Arsse::$db->tagRemove("john.doe@example.com", -1);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagRemove
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testRemoveAnInvalidTagByName(): void { public function testRemoveAnInvalidTagByName(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->tagRemove("john.doe@example.com", [], true); Arsse::$db->tagRemove("john.doe@example.com", [], true);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagRemove
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testRemoveATagOfTheWrongOwner(): void { public function testRemoveATagOfTheWrongOwner(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->tagRemove("john.doe@example.com", 3); // tag ID 3 belongs to Jane Arsse::$db->tagRemove("john.doe@example.com", 3); // tag ID 3 belongs to Jane
} }
/**
* @covers \JKingWeb\Arsse\Database::tagPropertiesGet
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testGetThePropertiesOfATag(): void { public function testGetThePropertiesOfATag(): void {
$exp = [ $exp = [
'id' => 2, 'id' => 2,
@ -200,30 +249,56 @@ trait SeriesTag {
$this->assertArraySubset($exp, Arsse::$db->tagPropertiesGet("john.doe@example.com", "Fascinating", true)); $this->assertArraySubset($exp, Arsse::$db->tagPropertiesGet("john.doe@example.com", "Fascinating", true));
} }
/**
* @covers \JKingWeb\Arsse\Database::tagPropertiesGet
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testGetThePropertiesOfAMissingTag(): void { public function testGetThePropertiesOfAMissingTag(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->tagPropertiesGet("john.doe@example.com", 2112); Arsse::$db->tagPropertiesGet("john.doe@example.com", 2112);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagPropertiesGet
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testGetThePropertiesOfAnInvalidTag(): void { public function testGetThePropertiesOfAnInvalidTag(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->tagPropertiesGet("john.doe@example.com", -1); Arsse::$db->tagPropertiesGet("john.doe@example.com", -1);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagPropertiesGet
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testGetThePropertiesOfAnInvalidTagByName(): void { public function testGetThePropertiesOfAnInvalidTagByName(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->tagPropertiesGet("john.doe@example.com", [], true); Arsse::$db->tagPropertiesGet("john.doe@example.com", [], true);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagPropertiesGet
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testGetThePropertiesOfATagOfTheWrongOwner(): void { public function testGetThePropertiesOfATagOfTheWrongOwner(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->tagPropertiesGet("john.doe@example.com", 3); // tag ID 3 belongs to Jane Arsse::$db->tagPropertiesGet("john.doe@example.com", 3); // tag ID 3 belongs to Jane
} }
/**
* @covers \JKingWeb\Arsse\Database::tagPropertiesSet
* @covers \JKingWeb\Arsse\Database::tagValidateId
* @covers \JKingWeb\Arsse\Database::tagValidateName
*/
public function testMakeNoChangesToATag(): void { public function testMakeNoChangesToATag(): void {
$this->assertFalse(Arsse::$db->tagPropertiesSet("john.doe@example.com", 1, [])); $this->assertFalse(Arsse::$db->tagPropertiesSet("john.doe@example.com", 1, []));
} }
/**
* @covers \JKingWeb\Arsse\Database::tagPropertiesSet
* @covers \JKingWeb\Arsse\Database::tagValidateId
* @covers \JKingWeb\Arsse\Database::tagValidateName
*/
public function testRenameATag(): void { public function testRenameATag(): void {
$this->assertTrue(Arsse::$db->tagPropertiesSet("john.doe@example.com", 1, ['name' => "Curious"])); $this->assertTrue(Arsse::$db->tagPropertiesSet("john.doe@example.com", 1, ['name' => "Curious"]));
$state = $this->primeExpectations($this->data, $this->checkTags); $state = $this->primeExpectations($this->data, $this->checkTags);
@ -231,6 +306,11 @@ trait SeriesTag {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagPropertiesSet
* @covers \JKingWeb\Arsse\Database::tagValidateId
* @covers \JKingWeb\Arsse\Database::tagValidateName
*/
public function testRenameATagByName(): void { public function testRenameATagByName(): void {
$this->assertTrue(Arsse::$db->tagPropertiesSet("john.doe@example.com", "Interesting", ['name' => "Curious"], true)); $this->assertTrue(Arsse::$db->tagPropertiesSet("john.doe@example.com", "Interesting", ['name' => "Curious"], true));
$state = $this->primeExpectations($this->data, $this->checkTags); $state = $this->primeExpectations($this->data, $this->checkTags);
@ -238,46 +318,90 @@ trait SeriesTag {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagPropertiesSet
* @covers \JKingWeb\Arsse\Database::tagValidateId
* @covers \JKingWeb\Arsse\Database::tagValidateName
*/
public function testRenameATagToTheEmptyString(): void { public function testRenameATagToTheEmptyString(): void {
$this->assertException("missing", "Db", "ExceptionInput"); $this->assertException("missing", "Db", "ExceptionInput");
$this->assertTrue(Arsse::$db->tagPropertiesSet("john.doe@example.com", 1, ['name' => ""])); $this->assertTrue(Arsse::$db->tagPropertiesSet("john.doe@example.com", 1, ['name' => ""]));
} }
/**
* @covers \JKingWeb\Arsse\Database::tagPropertiesSet
* @covers \JKingWeb\Arsse\Database::tagValidateId
* @covers \JKingWeb\Arsse\Database::tagValidateName
*/
public function testRenameATagToWhitespaceOnly(): void { public function testRenameATagToWhitespaceOnly(): void {
$this->assertException("whitespace", "Db", "ExceptionInput"); $this->assertException("whitespace", "Db", "ExceptionInput");
$this->assertTrue(Arsse::$db->tagPropertiesSet("john.doe@example.com", 1, ['name' => " "])); $this->assertTrue(Arsse::$db->tagPropertiesSet("john.doe@example.com", 1, ['name' => " "]));
} }
/**
* @covers \JKingWeb\Arsse\Database::tagPropertiesSet
* @covers \JKingWeb\Arsse\Database::tagValidateId
* @covers \JKingWeb\Arsse\Database::tagValidateName
*/
public function testRenameATagToAnInvalidValue(): void { public function testRenameATagToAnInvalidValue(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
$this->assertTrue(Arsse::$db->tagPropertiesSet("john.doe@example.com", 1, ['name' => []])); $this->assertTrue(Arsse::$db->tagPropertiesSet("john.doe@example.com", 1, ['name' => []]));
} }
/**
* @covers \JKingWeb\Arsse\Database::tagPropertiesSet
* @covers \JKingWeb\Arsse\Database::tagValidateId
* @covers \JKingWeb\Arsse\Database::tagValidateName
*/
public function testCauseATagCollision(): void { public function testCauseATagCollision(): void {
$this->assertException("constraintViolation", "Db", "ExceptionInput"); $this->assertException("constraintViolation", "Db", "ExceptionInput");
Arsse::$db->tagPropertiesSet("john.doe@example.com", 1, ['name' => "Fascinating"]); Arsse::$db->tagPropertiesSet("john.doe@example.com", 1, ['name' => "Fascinating"]);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagPropertiesSet
* @covers \JKingWeb\Arsse\Database::tagValidateId
* @covers \JKingWeb\Arsse\Database::tagValidateName
*/
public function testSetThePropertiesOfAMissingTag(): void { public function testSetThePropertiesOfAMissingTag(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->tagPropertiesSet("john.doe@example.com", 2112, ['name' => "Exciting"]); Arsse::$db->tagPropertiesSet("john.doe@example.com", 2112, ['name' => "Exciting"]);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagPropertiesSet
* @covers \JKingWeb\Arsse\Database::tagValidateId
* @covers \JKingWeb\Arsse\Database::tagValidateName
*/
public function testSetThePropertiesOfAnInvalidTag(): void { public function testSetThePropertiesOfAnInvalidTag(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->tagPropertiesSet("john.doe@example.com", -1, ['name' => "Exciting"]); Arsse::$db->tagPropertiesSet("john.doe@example.com", -1, ['name' => "Exciting"]);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagPropertiesSet
* @covers \JKingWeb\Arsse\Database::tagValidateId
* @covers \JKingWeb\Arsse\Database::tagValidateName
*/
public function testSetThePropertiesOfAnInvalidTagByName(): void { public function testSetThePropertiesOfAnInvalidTagByName(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->tagPropertiesSet("john.doe@example.com", [], ['name' => "Exciting"], true); Arsse::$db->tagPropertiesSet("john.doe@example.com", [], ['name' => "Exciting"], true);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagPropertiesSet
* @covers \JKingWeb\Arsse\Database::tagValidateId
* @covers \JKingWeb\Arsse\Database::tagValidateName
*/
public function testSetThePropertiesOfATagForTheWrongOwner(): void { public function testSetThePropertiesOfATagForTheWrongOwner(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->tagPropertiesSet("john.doe@example.com", 3, ['name' => "Exciting"]); // tag ID 3 belongs to Jane Arsse::$db->tagPropertiesSet("john.doe@example.com", 3, ['name' => "Exciting"]); // tag ID 3 belongs to Jane
} }
/**
* @covers \JKingWeb\Arsse\Database::tagSubscriptionsGet
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testListTaggedSubscriptions(): void { public function testListTaggedSubscriptions(): void {
$exp = [1,5]; $exp = [1,5];
$this->assertEquals($exp, Arsse::$db->tagSubscriptionsGet("john.doe@example.com", 1)); $this->assertEquals($exp, Arsse::$db->tagSubscriptionsGet("john.doe@example.com", 1));
@ -290,16 +414,28 @@ trait SeriesTag {
$this->assertEquals($exp, Arsse::$db->tagSubscriptionsGet("john.doe@example.com", "Lonely", true)); $this->assertEquals($exp, Arsse::$db->tagSubscriptionsGet("john.doe@example.com", "Lonely", true));
} }
/**
* @covers \JKingWeb\Arsse\Database::tagSubscriptionsGet
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testListTaggedSubscriptionsForAMissingTag(): void { public function testListTaggedSubscriptionsForAMissingTag(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->tagSubscriptionsGet("john.doe@example.com", 3); Arsse::$db->tagSubscriptionsGet("john.doe@example.com", 3);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagSubscriptionsGet
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testListTaggedSubscriptionsForAnInvalidTag(): void { public function testListTaggedSubscriptionsForAnInvalidTag(): void {
$this->assertException("typeViolation", "Db", "ExceptionInput"); $this->assertException("typeViolation", "Db", "ExceptionInput");
Arsse::$db->tagSubscriptionsGet("john.doe@example.com", -1); Arsse::$db->tagSubscriptionsGet("john.doe@example.com", -1);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagSubscriptionsSet
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testApplyATagToSubscriptions(): void { public function testApplyATagToSubscriptions(): void {
Arsse::$db->tagSubscriptionsSet("john.doe@example.com", 1, [3,4]); Arsse::$db->tagSubscriptionsSet("john.doe@example.com", 1, [3,4]);
$state = $this->primeExpectations($this->data, $this->checkMembers); $state = $this->primeExpectations($this->data, $this->checkMembers);
@ -308,6 +444,10 @@ trait SeriesTag {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagSubscriptionsSet
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testClearATagFromSubscriptions(): void { public function testClearATagFromSubscriptions(): void {
Arsse::$db->tagSubscriptionsSet("john.doe@example.com", 1, [1,3], Database::ASSOC_REMOVE); Arsse::$db->tagSubscriptionsSet("john.doe@example.com", 1, [1,3], Database::ASSOC_REMOVE);
$state = $this->primeExpectations($this->data, $this->checkMembers); $state = $this->primeExpectations($this->data, $this->checkMembers);
@ -315,6 +455,10 @@ trait SeriesTag {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagSubscriptionsSet
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testApplyATagToSubscriptionsByName(): void { public function testApplyATagToSubscriptionsByName(): void {
Arsse::$db->tagSubscriptionsSet("john.doe@example.com", "Interesting", [3,4], Database::ASSOC_ADD, true); Arsse::$db->tagSubscriptionsSet("john.doe@example.com", "Interesting", [3,4], Database::ASSOC_ADD, true);
$state = $this->primeExpectations($this->data, $this->checkMembers); $state = $this->primeExpectations($this->data, $this->checkMembers);
@ -323,6 +467,10 @@ trait SeriesTag {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagSubscriptionsSet
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testClearATagFromSubscriptionsByName(): void { public function testClearATagFromSubscriptionsByName(): void {
Arsse::$db->tagSubscriptionsSet("john.doe@example.com", "Interesting", [1,3], Database::ASSOC_REMOVE, true); Arsse::$db->tagSubscriptionsSet("john.doe@example.com", "Interesting", [1,3], Database::ASSOC_REMOVE, true);
$state = $this->primeExpectations($this->data, $this->checkMembers); $state = $this->primeExpectations($this->data, $this->checkMembers);
@ -330,18 +478,30 @@ trait SeriesTag {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagSubscriptionsSet
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testApplyATagToNoSubscriptionsByName(): void { public function testApplyATagToNoSubscriptionsByName(): void {
Arsse::$db->tagSubscriptionsSet("john.doe@example.com", "Interesting", [], Database::ASSOC_ADD, true); Arsse::$db->tagSubscriptionsSet("john.doe@example.com", "Interesting", [], Database::ASSOC_ADD, true);
$state = $this->primeExpectations($this->data, $this->checkMembers); $state = $this->primeExpectations($this->data, $this->checkMembers);
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagSubscriptionsSet
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testClearATagFromNoSubscriptionsByName(): void { public function testClearATagFromNoSubscriptionsByName(): void {
Arsse::$db->tagSubscriptionsSet("john.doe@example.com", "Interesting", [], Database::ASSOC_REMOVE, true); Arsse::$db->tagSubscriptionsSet("john.doe@example.com", "Interesting", [], Database::ASSOC_REMOVE, true);
$state = $this->primeExpectations($this->data, $this->checkMembers); $state = $this->primeExpectations($this->data, $this->checkMembers);
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagSubscriptionsSet
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testReplaceSubscriptionsOfATag(): void { public function testReplaceSubscriptionsOfATag(): void {
Arsse::$db->tagSubscriptionsSet("john.doe@example.com", 1, [3,4], Database::ASSOC_REPLACE); Arsse::$db->tagSubscriptionsSet("john.doe@example.com", 1, [3,4], Database::ASSOC_REPLACE);
$state = $this->primeExpectations($this->data, $this->checkMembers); $state = $this->primeExpectations($this->data, $this->checkMembers);
@ -352,6 +512,10 @@ trait SeriesTag {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/**
* @covers \JKingWeb\Arsse\Database::tagSubscriptionsSet
* @covers \JKingWeb\Arsse\Database::tagValidateId
*/
public function testPurgeSubscriptionsOfATag(): void { public function testPurgeSubscriptionsOfATag(): void {
Arsse::$db->tagSubscriptionsSet("john.doe@example.com", 1, [], Database::ASSOC_REPLACE); Arsse::$db->tagSubscriptionsSet("john.doe@example.com", 1, [], Database::ASSOC_REPLACE);
$state = $this->primeExpectations($this->data, $this->checkMembers); $state = $this->primeExpectations($this->data, $this->checkMembers);
@ -360,6 +524,7 @@ trait SeriesTag {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::tagSummarize */
public function testSummarizeTags(): void { public function testSummarizeTags(): void {
$exp = [ $exp = [
['id' => 1, 'name' => "Interesting", 'subscription' => 1], ['id' => 1, 'name' => "Interesting", 'subscription' => 1],

View file

@ -53,6 +53,7 @@ trait SeriesToken {
unset($this->data); unset($this->data);
} }
/** @covers \JKingWeb\Arsse\Database::tokenLookup */
public function testLookUpAValidToken(): void { public function testLookUpAValidToken(): void {
$exp1 = [ $exp1 = [
'id' => "80fa94c1a11f11e78667001e673b2560", 'id' => "80fa94c1a11f11e78667001e673b2560",
@ -74,21 +75,25 @@ trait SeriesToken {
$this->assertArraySubset($exp3, Arsse::$db->tokenLookup("class.class", "ab3b3eb8a13311e78667001e673b2560")); $this->assertArraySubset($exp3, Arsse::$db->tokenLookup("class.class", "ab3b3eb8a13311e78667001e673b2560"));
} }
/** @covers \JKingWeb\Arsse\Database::tokenLookup */
public function testLookUpAMissingToken(): void { public function testLookUpAMissingToken(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->tokenLookup("class", "thisTokenDoesNotExist"); Arsse::$db->tokenLookup("class", "thisTokenDoesNotExist");
} }
/** @covers \JKingWeb\Arsse\Database::tokenLookup */
public function testLookUpAnExpiredToken(): void { public function testLookUpAnExpiredToken(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->tokenLookup("fever.login", "27c6de8da13311e78667001e673b2560"); Arsse::$db->tokenLookup("fever.login", "27c6de8da13311e78667001e673b2560");
} }
/** @covers \JKingWeb\Arsse\Database::tokenLookup */
public function testLookUpATokenOfTheWrongClass(): void { public function testLookUpATokenOfTheWrongClass(): void {
$this->assertException("subjectMissing", "Db", "ExceptionInput"); $this->assertException("subjectMissing", "Db", "ExceptionInput");
Arsse::$db->tokenLookup("some.class", "80fa94c1a11f11e78667001e673b2560"); Arsse::$db->tokenLookup("some.class", "80fa94c1a11f11e78667001e673b2560");
} }
/** @covers \JKingWeb\Arsse\Database::tokenCreate */
public function testCreateAToken(): void { public function testCreateAToken(): void {
$user = "jane.doe@example.com"; $user = "jane.doe@example.com";
$state = $this->primeExpectations($this->data, ['arsse_tokens' => ["id", "class", "expires", "user"]]); $state = $this->primeExpectations($this->data, ['arsse_tokens' => ["id", "class", "expires", "user"]]);
@ -103,11 +108,13 @@ trait SeriesToken {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::tokenCreate */
public function testCreateATokenForAMissingUser(): void { public function testCreateATokenForAMissingUser(): void {
$this->assertException("doesNotExist", "User", "ExceptionConflict"); $this->assertException("doesNotExist", "User", "ExceptionConflict");
Arsse::$db->tokenCreate("fever.login", "jane.doe@example.biz"); Arsse::$db->tokenCreate("fever.login", "jane.doe@example.biz");
} }
/** @covers \JKingWeb\Arsse\Database::tokenRevoke */
public function testRevokeAToken(): void { public function testRevokeAToken(): void {
$user = "jane.doe@example.com"; $user = "jane.doe@example.com";
$id = "80fa94c1a11f11e78667001e673b2560"; $id = "80fa94c1a11f11e78667001e673b2560";
@ -119,6 +126,7 @@ trait SeriesToken {
$this->assertFalse(Arsse::$db->tokenRevoke($user, "fever.login", $id)); $this->assertFalse(Arsse::$db->tokenRevoke($user, "fever.login", $id));
} }
/** @covers \JKingWeb\Arsse\Database::tokenRevoke */
public function testRevokeAllTokens(): void { public function testRevokeAllTokens(): void {
$user = "jane.doe@example.com"; $user = "jane.doe@example.com";
$state = $this->primeExpectations($this->data, ['arsse_tokens' => ["id", "expires", "user"]]); $state = $this->primeExpectations($this->data, ['arsse_tokens' => ["id", "expires", "user"]]);
@ -133,6 +141,7 @@ trait SeriesToken {
$this->assertFalse(Arsse::$db->tokenRevoke($user, "unknown.class")); $this->assertFalse(Arsse::$db->tokenRevoke($user, "unknown.class"));
} }
/** @covers \JKingWeb\Arsse\Database::tokenList */
public function testListTokens(): void { public function testListTokens(): void {
$user = "jane.doe@example.com"; $user = "jane.doe@example.com";
$exp = [ $exp = [

View file

@ -48,23 +48,27 @@ trait SeriesUser {
unset($this->data); unset($this->data);
} }
/** @covers \JKingWeb\Arsse\Database::userExists */
public function testCheckThatAUserExists(): void { public function testCheckThatAUserExists(): void {
$this->assertTrue(Arsse::$db->userExists("jane.doe@example.com")); $this->assertTrue(Arsse::$db->userExists("jane.doe@example.com"));
$this->assertFalse(Arsse::$db->userExists("jane.doe@example.org")); $this->assertFalse(Arsse::$db->userExists("jane.doe@example.org"));
$this->compareExpectations(static::$drv, $this->data); $this->compareExpectations(static::$drv, $this->data);
} }
/** @covers \JKingWeb\Arsse\Database::userPasswordGet */
public function testGetAPassword(): void { public function testGetAPassword(): void {
$hash = Arsse::$db->userPasswordGet("admin@example.net"); $hash = Arsse::$db->userPasswordGet("admin@example.net");
$this->assertSame('$2y$10$PbcG2ZR3Z8TuPzM7aHTF8.v61dtCjzjK78gdZJcp4UePE8T9jEgBW', $hash); $this->assertSame('$2y$10$PbcG2ZR3Z8TuPzM7aHTF8.v61dtCjzjK78gdZJcp4UePE8T9jEgBW', $hash);
$this->assertTrue(password_verify("secret", $hash)); $this->assertTrue(password_verify("secret", $hash));
} }
/** @covers \JKingWeb\Arsse\Database::userPasswordGet */
public function testGetThePasswordOfAMissingUser(): void { public function testGetThePasswordOfAMissingUser(): void {
$this->assertException("doesNotExist", "User", "ExceptionConflict"); $this->assertException("doesNotExist", "User", "ExceptionConflict");
Arsse::$db->userPasswordGet("john.doe@example.org"); Arsse::$db->userPasswordGet("john.doe@example.org");
} }
/** @covers \JKingWeb\Arsse\Database::userAdd */
public function testAddANewUser(): void { public function testAddANewUser(): void {
$this->assertTrue(Arsse::$db->userAdd("john.doe@example.org", "")); $this->assertTrue(Arsse::$db->userAdd("john.doe@example.org", ""));
$state = $this->primeExpectations($this->data, ['arsse_users' => ['id']]); $state = $this->primeExpectations($this->data, ['arsse_users' => ['id']]);
@ -72,11 +76,13 @@ trait SeriesUser {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::userAdd */
public function testAddAnExistingUser(): void { public function testAddAnExistingUser(): void {
$this->assertException("alreadyExists", "User", "ExceptionConflict"); $this->assertException("alreadyExists", "User", "ExceptionConflict");
Arsse::$db->userAdd("john.doe@example.com", ""); Arsse::$db->userAdd("john.doe@example.com", "");
} }
/** @covers \JKingWeb\Arsse\Database::userRemove */
public function testRemoveAUser(): void { public function testRemoveAUser(): void {
$this->assertTrue(Arsse::$db->userRemove("admin@example.net")); $this->assertTrue(Arsse::$db->userRemove("admin@example.net"));
$state = $this->primeExpectations($this->data, ['arsse_users' => ['id']]); $state = $this->primeExpectations($this->data, ['arsse_users' => ['id']]);
@ -84,19 +90,19 @@ trait SeriesUser {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::userRemove */
public function testRemoveAMissingUser(): void { public function testRemoveAMissingUser(): void {
$this->assertException("doesNotExist", "User", "ExceptionConflict"); $this->assertException("doesNotExist", "User", "ExceptionConflict");
Arsse::$db->userRemove("john.doe@example.org"); Arsse::$db->userRemove("john.doe@example.org");
} }
/** @covers \JKingWeb\Arsse\Database::userList */
public function testListAllUsers(): void { public function testListAllUsers(): void {
$users = ["admin@example.net", "jane.doe@example.com", "john.doe@example.com"]; $users = ["admin@example.net", "jane.doe@example.com", "john.doe@example.com"];
$this->assertSame($users, Arsse::$db->userList()); $this->assertSame($users, Arsse::$db->userList());
} }
/** /** @covers \JKingWeb\Arsse\Database::userPasswordSet */
* @depends testGetAPassword
*/
public function testSetAPassword(): void { public function testSetAPassword(): void {
$user = "john.doe@example.com"; $user = "john.doe@example.com";
$pass = "secret"; $pass = "secret";
@ -107,6 +113,7 @@ trait SeriesUser {
$this->assertTrue(password_verify($pass, $hash), "Failed verifying password of $user '$pass' against hash '$hash'."); $this->assertTrue(password_verify($pass, $hash), "Failed verifying password of $user '$pass' against hash '$hash'.");
} }
/** @covers \JKingWeb\Arsse\Database::userPasswordSet */
public function testUnsetAPassword(): void { public function testUnsetAPassword(): void {
$user = "john.doe@example.com"; $user = "john.doe@example.com";
$this->assertEquals("", Arsse::$db->userPasswordGet($user)); $this->assertEquals("", Arsse::$db->userPasswordGet($user));
@ -114,12 +121,16 @@ trait SeriesUser {
$this->assertNull(Arsse::$db->userPasswordGet($user)); $this->assertNull(Arsse::$db->userPasswordGet($user));
} }
/** @covers \JKingWeb\Arsse\Database::userPasswordSet */
public function testSetThePasswordOfAMissingUser(): void { public function testSetThePasswordOfAMissingUser(): void {
$this->assertException("doesNotExist", "User", "ExceptionConflict"); $this->assertException("doesNotExist", "User", "ExceptionConflict");
Arsse::$db->userPasswordSet("john.doe@example.org", "secret"); Arsse::$db->userPasswordSet("john.doe@example.org", "secret");
} }
/** @dataProvider provideMetaData */ /**
* @dataProvider provideMetaData
* @covers \JKingWeb\Arsse\Database::userPropertiesGet
*/
public function testGetMetadata(string $user, bool $includeLarge, array $exp): void { public function testGetMetadata(string $user, bool $includeLarge, array $exp): void {
$this->assertSame($exp, Arsse::$db->userPropertiesGet($user, $includeLarge)); $this->assertSame($exp, Arsse::$db->userPropertiesGet($user, $includeLarge));
} }
@ -135,11 +146,13 @@ trait SeriesUser {
]; ];
} }
/** @covers \JKingWeb\Arsse\Database::userPropertiesGet */
public function testGetTheMetadataOfAMissingUser(): void { public function testGetTheMetadataOfAMissingUser(): void {
$this->assertException("doesNotExist", "User", "ExceptionConflict"); $this->assertException("doesNotExist", "User", "ExceptionConflict");
Arsse::$db->userPropertiesGet("john.doe@example.org"); Arsse::$db->userPropertiesGet("john.doe@example.org");
} }
/** @covers \JKingWeb\Arsse\Database::userPropertiesSet */
public function testSetMetadata(): void { public function testSetMetadata(): void {
$in = [ $in = [
'admin' => true, 'admin' => true,
@ -156,6 +169,7 @@ trait SeriesUser {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::userPropertiesSet */
public function testSetNoMetadata(): void { public function testSetNoMetadata(): void {
$in = [ $in = [
'num' => 2112, 'num' => 2112,
@ -166,22 +180,26 @@ trait SeriesUser {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::userPropertiesSet */
public function testSetTheMetadataOfAMissingUser(): void { public function testSetTheMetadataOfAMissingUser(): void {
$this->assertException("doesNotExist", "User", "ExceptionConflict"); $this->assertException("doesNotExist", "User", "ExceptionConflict");
Arsse::$db->userPropertiesSet("john.doe@example.org", ['admin' => true]); Arsse::$db->userPropertiesSet("john.doe@example.org", ['admin' => true]);
} }
/** @covers \JKingWeb\Arsse\Database::userLookup */
public function testLookUpAUserByNumber(): void { public function testLookUpAUserByNumber(): void {
$this->assertSame("admin@example.net", Arsse::$db->userLookup(1)); $this->assertSame("admin@example.net", Arsse::$db->userLookup(1));
$this->assertSame("jane.doe@example.com", Arsse::$db->userLookup(2)); $this->assertSame("jane.doe@example.com", Arsse::$db->userLookup(2));
$this->assertSame("john.doe@example.com", Arsse::$db->userLookup(3)); $this->assertSame("john.doe@example.com", Arsse::$db->userLookup(3));
} }
/** @covers \JKingWeb\Arsse\Database::userLookup */
public function testLookUpAMissingUserByNumber(): void { public function testLookUpAMissingUserByNumber(): void {
$this->assertException("doesNotExist", "User", "ExceptionConflict"); $this->assertException("doesNotExist", "User", "ExceptionConflict");
Arsse::$db->userLookup(2112); Arsse::$db->userLookup(2112);
} }
/** @covers \JKingWeb\Arsse\Database::userRename */
public function testRenameAUser(): void { public function testRenameAUser(): void {
$this->assertTrue(Arsse::$db->userRename("john.doe@example.com", "juan.doe@example.com")); $this->assertTrue(Arsse::$db->userRename("john.doe@example.com", "juan.doe@example.com"));
$state = $this->primeExpectations($this->data, [ $state = $this->primeExpectations($this->data, [
@ -193,20 +211,24 @@ trait SeriesUser {
$this->compareExpectations(static::$drv, $state); $this->compareExpectations(static::$drv, $state);
} }
/** @covers \JKingWeb\Arsse\Database::userRename */
public function testRenameAUserToTheSameName(): void { public function testRenameAUserToTheSameName(): void {
$this->assertFalse(Arsse::$db->userRename("john.doe@example.com", "john.doe@example.com")); $this->assertFalse(Arsse::$db->userRename("john.doe@example.com", "john.doe@example.com"));
} }
/** @covers \JKingWeb\Arsse\Database::userRename */
public function testRenameAMissingUser(): void { public function testRenameAMissingUser(): void {
$this->assertException("doesNotExist", "User", "ExceptionConflict"); $this->assertException("doesNotExist", "User", "ExceptionConflict");
Arsse::$db->userRename("juan.doe@example.com", "john.doe@example.com"); Arsse::$db->userRename("juan.doe@example.com", "john.doe@example.com");
} }
/** @covers \JKingWeb\Arsse\Database::userRename */
public function testRenameAUserToADuplicateName(): void { public function testRenameAUserToADuplicateName(): void {
$this->assertException("alreadyExists", "User", "ExceptionConflict"); $this->assertException("alreadyExists", "User", "ExceptionConflict");
Arsse::$db->userRename("john.doe@example.com", "jane.doe@example.com"); Arsse::$db->userRename("john.doe@example.com", "jane.doe@example.com");
} }
/** @covers \JKingWeb\Arsse\Database::userAdd */
public function testAddFirstUser(): void { public function testAddFirstUser(): void {
// first truncate the users table // first truncate the users table
static::$drv->exec("DELETE FROM arsse_users"); static::$drv->exec("DELETE FROM arsse_users");

View file

@ -8,8 +8,9 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\Database; namespace JKingWeb\Arsse\TestCase\Database;
use JKingWeb\Arsse\Database; use JKingWeb\Arsse\Database;
use JKingWeb\Arsse\Db\Transaction;
/** @covers \JKingWeb\Arsse\Database */ /** @coversNothing */
class TestDatabase extends \JKingWeb\Arsse\Test\AbstractTest { class TestDatabase extends \JKingWeb\Arsse\Test\AbstractTest {
protected $db = null; protected $db = null;
@ -34,7 +35,10 @@ class TestDatabase extends \JKingWeb\Arsse\Test\AbstractTest {
return $m->invoke($this->db, ...$arg); return $m->invoke($this->db, ...$arg);
} }
/** @dataProvider provideInClauses */ /**
* @dataProvider provideInClauses
* @covers \JKingWeb\Arsse\Database::generateIn
*/
public function testGenerateInClause(string $clause, array $values, array $inV, string $inT): void { public function testGenerateInClause(string $clause, array $values, array $inV, string $inT): void {
$types = array_fill(0, sizeof($values), $inT); $types = array_fill(0, sizeof($values), $inT);
$exp = [$clause, $types, $values]; $exp = [$clause, $types, $values];
@ -68,7 +72,10 @@ class TestDatabase extends \JKingWeb\Arsse\Test\AbstractTest {
]; ];
} }
/** @dataProvider provideSearchClauses */ /**
* @dataProvider provideSearchClauses
* @covers \JKingWeb\Arsse\Database::generateSearch
*/
public function testGenerateSearchClause(string $clause, array $values, array $inV, array $inC, bool $inAny): void { public function testGenerateSearchClause(string $clause, array $values, array $inV, array $inC, bool $inAny): void {
// this is not an exhaustive test; integration tests already cover the ins and outs of the functionality // this is not an exhaustive test; integration tests already cover the ins and outs of the functionality
$types = array_fill(0, sizeof($values), "str"); $types = array_fill(0, sizeof($values), "str");
@ -91,4 +98,36 @@ class TestDatabase extends \JKingWeb\Arsse\Test\AbstractTest {
["(".implode(" or ", $clause)." or test like ? escape '^')", ["%?%"], array_merge($terms, ["?"]), ["test"], true], ["(".implode(" or ", $clause)." or test like ? escape '^')", ["%?%"], array_merge($terms, ["?"]), ["test"], true],
]; ];
} }
/** @covers \JKingWeb\Arsse\Database::generateSet */
public function testGenerateSetClause(): void {
$in = [
'ook' => true,
'ack' => false,
'bar' => "Nimoy",
'foo' => "Shatner",
];
$valid = [
'ook' => "bool",
'eek' => "int",
'foo' => "str",
'bar' => "str",
];
$exp = [
'"ook" = ?, "foo" = ?, "bar" = ?',
["bool", "str", "str"],
[true, "Shatner", "Nimoy"],
];
$this->assertSame($exp, $this->invoke("generateSet", $in, $valid));
}
/** @covers \JKingWeb\Arsse\Database::begin */
public function testBeginATransaction(): void {
$this->assertInstanceOf(Transaction::class, $this->invoke("begin"));
}
/** @covers \JKingWeb\Arsse\Database::caller */
public function testReportCallingMethod(): void {
$this->assertSame("caller", $this->invoke("caller"));
}
} }

View file

@ -10,7 +10,7 @@ namespace JKingWeb\Arsse\TestCase\Db\MySQL;
/** /**
* @group slow * @group slow
* @group coverageOptional * @group coverageOptional
* @covers \JKingWeb\Arsse\Database<extended> * @coversNothing
*/ */
class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest { class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest {
use \JKingWeb\Arsse\Test\DatabaseDrivers\MySQL; use \JKingWeb\Arsse\Test\DatabaseDrivers\MySQL;

View file

@ -11,7 +11,7 @@ namespace JKingWeb\Arsse\TestCase\Db\MySQLPDO;
* @group slow * @group slow
* @group optional * @group optional
* @group coverageOptional * @group coverageOptional
* @covers \JKingWeb\Arsse\Database<extended> * @coversNothing
*/ */
class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest { class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest {
use \JKingWeb\Arsse\Test\DatabaseDrivers\MySQLPDO; use \JKingWeb\Arsse\Test\DatabaseDrivers\MySQLPDO;

View file

@ -10,7 +10,7 @@ namespace JKingWeb\Arsse\TestCase\Db\PostgreSQL;
/** /**
* @group slow * @group slow
* @group coverageOptional * @group coverageOptional
* @covers \JKingWeb\Arsse\Database<extended> * @coversNothing
*/ */
class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest { class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest {
use \JKingWeb\Arsse\Test\DatabaseDrivers\PostgreSQL; use \JKingWeb\Arsse\Test\DatabaseDrivers\PostgreSQL;

View file

@ -11,7 +11,7 @@ namespace JKingWeb\Arsse\TestCase\Db\PostgreSQLPDO;
* @group slow * @group slow
* @group optional * @group optional
* @group coverageOptional * @group coverageOptional
* @covers \JKingWeb\Arsse\Database<extended> * @coversNothing
*/ */
class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest { class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest {
use \JKingWeb\Arsse\Test\DatabaseDrivers\PostgreSQLPDO; use \JKingWeb\Arsse\Test\DatabaseDrivers\PostgreSQLPDO;

View file

@ -9,7 +9,7 @@ namespace JKingWeb\Arsse\TestCase\Db\SQLite3;
/** /**
* @group optional * @group optional
* @covers \JKingWeb\Arsse\Database<extended> * @coversNothing
*/ */
class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest { class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest {
use \JKingWeb\Arsse\Test\DatabaseDrivers\SQLite3; use \JKingWeb\Arsse\Test\DatabaseDrivers\SQLite3;

View file

@ -8,7 +8,7 @@ declare(strict_types=1);
namespace JKingWeb\Arsse\TestCase\Db\SQLite3PDO; namespace JKingWeb\Arsse\TestCase\Db\SQLite3PDO;
/** /**
* @covers \JKingWeb\Arsse\Database<extended> * @coversNothing
*/ */
class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest { class TestDatabase extends \JKingWeb\Arsse\TestCase\Database\AbstractTest {
use \JKingWeb\Arsse\Test\DatabaseDrivers\SQLite3PDO; use \JKingWeb\Arsse\Test\DatabaseDrivers\SQLite3PDO;