mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +00:00
More feed adding tests
This commit is contained in:
parent
36cc4928b9
commit
7893b5f59d
2 changed files with 32 additions and 31 deletions
|
@ -703,18 +703,16 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createFeed(array $data): ResponseInterface {
|
protected function createFeed(array $data): ResponseInterface {
|
||||||
$props = [
|
|
||||||
'keep_rule' => $data['keeplist_rules'],
|
|
||||||
'block_rule' => $data['blocklist_rules'],
|
|
||||||
'folder' => $data['category_id'] - 1,
|
|
||||||
'scrape' => (bool) $data['crawler'],
|
|
||||||
];
|
|
||||||
try {
|
try {
|
||||||
Arsse::$db->feedAdd($data['feed_url'], (string) $data['username'], (string) $data['password'], false, (bool) $data['crawler']);
|
Arsse::$db->feedAdd($data['feed_url'], (string) $data['username'], (string) $data['password'], false, (bool) $data['crawler']);
|
||||||
$tr = Arsse::$db->begin();
|
$tr = Arsse::$db->begin();
|
||||||
$id = Arsse::$db->subscriptionAdd(Arsse::$user->id, $data['feed_url'], (string) $data['username'], (string) $data['password'], false, (bool) $data['crawler']);
|
$id = Arsse::$db->subscriptionAdd(Arsse::$user->id, $data['feed_url'], (string) $data['username'], (string) $data['password'], false, (bool) $data['crawler']);
|
||||||
Arsse::$db->subscriptionPropertiesSet(Arsse::$user->id, $id, $props);
|
Arsse::$db->subscriptionPropertiesSet(Arsse::$user->id, $id, ['folder' => $data['category_id'] - 1, 'scrape' => (bool) $data['crawler']]);
|
||||||
$tr->commit();
|
$tr->commit();
|
||||||
|
if (strlen($data['keeplist_rules'] ?? "") || strlen($data['blocklist_rules'] ?? "")) {
|
||||||
|
// we do rules separately so as not to tie up the database
|
||||||
|
Arsse::$db->subscriptionPropertiesSet(Arsse::$user->id, $id, ['keep_rule' => $data['keeplist_rules'], 'block_rule' => $data['blocklist_rules']]);
|
||||||
|
}
|
||||||
} catch (FeedException $e) {
|
} catch (FeedException $e) {
|
||||||
$msg = [
|
$msg = [
|
||||||
10502 => "Fetch404",
|
10502 => "Fetch404",
|
||||||
|
|
|
@ -613,11 +613,13 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
}
|
}
|
||||||
if ($in3) {
|
if ($in3) {
|
||||||
$props = [
|
$props = [
|
||||||
'keep_rule' => $in['keeplist_rules'],
|
|
||||||
'block_rule' => $in['blocklist_rules'],
|
|
||||||
'folder' => $in['category_id'] - 1,
|
'folder' => $in['category_id'] - 1,
|
||||||
'scrape' => $in['crawler'] ?? false,
|
'scrape' => $in['crawler'] ?? false,
|
||||||
];
|
];
|
||||||
|
$rules = (strlen($in['keeplist_rules'] ?? "") || strlen($in['blocklist_rules'] ?? "")) ? [
|
||||||
|
'keep_rule' => $in['keeplist_rules'],
|
||||||
|
'block_rule' => $in['blocklist_rules'],
|
||||||
|
] : [];
|
||||||
\Phake::verify(Arsse::$db)->subscriptionPropertiesSet("john.doe@example.com", $out2, $props);
|
\Phake::verify(Arsse::$db)->subscriptionPropertiesSet("john.doe@example.com", $out2, $props);
|
||||||
} else {
|
} else {
|
||||||
\Phake::verify(Arsse::$db, \Phake::times(0))->subscriptionPropertiesSet;
|
\Phake::verify(Arsse::$db, \Phake::times(0))->subscriptionPropertiesSet;
|
||||||
|
@ -648,6 +650,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
|
||||||
[['feed_url' => "http://example.com/", 'category_id' => 1], new FeedException("xmlEntity"), null, null, new ErrorResponse("FetchOther", 502)],
|
[['feed_url' => "http://example.com/", 'category_id' => 1], new FeedException("xmlEntity"), null, null, new ErrorResponse("FetchOther", 502)],
|
||||||
[['feed_url' => "http://example.com/", 'category_id' => 1], new FeedException("subscriptionNotFound"), null, null, new ErrorResponse("Fetch404", 502)],
|
[['feed_url' => "http://example.com/", 'category_id' => 1], new FeedException("subscriptionNotFound"), null, null, new ErrorResponse("Fetch404", 502)],
|
||||||
[['feed_url' => "http://example.com/", 'category_id' => 1], new FeedException("unsupportedFeedFormat"), null, null, new ErrorResponse("FetchFormat", 502)],
|
[['feed_url' => "http://example.com/", 'category_id' => 1], new FeedException("unsupportedFeedFormat"), null, null, new ErrorResponse("FetchFormat", 502)],
|
||||||
|
[['feed_url' => "http://example.com/", 'category_id' => 1], 2112, new ExceptionInput("constraintViolation"), null, new ErrorResponse("DuplicateFeed", 409)],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue