1
1
Fork 0
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:
J. King 2021-01-23 18:01:23 -05:00
parent 36cc4928b9
commit 7893b5f59d
2 changed files with 32 additions and 31 deletions

View file

@ -703,18 +703,16 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler {
}
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 {
Arsse::$db->feedAdd($data['feed_url'], (string) $data['username'], (string) $data['password'], false, (bool) $data['crawler']);
$tr = Arsse::$db->begin();
$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();
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) {
$msg = [
10502 => "Fetch404",

View file

@ -613,11 +613,13 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
}
if ($in3) {
$props = [
'keep_rule' => $in['keeplist_rules'],
'block_rule' => $in['blocklist_rules'],
'folder' => $in['category_id'] - 1,
'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);
} else {
\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("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], 2112, new ExceptionInput("constraintViolation"), null, new ErrorResponse("DuplicateFeed", 409)],
];
}
}