mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
Enforce minimum array size (for now)
This commit is contained in:
parent
ef1b761f95
commit
98f6fca7e3
2 changed files with 16 additions and 16 deletions
|
@ -1418,6 +1418,9 @@ class Database {
|
||||||
$col = $opt['cte_cols'][$named ? 2 : 1];
|
$col = $opt['cte_cols'][$named ? 2 : 1];
|
||||||
if ($context->$m()) {
|
if ($context->$m()) {
|
||||||
$seen = true;
|
$seen = true;
|
||||||
|
if (!$context->$m) {
|
||||||
|
throw new Db\ExceptionInput("tooShort", ['field' => $m, 'action' => $this->caller(), 'min' => 1]); // must have at least one array element
|
||||||
|
}
|
||||||
if ($multi) {
|
if ($multi) {
|
||||||
list($test, $types, $values) = $this->generateIn($context->$m, $named ? "str" : "int");
|
list($test, $types, $values) = $this->generateIn($context->$m, $named ? "str" : "int");
|
||||||
$test = "in ($test)";
|
$test = "in ($test)";
|
||||||
|
|
|
@ -789,11 +789,6 @@ trait SeriesArticle {
|
||||||
$this->compareExpectations($state);
|
$this->compareExpectations($state);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMarkTooFewMultipleArticles() {
|
|
||||||
$this->assertException("tooShort", "Db", "ExceptionInput");
|
|
||||||
Arsse::$db->articleMark($this->user, ['read'=>false,'starred'=>true], (new Context)->articles([]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testMarkTooManyMultipleArticles() {
|
public function testMarkTooManyMultipleArticles() {
|
||||||
$this->assertSame(7, Arsse::$db->articleMark($this->user, ['read'=>false,'starred'=>true], (new Context)->articles(range(1, Database::LIMIT_SET_SIZE * 3))));
|
$this->assertSame(7, Arsse::$db->articleMark($this->user, ['read'=>false,'starred'=>true], (new Context)->articles(range(1, Database::LIMIT_SET_SIZE * 3))));
|
||||||
}
|
}
|
||||||
|
@ -860,11 +855,6 @@ trait SeriesArticle {
|
||||||
$this->compareExpectations($state);
|
$this->compareExpectations($state);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMarkTooFewMultipleEditions() {
|
|
||||||
$this->assertException("tooShort", "Db", "ExceptionInput");
|
|
||||||
Arsse::$db->articleMark($this->user, ['read'=>false,'starred'=>true], (new Context)->editions([]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testMarkTooManyMultipleEditions() {
|
public function testMarkTooManyMultipleEditions() {
|
||||||
$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))));
|
||||||
}
|
}
|
||||||
|
@ -1036,13 +1026,20 @@ trait SeriesArticle {
|
||||||
Arsse::$db->articleCategoriesGet($this->user, 19);
|
Arsse::$db->articleCategoriesGet($this->user, 19);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSearchTooFewTerms() {
|
/** @dataProvider provideArrayContextOptions */
|
||||||
$this->assertException("tooShort", "Db", "ExceptionInput");
|
public function testUseTooFewValuesInArrayContext(string $option) {
|
||||||
Arsse::$db->articleList($this->user, (new Context)->searchTerms([]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSearchTooFewTermsInNote() {
|
|
||||||
$this->assertException("tooShort", "Db", "ExceptionInput");
|
$this->assertException("tooShort", "Db", "ExceptionInput");
|
||||||
Arsse::$db->articleList($this->user, (new Context)->annotationTerms([]));
|
Arsse::$db->articleList($this->user, (new Context)->annotationTerms([]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function provideArrayContextOptions() {
|
||||||
|
foreach([
|
||||||
|
"articles", "editions",
|
||||||
|
"subscriptions", "foldersShallow", //"folders",
|
||||||
|
"tags", "tagNames", "labels", "labelNames",
|
||||||
|
"searchTerms", "authorTerms", "annotationTerms",
|
||||||
|
] as $method) {
|
||||||
|
yield [$method];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue