2017-06-22 17:07:56 +00:00
< ? php
2017-11-17 01:23:18 +00:00
/** @ license MIT
* Copyright 2017 J . King , Dustin Wilson et al .
* See LICENSE and AUTHORS files for details */
2017-06-22 17:07:56 +00:00
declare ( strict_types = 1 );
2018-11-23 15:01:17 +00:00
namespace JKingWeb\Arsse\TestCase\Database ;
2017-08-29 14:50:31 +00:00
2017-11-07 04:32:29 +00:00
use JKingWeb\Arsse\Database ;
2017-07-17 11:47:57 +00:00
use JKingWeb\Arsse\Arsse ;
2019-02-26 03:41:12 +00:00
use JKingWeb\Arsse\Context\Context ;
2022-04-30 03:28:47 +00:00
use JKingWeb\Arsse\Context\UnionContext ;
use JKingWeb\Arsse\Context\RootContext ;
2017-07-17 11:47:57 +00:00
use JKingWeb\Arsse\Misc\Date ;
2019-04-04 21:21:23 +00:00
use JKingWeb\Arsse\Misc\ValueInfo ;
2017-06-22 17:07:56 +00:00
trait SeriesArticle {
2020-01-20 18:52:48 +00:00
protected function setUpSeriesArticle () : void {
2018-11-25 04:18:17 +00:00
$this -> data = [
'arsse_users' => [
2022-06-05 21:41:32 +00:00
'columns' => [ " id " , " password " , " num " ],
2018-11-25 04:18:17 +00:00
'rows' => [
2021-01-16 22:58:31 +00:00
[ " jane.doe@example.com " , " " , 1 ],
[ " john.doe@example.com " , " " , 2 ],
[ " john.doe@example.org " , " " , 3 ],
[ " john.doe@example.net " , " " , 4 ],
[ " jill.doe@example.com " , " " , 5 ],
2018-11-25 04:18:17 +00:00
],
2017-06-22 17:07:56 +00:00
],
2019-03-07 16:07:22 +00:00
'arsse_feeds' => [
2022-06-05 21:41:32 +00:00
'columns' => [ " id " , " url " , " title " ],
2019-03-07 16:07:22 +00:00
'rows' => [
[ 1 , " http://example.com/1 " , " Feed 1 " ],
[ 2 , " http://example.com/2 " , " Feed 2 " ],
[ 3 , " http://example.com/3 " , " Feed 3 " ],
[ 4 , " http://example.com/4 " , " Feed 4 " ],
[ 5 , " http://example.com/5 " , " Feed 5 " ],
[ 6 , " http://example.com/6 " , " Feed 6 " ],
[ 7 , " http://example.com/7 " , " Feed 7 " ],
[ 8 , " http://example.com/8 " , " Feed 8 " ],
[ 9 , " http://example.com/9 " , " Feed 9 " ],
[ 10 , " http://example.com/10 " , " Feed 10 " ],
[ 11 , " http://example.com/11 " , " Feed 11 " ],
[ 12 , " http://example.com/12 " , " Feed 12 " ],
[ 13 , " http://example.com/13 " , " Feed 13 " ],
2020-03-01 20:16:50 +00:00
],
2019-03-07 16:07:22 +00:00
],
2018-11-25 04:18:17 +00:00
'arsse_folders' => [
2022-06-05 21:41:32 +00:00
'columns' => [ " id " , " owner " , " parent " , " name " ],
2018-11-25 04:18:17 +00:00
'rows' => [
[ 1 , " john.doe@example.com " , null , " Technology " ],
[ 2 , " john.doe@example.com " , 1 , " Software " ],
[ 3 , " john.doe@example.com " , 1 , " Rocketry " ],
[ 4 , " jane.doe@example.com " , null , " Politics " ],
[ 5 , " john.doe@example.com " , null , " Politics " ],
[ 6 , " john.doe@example.com " , 2 , " Politics " ],
[ 7 , " john.doe@example.net " , null , " Technology " ],
[ 8 , " john.doe@example.net " , 7 , " Software " ],
[ 9 , " john.doe@example.net " , null , " Politics " ],
2020-03-01 20:16:50 +00:00
],
2017-06-22 17:07:56 +00:00
],
2019-03-07 16:07:22 +00:00
'arsse_tags' => [
2022-06-05 21:41:32 +00:00
'columns' => [ " id " , " owner " , " name " ],
2018-11-25 04:18:17 +00:00
'rows' => [
2019-03-07 16:07:22 +00:00
[ 1 , " john.doe@example.com " , " Technology " ],
[ 2 , " john.doe@example.com " , " Software " ],
[ 3 , " john.doe@example.com " , " Rocketry " ],
[ 4 , " jane.doe@example.com " , " Politics " ],
[ 5 , " john.doe@example.com " , " Politics " ],
[ 6 , " john.doe@example.net " , " Technology " ],
[ 7 , " john.doe@example.net " , " Software " ],
[ 8 , " john.doe@example.net " , " Politics " ],
2020-03-01 20:16:50 +00:00
],
2017-06-22 17:07:56 +00:00
],
2018-11-25 04:18:17 +00:00
'arsse_subscriptions' => [
2022-06-05 21:41:32 +00:00
'columns' => [ " id " , " owner " , " feed " , " folder " , " title " , " scrape " ],
2018-11-25 04:18:17 +00:00
'rows' => [
2022-06-05 21:41:32 +00:00
[ 1 , " john.doe@example.com " , 1 , null , " Subscription 1 " , 0 ],
[ 2 , " john.doe@example.com " , 2 , null , null , 0 ],
[ 3 , " john.doe@example.com " , 3 , 1 , " Subscription 3 " , 0 ],
[ 4 , " john.doe@example.com " , 4 , 6 , null , 0 ],
[ 5 , " john.doe@example.com " , 10 , 5 , " Subscription 5 " , 0 ],
[ 6 , " jane.doe@example.com " , 1 , null , null , 0 ],
[ 7 , " jane.doe@example.com " , 10 , null , " Subscription 7 " , 0 ],
[ 8 , " john.doe@example.org " , 11 , null , null , 0 ],
[ 9 , " john.doe@example.org " , 12 , null , " Subscription 9 " , 0 ],
[ 10 , " john.doe@example.org " , 13 , null , null , 0 ],
2021-01-16 21:48:35 +00:00
[ 11 , " john.doe@example.net " , 10 , null , " Subscription 11 " , 0 ],
2022-06-05 21:41:32 +00:00
[ 12 , " john.doe@example.net " , 2 , 9 , null , 0 ],
2021-01-16 21:48:35 +00:00
[ 13 , " john.doe@example.net " , 3 , 8 , " Subscription 13 " , 0 ],
2022-06-05 21:41:32 +00:00
[ 14 , " john.doe@example.net " , 4 , 7 , null , 0 ],
[ 15 , " jill.doe@example.com " , 11 , null , null , 1 ],
2020-03-01 20:16:50 +00:00
],
2017-06-22 17:07:56 +00:00
],
2019-03-07 16:07:22 +00:00
'arsse_tag_members' => [
2022-06-05 21:41:32 +00:00
'columns' => [ " tag " , " subscription " , " assigned " ],
2019-03-07 16:07:22 +00:00
'rows' => [
[ 1 , 3 , 1 ],
[ 1 , 4 , 1 ],
[ 2 , 4 , 1 ],
[ 5 , 1 , 0 ],
[ 5 , 4 , 1 ],
[ 5 , 5 , 1 ],
[ 6 , 13 , 1 ],
[ 6 , 14 , 1 ],
[ 7 , 13 , 1 ],
[ 8 , 12 , 1 ],
],
],
2018-11-25 04:18:17 +00:00
'arsse_articles' => [
'columns' => [
2022-06-05 21:41:32 +00:00
" id " , " feed " , " url " , " title " , " author " , " published " , " edited " , " content " , " guid " ,
" url_title_hash " , " url_content_hash " , " title_content_hash " , " modified " , " content_scraped "
2018-11-25 04:18:17 +00:00
],
'rows' => [
2021-01-16 21:48:35 +00:00
[ 1 , 1 , null , " Title one " , null , null , null , " First article " , null , " " , " " , " " , " 2000-01-01T00:00:00Z " , null ],
[ 2 , 1 , null , " Title two " , null , null , null , " Second article " , null , " " , " " , " " , " 2010-01-01T00:00:00Z " , null ],
[ 3 , 2 , null , " Title three " , null , null , null , " Third article " , null , " " , " " , " " , " 2000-01-01T00:00:00Z " , null ],
[ 4 , 2 , null , null , " John Doe " , null , null , null , null , " " , " " , " " , " 2010-01-01T00:00:00Z " , null ],
[ 5 , 3 , null , null , " John Doe " , null , null , null , null , " " , " " , " " , " 2000-01-01T00:00:00Z " , null ],
[ 6 , 3 , null , null , " Jane Doe " , null , null , null , null , " " , " " , " " , " 2010-01-01T00:00:00Z " , null ],
[ 7 , 4 , null , null , " Jane Doe " , null , null , null , null , " " , " " , " " , " 2000-01-01T00:00:00Z " , null ],
[ 8 , 4 , null , null , null , null , null , null , null , " " , " " , " " , " 2010-01-01T00:00:00Z " , null ],
[ 9 , 5 , null , null , null , null , null , null , null , " " , " " , " " , " 2000-01-01T00:00:00Z " , null ],
[ 10 , 5 , null , null , null , null , null , null , null , " " , " " , " " , " 2010-01-01T00:00:00Z " , null ],
[ 11 , 6 , null , null , null , null , null , null , null , " " , " " , " " , " 2000-01-01T00:00:00Z " , null ],
[ 12 , 6 , null , null , null , null , null , null , null , " " , " " , " " , " 2010-01-01T00:00:00Z " , null ],
[ 13 , 7 , null , null , null , null , null , null , null , " " , " " , " " , " 2000-01-01T00:00:00Z " , null ],
[ 14 , 7 , null , null , null , null , null , null , null , " " , " " , " " , " 2010-01-01T00:00:00Z " , null ],
[ 15 , 8 , null , null , null , null , null , null , null , " " , " " , " " , " 2000-01-01T00:00:00Z " , null ],
[ 16 , 8 , null , null , null , null , null , null , null , " " , " " , " " , " 2010-01-01T00:00:00Z " , null ],
[ 17 , 9 , null , null , null , null , null , null , null , " " , " " , " " , " 2000-01-01T00:00:00Z " , null ],
[ 18 , 9 , null , null , null , null , null , null , null , " " , " " , " " , " 2010-01-01T00:00:00Z " , null ],
[ 19 , 10 , null , null , null , null , null , null , null , " " , " " , " " , " 2000-01-01T00:00:00Z " , null ],
[ 20 , 10 , null , null , null , null , null , null , null , " " , " " , " " , " 2010-01-01T00:00:00Z " , null ],
[ 101 , 11 , 'http://example.com/1' , 'Article title 1' , '' , '2000-01-01 00:00:00' , '2000-01-01 00:00:01' , '<p>Article content 1</p>' , 'e433653cef2e572eee4215fa299a4a5af9137b2cefd6283c85bd69a32915beda' , 'f5cb8bfc1c7396dc9816af212a3e2ac5221585c2a00bf7ccb6aabd95dcfcd6a6' , 'fb0bc8f8cb08913dc5a497db700e327f1d34e4987402687d494a5891f24714d4' , '18fdd4fa93d693128c43b004399e5c9cea6c261ddfa002518d3669f55d8c2207' , '2000-01-01 01:00:00' , " <p>Scraped content 1</p> " ],
[ 102 , 11 , 'http://example.com/2' , 'Article title 2' , '' , '2000-01-02 00:00:00' , '2000-01-02 00:00:02' , '<p>Article content 2</p>' , '5be8a5a46ecd52ed132191c8d27fb1af6b3d4edc00234c5d9f8f0e10562ed3b7' , '0e86d2de822a174fe3c44a466953e63ca1f1a58a19cbf475fce0855d4e3d5153' , '13075894189c47ffcfafd1dfe7fbb539f7c74a69d35a399b3abf8518952714f9' , '2abd0a8cba83b8214a66c8f0293ba63e467d720540e29ff8ddcdab069d4f1c9e' , '2000-01-02 02:00:00' , null ],
[ 103 , 12 , 'http://example.com/3' , 'Article title 3' , '' , '2000-01-03 00:00:00' , '2000-01-03 00:00:03' , '<p>Article content 3</p>' , '31a6594500a48b59fcc8a075ce82b946c9c3c782460d088bd7b8ef3ede97ad92' , 'f74b06b240bd08abf4d3fdfc20dba6a6f6eb8b4f1a00e9a617efd63a87180a4b' , 'b278380e984cefe63f0e412b88ffc9cb0befdfa06fdc00bace1da99a8daff406' , 'ad622b31e739cd3a3f3c788991082cf4d2f7a8773773008e75f0572e58cd373b' , '2000-01-03 03:00:00' , null ],
[ 104 , 12 , 'http://example.com/4' , 'Article title 4' , '' , '2000-01-04 00:00:00' , '2000-01-04 00:00:04' , '<p>Article content 4</p>' , '804e517d623390e71497982c77cf6823180342ebcd2e7d5e32da1e55b09dd180' , 'f3615c7f16336d3ea242d35cf3fc17dbc4ee3afb78376bf49da2dd7a5a25dec8' , 'f11c2b4046f207579aeb9c69a8c20ca5461cef49756ccfa5ba5e2344266da3b3' , 'ab2da63276acce431250b18d3d49b988b226a99c7faadf275c90b751aee05be9' , '2000-01-04 04:00:00' , null ],
[ 105 , 13 , 'http://example.com/5' , 'Article title 5' , '' , '2000-01-05 00:00:00' , '2000-01-05 00:00:05' , '<p>Article content 5</p>' , 'db3e736c2c492f5def5c5da33ddcbea1824040e9ced2142069276b0a6e291a41' , 'd40da96e39eea6c55948ccbe9b3d275b5f931298288dbe953990c5f496097022' , '834240f84501b5341d375414718204ec421561f3825d34c22bf9182203e42900' , '43b970ac6ec5f8a9647b2c7e4eed8b1d7f62e154a95eed748b0294c1256764ba' , '2000-01-05 05:00:00' , null ],
2020-03-01 20:16:50 +00:00
],
2017-06-22 17:07:56 +00:00
],
2018-11-25 04:18:17 +00:00
'arsse_enclosures' => [
2022-06-05 21:41:32 +00:00
'columns' => [ " article " , " url " , " type " ],
2018-11-25 04:18:17 +00:00
'rows' => [
[ 102 , " http://example.com/text " , " text/plain " ],
[ 103 , " http://example.com/video " , " video/webm " ],
[ 104 , " http://example.com/image " , " image/svg+xml " ],
[ 105 , " http://example.com/audio " , " audio/ogg " ],
2020-03-01 20:16:50 +00:00
],
2017-06-22 17:07:56 +00:00
],
2018-11-25 04:18:17 +00:00
'arsse_editions' => [
2022-06-05 21:41:32 +00:00
'columns' => [ " id " , " article " ],
2018-11-25 04:18:17 +00:00
'rows' => [
[ 1 , 1 ],
[ 2 , 2 ],
[ 3 , 3 ],
[ 4 , 4 ],
[ 5 , 5 ],
[ 6 , 6 ],
[ 7 , 7 ],
[ 8 , 8 ],
[ 9 , 9 ],
[ 10 , 10 ],
[ 11 , 11 ],
[ 12 , 12 ],
[ 13 , 13 ],
[ 14 , 14 ],
[ 15 , 15 ],
[ 16 , 16 ],
[ 17 , 17 ],
[ 18 , 18 ],
[ 19 , 19 ],
[ 20 , 20 ],
[ 101 , 101 ],
[ 102 , 102 ],
[ 103 , 103 ],
[ 104 , 104 ],
[ 105 , 105 ],
[ 202 , 102 ],
[ 203 , 103 ],
[ 204 , 104 ],
[ 205 , 105 ],
[ 305 , 105 ],
[ 1001 , 20 ],
2020-03-01 20:16:50 +00:00
],
2017-06-22 17:07:56 +00:00
],
2018-11-25 04:18:17 +00:00
'arsse_marks' => [
2022-06-05 21:41:32 +00:00
'columns' => [ " subscription " , " article " , " read " , " starred " , " modified " , " note " , " hidden " ],
2018-11-25 04:18:17 +00:00
'rows' => [
2020-12-16 00:28:51 +00:00
[ 1 , 1 , 1 , 1 , '2000-01-01 00:00:00' , '' , 0 ],
[ 5 , 19 , 1 , 0 , '2016-01-01 00:00:00' , '' , 0 ],
[ 5 , 20 , 0 , 1 , '2005-01-01 00:00:00' , '' , 0 ],
[ 7 , 20 , 1 , 0 , '2010-01-01 00:00:00' , '' , 0 ],
[ 8 , 102 , 1 , 0 , '2000-01-02 02:00:00' , 'Note 2' , 0 ],
[ 9 , 103 , 0 , 1 , '2000-01-03 03:00:00' , 'Note 3' , 0 ],
[ 9 , 104 , 1 , 1 , '2000-01-04 04:00:00' , 'Note 4' , 0 ],
[ 10 , 105 , 0 , 0 , '2000-01-05 05:00:00' , '' , 0 ],
[ 11 , 19 , 0 , 0 , '2017-01-01 00:00:00' , 'ook' , 0 ],
[ 11 , 20 , 1 , 0 , '2017-01-01 00:00:00' , 'eek' , 0 ],
[ 12 , 3 , 0 , 1 , '2017-01-01 00:00:00' , 'ack' , 0 ],
[ 12 , 4 , 1 , 1 , '2017-01-01 00:00:00' , 'ach' , 0 ],
[ 1 , 2 , 0 , 0 , '2010-01-01 00:00:00' , 'Some Note' , 0 ],
2020-12-20 22:34:32 +00:00
[ 3 , 6 , 0 , 0 , '2000-01-01 00:00:00' , '' , 1 ],
2020-12-17 23:12:52 +00:00
[ 6 , 1 , 0 , 1 , '2010-01-01 00:00:00' , '' , 1 ],
2020-12-19 15:59:40 +00:00
[ 6 , 2 , 1 , 0 , '2010-01-01 00:00:00' , '' , 1 ],
2020-03-01 20:16:50 +00:00
],
2017-06-22 17:07:56 +00:00
],
2018-11-25 04:18:17 +00:00
'arsse_categories' => [ // author-supplied categories
2022-06-05 21:41:32 +00:00
'columns' => [ " article " , " name " ],
2018-11-25 04:18:17 +00:00
'rows' => [
[ 19 , " Fascinating " ],
[ 19 , " Logical " ],
[ 20 , " Interesting " ],
[ 20 , " Logical " ],
],
2017-06-22 17:07:56 +00:00
],
2022-06-05 21:41:32 +00:00
'arsse_labels' => [ // labels applied to articles
'columns' => [ " id " , " owner " , " name " ],
2018-11-25 04:18:17 +00:00
'rows' => [
[ 1 , " john.doe@example.com " , " Interesting " ],
[ 2 , " john.doe@example.com " , " Fascinating " ],
[ 3 , " jane.doe@example.com " , " Boring " ],
[ 4 , " john.doe@example.com " , " Lonely " ],
],
2017-11-21 14:22:58 +00:00
],
2018-11-25 04:18:17 +00:00
'arsse_label_members' => [
2022-06-05 21:41:32 +00:00
'columns' => [ " label " , " article " , " subscription " , " assigned " , " modified " ],
2018-11-25 04:18:17 +00:00
'rows' => [
[ 1 , 1 , 1 , 1 , '2000-01-01 00:00:00' ],
[ 2 , 1 , 1 , 1 , '2000-01-01 00:00:00' ],
[ 1 , 19 , 5 , 1 , '2000-01-01 00:00:00' ],
[ 2 , 20 , 5 , 1 , '2000-01-01 00:00:00' ],
[ 1 , 5 , 3 , 0 , '2000-01-01 00:00:00' ],
[ 2 , 5 , 3 , 1 , '2000-01-01 00:00:00' ],
[ 4 , 7 , 4 , 0 , '2000-01-01 00:00:00' ],
[ 4 , 8 , 4 , 1 , '2015-01-01 00:00:00' ],
],
2017-11-21 14:22:58 +00:00
],
2018-11-25 04:18:17 +00:00
];
$this -> matches = [
[
2020-03-01 20:16:50 +00:00
'id' => 101 ,
'url' => 'http://example.com/1' ,
'title' => 'Article title 1' ,
2018-11-25 04:18:17 +00:00
'subscription_title' => " Feed 11 " ,
2020-03-01 20:16:50 +00:00
'author' => '' ,
'content' => '<p>Article content 1</p>' ,
'guid' => 'e433653cef2e572eee4215fa299a4a5af9137b2cefd6283c85bd69a32915beda' ,
'published_date' => '2000-01-01 00:00:00' ,
'edited_date' => '2000-01-01 00:00:01' ,
'modified_date' => '2000-01-01 01:00:00' ,
'unread' => 1 ,
'starred' => 0 ,
'edition' => 101 ,
'subscription' => 8 ,
'fingerprint' => 'f5cb8bfc1c7396dc9816af212a3e2ac5221585c2a00bf7ccb6aabd95dcfcd6a6:fb0bc8f8cb08913dc5a497db700e327f1d34e4987402687d494a5891f24714d4:18fdd4fa93d693128c43b004399e5c9cea6c261ddfa002518d3669f55d8c2207' ,
'media_url' => null ,
'media_type' => null ,
'note' => " " ,
2017-10-13 04:04:26 +00:00
],
2018-11-25 04:18:17 +00:00
[
2020-03-01 20:16:50 +00:00
'id' => 102 ,
'url' => 'http://example.com/2' ,
'title' => 'Article title 2' ,
2018-11-25 04:18:17 +00:00
'subscription_title' => " Feed 11 " ,
2020-03-01 20:16:50 +00:00
'author' => '' ,
'content' => '<p>Article content 2</p>' ,
'guid' => '5be8a5a46ecd52ed132191c8d27fb1af6b3d4edc00234c5d9f8f0e10562ed3b7' ,
'published_date' => '2000-01-02 00:00:00' ,
'edited_date' => '2000-01-02 00:00:02' ,
'modified_date' => '2000-01-02 02:00:00' ,
'unread' => 0 ,
'starred' => 0 ,
'edition' => 202 ,
'subscription' => 8 ,
'fingerprint' => '0e86d2de822a174fe3c44a466953e63ca1f1a58a19cbf475fce0855d4e3d5153:13075894189c47ffcfafd1dfe7fbb539f7c74a69d35a399b3abf8518952714f9:2abd0a8cba83b8214a66c8f0293ba63e467d720540e29ff8ddcdab069d4f1c9e' ,
'media_url' => " http://example.com/text " ,
'media_type' => " text/plain " ,
'note' => " Note 2 " ,
2017-10-13 04:04:26 +00:00
],
2018-11-25 04:18:17 +00:00
[
2020-03-01 20:16:50 +00:00
'id' => 103 ,
'url' => 'http://example.com/3' ,
'title' => 'Article title 3' ,
2018-11-25 04:18:17 +00:00
'subscription_title' => " Subscription 9 " ,
2020-03-01 20:16:50 +00:00
'author' => '' ,
'content' => '<p>Article content 3</p>' ,
'guid' => '31a6594500a48b59fcc8a075ce82b946c9c3c782460d088bd7b8ef3ede97ad92' ,
'published_date' => '2000-01-03 00:00:00' ,
'edited_date' => '2000-01-03 00:00:03' ,
'modified_date' => '2000-01-03 03:00:00' ,
'unread' => 1 ,
'starred' => 1 ,
'edition' => 203 ,
'subscription' => 9 ,
'fingerprint' => 'f74b06b240bd08abf4d3fdfc20dba6a6f6eb8b4f1a00e9a617efd63a87180a4b:b278380e984cefe63f0e412b88ffc9cb0befdfa06fdc00bace1da99a8daff406:ad622b31e739cd3a3f3c788991082cf4d2f7a8773773008e75f0572e58cd373b' ,
'media_url' => " http://example.com/video " ,
'media_type' => " video/webm " ,
'note' => " Note 3 " ,
2017-10-13 04:04:26 +00:00
],
2018-11-25 04:18:17 +00:00
[
2020-03-01 20:16:50 +00:00
'id' => 104 ,
'url' => 'http://example.com/4' ,
'title' => 'Article title 4' ,
2018-11-25 04:18:17 +00:00
'subscription_title' => " Subscription 9 " ,
2020-03-01 20:16:50 +00:00
'author' => '' ,
'content' => '<p>Article content 4</p>' ,
'guid' => '804e517d623390e71497982c77cf6823180342ebcd2e7d5e32da1e55b09dd180' ,
'published_date' => '2000-01-04 00:00:00' ,
'edited_date' => '2000-01-04 00:00:04' ,
'modified_date' => '2000-01-04 04:00:00' ,
'unread' => 0 ,
'starred' => 1 ,
'edition' => 204 ,
'subscription' => 9 ,
'fingerprint' => 'f3615c7f16336d3ea242d35cf3fc17dbc4ee3afb78376bf49da2dd7a5a25dec8:f11c2b4046f207579aeb9c69a8c20ca5461cef49756ccfa5ba5e2344266da3b3:ab2da63276acce431250b18d3d49b988b226a99c7faadf275c90b751aee05be9' ,
'media_url' => " http://example.com/image " ,
'media_type' => " image/svg+xml " ,
'note' => " Note 4 " ,
2017-10-13 04:04:26 +00:00
],
2018-11-25 04:18:17 +00:00
[
2020-03-01 20:16:50 +00:00
'id' => 105 ,
'url' => 'http://example.com/5' ,
'title' => 'Article title 5' ,
2018-11-25 04:18:17 +00:00
'subscription_title' => " Feed 13 " ,
2020-03-01 20:16:50 +00:00
'author' => '' ,
'content' => '<p>Article content 5</p>' ,
'guid' => 'db3e736c2c492f5def5c5da33ddcbea1824040e9ced2142069276b0a6e291a41' ,
'published_date' => '2000-01-05 00:00:00' ,
'edited_date' => '2000-01-05 00:00:05' ,
'modified_date' => '2000-01-05 05:00:00' ,
'unread' => 1 ,
'starred' => 0 ,
'edition' => 305 ,
'subscription' => 10 ,
'fingerprint' => 'd40da96e39eea6c55948ccbe9b3d275b5f931298288dbe953990c5f496097022:834240f84501b5341d375414718204ec421561f3825d34c22bf9182203e42900:43b970ac6ec5f8a9647b2c7e4eed8b1d7f62e154a95eed748b0294c1256764ba' ,
'media_url' => " http://example.com/audio " ,
'media_type' => " audio/ogg " ,
'note' => " " ,
2018-11-25 04:18:17 +00:00
],
];
$this -> fields = [
2021-02-02 16:51:19 +00:00
" id " , " subscription " , " feed " , " modified_date " , " marked_date " , " unread " , " starred " , " hidden " , " edition " , " edited_date " ,
2018-12-05 21:55:14 +00:00
" url " , " title " , " subscription_title " , " author " , " guid " , " published_date " , " fingerprint " ,
2021-02-02 16:51:19 +00:00
" folder " , " top_folder " , " folder_name " , " top_folder_name " ,
2018-12-05 21:55:14 +00:00
" content " , " media_url " , " media_type " ,
" note " ,
2018-11-25 04:18:17 +00:00
];
2020-12-16 00:50:26 +00:00
$this -> checkTables = [ 'arsse_marks' => [ " subscription " , " article " , " read " , " starred " , " modified " , " note " , " hidden " ]];
2017-06-30 03:56:43 +00:00
$this -> user = " john.doe@example.net " ;
2017-06-22 17:07:56 +00:00
}
2020-01-20 18:52:48 +00:00
protected function tearDownSeriesArticle () : void {
2018-11-25 04:18:17 +00:00
unset ( $this -> data , $this -> matches , $this -> fields , $this -> checkTables , $this -> user );
2017-07-05 13:09:38 +00:00
}
2019-02-25 21:26:38 +00:00
/** @dataProvider provideContextMatches */
2022-04-30 03:28:47 +00:00
public function testListArticlesCheckingContext ( RootContext $c , array $exp ) : void {
2019-08-05 20:33:48 +00:00
$ids = array_column ( $ids = Arsse :: $db -> articleList ( " john.doe@example.com " , $c , [ " id " ], [ " id " ]) -> getAll (), " id " );
2019-02-25 21:26:38 +00:00
sort ( $ids );
sort ( $exp );
$this -> assertEquals ( $exp , $ids );
}
2019-10-16 18:42:43 +00:00
public function provideContextMatches () : iterable {
2020-03-01 23:32:01 +00:00
$setSize = ( new \ReflectionClassConstant ( Database :: class , " LIMIT_SET_SIZE " )) -> getValue ();
2019-02-25 21:26:38 +00:00
return [
2020-03-01 20:16:50 +00:00
'Blank context' => [ new Context , [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 19 , 20 ]],
'Folder tree' => [( new Context ) -> folder ( 1 ), [ 5 , 6 , 7 , 8 ]],
'Entire folder tree' => [( new Context ) -> folder ( 0 ), [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 19 , 20 ]],
'Leaf folder' => [( new Context ) -> folder ( 6 ), [ 7 , 8 ]],
'Multiple folder trees' => [( new Context ) -> folders ([ 1 , 5 ]), [ 5 , 6 , 7 , 8 , 19 , 20 ]],
'Multiple folder trees including root' => [( new Context ) -> folders ([ 0 , 1 , 5 ]), [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 19 , 20 ]],
'Shallow folder' => [( new Context ) -> folderShallow ( 1 ), [ 5 , 6 ]],
'Root folder only' => [( new Context ) -> folderShallow ( 0 ), [ 1 , 2 , 3 , 4 ]],
'Multiple shallow folders' => [( new Context ) -> foldersShallow ([ 1 , 6 ]), [ 5 , 6 , 7 , 8 ]],
'Subscription' => [( new Context ) -> subscription ( 5 ), [ 19 , 20 ]],
'Multiple subscriptions' => [( new Context ) -> subscriptions ([ 4 , 5 ]), [ 7 , 8 , 19 , 20 ]],
'Unread' => [( new Context ) -> subscription ( 5 ) -> unread ( true ), [ 20 ]],
'Read' => [( new Context ) -> subscription ( 5 ) -> unread ( false ), [ 19 ]],
'Starred' => [( new Context ) -> starred ( true ), [ 1 , 20 ]],
'Unstarred' => [( new Context ) -> starred ( false ), [ 2 , 3 , 4 , 5 , 6 , 7 , 8 , 19 ]],
'Starred and Read' => [( new Context ) -> starred ( true ) -> unread ( false ), [ 1 ]],
'Starred and Read in subscription' => [( new Context ) -> starred ( true ) -> unread ( false ) -> subscription ( 5 ), []],
'Annotated' => [( new Context ) -> annotated ( true ), [ 2 ]],
'Not annotated' => [( new Context ) -> annotated ( false ), [ 1 , 3 , 4 , 5 , 6 , 7 , 8 , 19 , 20 ]],
2020-12-20 22:34:32 +00:00
'Hidden' => [( new Context ) -> hidden ( true ), [ 6 ]],
'Not hidden' => [( new Context ) -> hidden ( false ), [ 1 , 2 , 3 , 4 , 5 , 7 , 8 , 19 , 20 ]],
2020-03-01 20:16:50 +00:00
'Labelled' => [( new Context ) -> labelled ( true ), [ 1 , 5 , 8 , 19 , 20 ]],
'Not labelled' => [( new Context ) -> labelled ( false ), [ 2 , 3 , 4 , 6 , 7 ]],
2022-04-20 02:53:36 +00:00
'Not after edition 999' => [( new Context ) -> subscription ( 5 ) -> editionRange ( null , 999 ), [ 19 ]],
'Not after edition 19' => [( new Context ) -> subscription ( 5 ) -> editionRange ( null , 19 ), [ 19 ]],
'Not before edition 999' => [( new Context ) -> subscription ( 5 ) -> editionRange ( 999 , null ), [ 20 ]],
'Not before edition 1001' => [( new Context ) -> subscription ( 5 ) -> editionRange ( 1001 , null ), [ 20 ]],
'Not after article 3' => [( new Context ) -> articleRange ( null , 3 ), [ 1 , 2 , 3 ]],
'Not before article 19' => [( new Context ) -> articleRange ( 19 , null ), [ 19 , 20 ]],
2022-04-20 00:19:51 +00:00
'Modified by author since 2005' => [( new Context ) -> modifiedRange ( " 2005-01-01T00:00:00Z " , null ), [ 2 , 4 , 6 , 8 , 20 ]],
'Modified by author since 2010' => [( new Context ) -> modifiedRange ( " 2010-01-01T00:00:00Z " , null ), [ 2 , 4 , 6 , 8 , 20 ]],
'Not modified by author since 2005' => [( new Context ) -> modifiedRange ( null , " 2005-01-01T00:00:00Z " ), [ 1 , 3 , 5 , 7 , 19 ]],
'Not modified by author since 2000' => [( new Context ) -> modifiedRange ( null , " 2000-01-01T00:00:00Z " ), [ 1 , 3 , 5 , 7 , 19 ]],
'Marked or labelled since 2014' => [( new Context ) -> markedRange ( " 2014-01-01T00:00:00Z " , null ), [ 8 , 19 ]],
'Marked or labelled since 2010' => [( new Context ) -> markedRange ( " 2010-01-01T00:00:00Z " , null ), [ 2 , 4 , 6 , 8 , 19 , 20 ]],
'Not marked or labelled since 2014' => [( new Context ) -> markedRange ( null , " 2014-01-01T00:00:00Z " ), [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 20 ]],
'Not marked or labelled since 2005' => [( new Context ) -> markedRange ( null , " 2005-01-01T00:00:00Z " ), [ 1 , 3 , 5 , 7 ]],
'Marked or labelled between 2000 and 2015' => [( new Context ) -> markedRange ( " 2000-01-01T00:00:00Z " , " 2015-12-31T23:59:59Z " ), [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 20 ]],
'Marked or labelled in 2010' => [( new Context ) -> markedRange ( " 2010-01-01T00:00:00Z " , " 2010-12-31T23:59:59Z " ), [ 2 , 4 , 6 , 20 ]],
2022-04-20 02:53:36 +00:00
'Paged results' => [( new Context ) -> limit ( 2 ) -> editionRange ( 4 , null ), [ 4 , 5 ]],
2020-03-01 20:16:50 +00:00
'With label ID 1' => [( new Context ) -> label ( 1 ), [ 1 , 19 ]],
'With label ID 2' => [( new Context ) -> label ( 2 ), [ 1 , 5 , 20 ]],
'With label ID 1 or 2' => [( new Context ) -> labels ([ 1 , 2 ]), [ 1 , 5 , 19 , 20 ]],
'With label "Interesting"' => [( new Context ) -> labelName ( " Interesting " ), [ 1 , 19 ]],
'With label "Fascinating"' => [( new Context ) -> labelName ( " Fascinating " ), [ 1 , 5 , 20 ]],
'With label "Interesting" or "Fascinating"' => [( new Context ) -> labelNames ([ " Interesting " , " Fascinating " ]), [ 1 , 5 , 19 , 20 ]],
'Article ID 20' => [( new Context ) -> article ( 20 ), [ 20 ]],
'Edition ID 1001' => [( new Context ) -> edition ( 1001 ), [ 20 ]],
'Multiple articles' => [( new Context ) -> articles ([ 1 , 20 , 50 ]), [ 1 , 20 ]],
'Multiple starred articles' => [( new Context ) -> articles ([ 1 , 2 , 3 ]) -> starred ( true ), [ 1 ]],
'Multiple unstarred articles' => [( new Context ) -> articles ([ 1 , 2 , 3 ]) -> starred ( false ), [ 2 , 3 ]],
'Multiple articles' => [( new Context ) -> articles ([ 1 , 20 , 50 ]), [ 1 , 20 ]],
'Multiple editions' => [( new Context ) -> editions ([ 1 , 1001 , 50 ]), [ 1 , 20 ]],
2020-03-01 23:32:01 +00:00
'150 articles' => [( new Context ) -> articles ( range ( 1 , $setSize * 3 )), [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 19 , 20 ]],
2020-03-01 20:16:50 +00:00
'Search title or content 1' => [( new Context ) -> searchTerms ([ " Article " ]), [ 1 , 2 , 3 ]],
'Search title or content 2' => [( new Context ) -> searchTerms ([ " one " , " first " ]), [ 1 ]],
'Search title or content 3' => [( new Context ) -> searchTerms ([ " one first " ]), []],
'Search title 1' => [( new Context ) -> titleTerms ([ " two " ]), [ 2 ]],
'Search title 2' => [( new Context ) -> titleTerms ([ " title two " ]), [ 2 ]],
'Search title 3' => [( new Context ) -> titleTerms ([ " two " , " title " ]), [ 2 ]],
'Search title 4' => [( new Context ) -> titleTerms ([ " two title " ]), []],
'Search note 1' => [( new Context ) -> annotationTerms ([ " some " ]), [ 2 ]],
'Search note 2' => [( new Context ) -> annotationTerms ([ " some Note " ]), [ 2 ]],
'Search note 3' => [( new Context ) -> annotationTerms ([ " note " , " some " ]), [ 2 ]],
'Search note 4' => [( new Context ) -> annotationTerms ([ " some " , " sauce " ]), []],
'Search author 1' => [( new Context ) -> authorTerms ([ " doe " ]), [ 4 , 5 , 6 , 7 ]],
'Search author 2' => [( new Context ) -> authorTerms ([ " jane doe " ]), [ 6 , 7 ]],
'Search author 3' => [( new Context ) -> authorTerms ([ " doe " , " jane " ]), [ 6 , 7 ]],
'Search author 4' => [( new Context ) -> authorTerms ([ " doe jane " ]), []],
'Folder tree 1 excluding subscription 4' => [( new Context ) -> not -> subscription ( 4 ) -> folder ( 1 ), [ 5 , 6 ]],
'Folder tree 1 excluding articles 7 and 8' => [( new Context ) -> folder ( 1 ) -> not -> articles ([ 7 , 8 ]), [ 5 , 6 ]],
'Folder tree 1 excluding no articles' => [( new Context ) -> folder ( 1 ) -> not -> articles ([]), [ 5 , 6 , 7 , 8 ]],
2022-04-23 02:46:13 +00:00
'Folder tree 1 excluding no labels' => [( new Context ) -> folder ( 1 ) -> not -> labels ([]), [ 5 , 6 , 7 , 8 ]],
'Folder tree 1 excluding no tags' => [( new Context ) -> folder ( 1 ) -> not -> tags ([]), [ 5 , 6 , 7 , 8 ]],
2022-04-20 00:19:51 +00:00
'Marked or labelled between 2000 and 2015 excluding in 2010' => [( new Context ) -> markedRange ( " 2000-01-01T00:00:00Z " , " 2015-12-31T23:59:59 " ) -> not -> markedRange ( " 2010-01-01T00:00:00Z " , " 2010-12-31T23:59:59Z " ), [ 1 , 3 , 5 , 7 , 8 ]],
2020-03-01 20:16:50 +00:00
'Search with exclusion' => [( new Context ) -> searchTerms ([ " Article " ]) -> not -> searchTerms ([ " one " , " two " ]), [ 3 ]],
'Excluded folder tree' => [( new Context ) -> not -> folder ( 1 ), [ 1 , 2 , 3 , 4 , 19 , 20 ]],
'Excluding label ID 2' => [( new Context ) -> not -> label ( 2 ), [ 2 , 3 , 4 , 6 , 7 , 8 , 19 ]],
'Excluding label "Fascinating"' => [( new Context ) -> not -> labelName ( " Fascinating " ), [ 2 , 3 , 4 , 6 , 7 , 8 , 19 ]],
'Search 501 terms' => [( new Context ) -> searchTerms ( array_merge ( range ( 1 , 500 ), [ str_repeat ( " a " , 1000 )])), []],
'With tag ID 1' => [( new Context ) -> tag ( 1 ), [ 5 , 6 , 7 , 8 ]],
'With tag ID 5' => [( new Context ) -> tag ( 5 ), [ 7 , 8 , 19 , 20 ]],
'With tag ID 1 or 5' => [( new Context ) -> tags ([ 1 , 5 ]), [ 5 , 6 , 7 , 8 , 19 , 20 ]],
'With tag "Technology"' => [( new Context ) -> tagName ( " Technology " ), [ 5 , 6 , 7 , 8 ]],
'With tag "Politics"' => [( new Context ) -> tagName ( " Politics " ), [ 7 , 8 , 19 , 20 ]],
'With tag "Technology" or "Politics"' => [( new Context ) -> tagNames ([ " Technology " , " Politics " ]), [ 5 , 6 , 7 , 8 , 19 , 20 ]],
'Excluding tag ID 1' => [( new Context ) -> not -> tag ( 1 ), [ 1 , 2 , 3 , 4 , 19 , 20 ]],
'Excluding tag ID 5' => [( new Context ) -> not -> tag ( 5 ), [ 1 , 2 , 3 , 4 , 5 , 6 ]],
'Excluding tag "Technology"' => [( new Context ) -> not -> tagName ( " Technology " ), [ 1 , 2 , 3 , 4 , 19 , 20 ]],
'Excluding tag "Politics"' => [( new Context ) -> not -> tagName ( " Politics " ), [ 1 , 2 , 3 , 4 , 5 , 6 ]],
'Excluding tags ID 1 and 5' => [( new Context ) -> not -> tags ([ 1 , 5 ]), [ 1 , 2 , 3 , 4 ]],
'Excluding tags "Technology" and "Politics"' => [( new Context ) -> not -> tagNames ([ " Technology " , " Politics " ]), [ 1 , 2 , 3 , 4 ]],
'Excluding entire folder tree' => [( new Context ) -> not -> folder ( 0 ), []],
'Excluding multiple folder trees' => [( new Context ) -> not -> folders ([ 1 , 5 ]), [ 1 , 2 , 3 , 4 ]],
'Excluding multiple folder trees including root' => [( new Context ) -> not -> folders ([ 0 , 1 , 5 ]), []],
2022-04-20 23:11:04 +00:00
'Before article 3' => [( new Context ) -> not -> articleRange ( 3 , null ), [ 1 , 2 ]],
'Before article 19' => [( new Context ) -> not -> articleRange ( null , 19 ), [ 20 ]],
2022-04-25 18:33:19 +00:00
'Marked or labelled in 2010 or 2015' => [( new Context ) -> markedRanges ([[ " 2010-01-01T00:00:00Z " , " 2010-12-31T23:59:59Z " ], [ " 2015-01-01T00:00:00Z " , " 2015-12-31T23:59:59Z " ]]), [ 2 , 4 , 6 , 8 , 20 ]],
'Not marked or labelled in 2010 or 2015' => [( new Context ) -> not -> markedRanges ([[ " 2010-01-01T00:00:00Z " , " 2010-12-31T23:59:59Z " ], [ " 2015-01-01T00:00:00Z " , " 2015-12-31T23:59:59Z " ]]), [ 1 , 3 , 5 , 7 , 19 ]],
'Marked or labelled prior to 2010 or since 2015' => [( new Context ) -> markedRanges ([[ null , " 2009-12-31T23:59:59Z " ], [ " 2015-01-01T00:00:00Z " , null ]]), [ 1 , 3 , 5 , 7 , 8 , 19 ]],
'Not marked or labelled prior to 2010 or since 2015' => [( new Context ) -> not -> markedRanges ([[ null , " 2009-12-31T23:59:59Z " ], [ " 2015-01-01T00:00:00Z " , null ]]), [ 2 , 4 , 6 , 20 ]],
'Modified in 2010 or 2015' => [( new Context ) -> modifiedRanges ([[ " 2010-01-01T00:00:00Z " , " 2010-12-31T23:59:59Z " ], [ " 2015-01-01T00:00:00Z " , " 2015-12-31T23:59:59Z " ]]), [ 2 , 4 , 6 , 8 , 20 ]],
'Not modified in 2010 or 2015' => [( new Context ) -> not -> modifiedRanges ([[ " 2010-01-01T00:00:00Z " , " 2010-12-31T23:59:59Z " ], [ " 2015-01-01T00:00:00Z " , " 2015-12-31T23:59:59Z " ]]), [ 1 , 3 , 5 , 7 , 19 ]],
'Modified prior to 2010 or since 2015' => [( new Context ) -> modifiedRanges ([[ null , " 2009-12-31T23:59:59Z " ], [ " 2015-01-01T00:00:00Z " , null ]]), [ 1 , 3 , 5 , 7 , 19 ]],
'Not modified prior to 2010 or since 2015' => [( new Context ) -> not -> modifiedRanges ([[ null , " 2009-12-31T23:59:59Z " ], [ " 2015-01-01T00:00:00Z " , null ]]), [ 2 , 4 , 6 , 8 , 20 ]],
2022-04-30 03:28:47 +00:00
'Either read or hidden' => [( new UnionContext (( new Context ) -> unread ( false ), ( new Context ) -> hidden ( true ))), [ 1 , 6 , 19 ]],
2019-02-25 21:26:38 +00:00
];
2017-06-30 03:56:43 +00:00
}
2020-01-20 18:52:48 +00:00
public function testRetrieveArticleIdsForEditions () : void {
2019-02-26 16:11:42 +00:00
$exp = [
2020-03-01 20:16:50 +00:00
1 => 1 ,
2 => 2 ,
3 => 3 ,
4 => 4 ,
5 => 5 ,
6 => 6 ,
7 => 7 ,
8 => 8 ,
9 => 9 ,
10 => 10 ,
11 => 11 ,
12 => 12 ,
13 => 13 ,
14 => 14 ,
15 => 15 ,
16 => 16 ,
17 => 17 ,
18 => 18 ,
19 => 19 ,
20 => 20 ,
101 => 101 ,
102 => 102 ,
103 => 103 ,
104 => 104 ,
105 => 105 ,
202 => 102 ,
203 => 103 ,
204 => 104 ,
205 => 105 ,
305 => 105 ,
2019-02-26 16:11:42 +00:00
1001 => 20 ,
];
$this -> assertEquals ( $exp , Arsse :: $db -> editionArticle ( ... range ( 1 , 1001 )));
}
2020-01-20 18:52:48 +00:00
public function testListArticlesOfAMissingFolder () : void {
2017-07-05 14:59:13 +00:00
$this -> assertException ( " idMissing " , " Db " , " ExceptionInput " );
2017-07-17 11:47:57 +00:00
Arsse :: $db -> articleList ( $this -> user , ( new Context ) -> folder ( 1 ));
2017-07-05 14:59:13 +00:00
}
2020-01-20 18:52:48 +00:00
public function testListArticlesOfAMissingSubscription () : void {
2017-07-05 14:59:13 +00:00
$this -> assertException ( " idMissing " , " Db " , " ExceptionInput " );
2017-07-17 11:47:57 +00:00
Arsse :: $db -> articleList ( $this -> user , ( new Context ) -> subscription ( 1 ));
2017-07-05 14:59:13 +00:00
}
2020-01-20 18:52:48 +00:00
public function testListArticlesCheckingProperties () : void {
2017-06-30 03:56:43 +00:00
$this -> user = " john.doe@example.org " ;
2017-11-17 22:52:00 +00:00
// check that the different fieldset groups return the expected columns
2018-12-05 21:55:14 +00:00
foreach ( $this -> fields as $column ) {
$test = array_keys ( Arsse :: $db -> articleList ( $this -> user , ( new Context ) -> article ( 101 ), [ $column ]) -> getRow ());
$this -> assertEquals ([ $column ], $test );
2017-11-17 22:52:00 +00:00
}
2018-12-05 21:55:14 +00:00
// check that an unknown field is silently ignored
$columns = array_merge ( $this -> fields , [ " unknown_column " , " bogus_column " ]);
$test = array_keys ( Arsse :: $db -> articleList ( $this -> user , ( new Context ) -> article ( 101 ), $columns ) -> getRow ());
$this -> assertEquals ( $this -> fields , $test );
2017-06-30 03:56:43 +00:00
}
2019-04-04 21:21:23 +00:00
/** @dataProvider provideOrderedLists */
2020-01-20 18:52:48 +00:00
public function testListArticlesCheckingOrder ( array $sortCols , array $exp ) : void {
2019-04-04 21:21:23 +00:00
$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 );
}
2019-10-16 18:42:43 +00:00
public function provideOrderedLists () : iterable {
2019-04-04 21:21:23 +00:00
return [
[[ " id " ], [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 19 , 20 ]],
[[ " id asc " ], [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 19 , 20 ]],
[[ " id desc " ], [ 20 , 19 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 ]],
[[ " edition " ], [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 19 , 20 ]],
[[ " edition asc " ], [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 19 , 20 ]],
[[ " edition desc " ], [ 20 , 19 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 ]],
[[ " id " , " edition desk " ], [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 19 , 20 ]],
[[ " id " , " editio " ], [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 19 , 20 ]],
];
}
2020-01-20 18:52:48 +00:00
public function testMarkNothing () : void {
2018-12-05 01:41:21 +00:00
$this -> assertSame ( 0 , Arsse :: $db -> articleMark ( $this -> user , []));
}
2020-01-20 18:52:48 +00:00
public function testMarkAllArticlesUnread () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'read' => false ]);
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-05 13:09:38 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
2017-06-30 03:56:43 +00:00
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 2 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 11 ][ 2 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 11 ][ 4 ] = $now ;
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-06-30 03:56:43 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkAllArticlesRead () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'read' => true ]);
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-05 13:09:38 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
2017-06-30 03:56:43 +00:00
$state [ 'arsse_marks' ][ 'rows' ][ 8 ][ 2 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 8 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 10 ][ 2 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 10 ][ 4 ] = $now ;
2020-12-16 00:50:26 +00:00
$state [ 'arsse_marks' ][ 'rows' ][] = [ 13 , 5 , 1 , 0 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 13 , 6 , 1 , 0 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 14 , 7 , 1 , 0 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 14 , 8 , 1 , 0 , $now , '' , 0 ];
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-06-30 03:56:43 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkAllArticlesUnstarred () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'starred' => false ]);
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-05 13:09:38 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
2017-06-30 03:56:43 +00:00
$state [ 'arsse_marks' ][ 'rows' ][ 10 ][ 3 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 10 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 11 ][ 3 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 11 ][ 4 ] = $now ;
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-06-30 03:56:43 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkAllArticlesStarred () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'starred' => true ]);
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-05 13:09:38 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
2017-06-30 03:56:43 +00:00
$state [ 'arsse_marks' ][ 'rows' ][ 8 ][ 3 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 8 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 3 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 4 ] = $now ;
2020-12-16 00:50:26 +00:00
$state [ 'arsse_marks' ][ 'rows' ][] = [ 13 , 5 , 0 , 1 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 13 , 6 , 0 , 1 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 14 , 7 , 0 , 1 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 14 , 8 , 0 , 1 , $now , '' , 0 ];
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-06-30 03:56:43 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkAllArticlesUnreadAndUnstarred () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'read' => false , 'starred' => false ]);
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-05 13:09:38 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
2017-06-30 03:56:43 +00:00
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 2 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 10 ][ 3 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 10 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 11 ][ 2 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 11 ][ 3 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 11 ][ 4 ] = $now ;
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-06-30 03:56:43 +00:00
}
2017-06-22 17:07:56 +00:00
2020-01-20 18:52:48 +00:00
public function testMarkAllArticlesReadAndStarred () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'read' => true , 'starred' => true ]);
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-05 13:09:38 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
2017-06-30 03:56:43 +00:00
$state [ 'arsse_marks' ][ 'rows' ][ 8 ][ 2 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 8 ][ 3 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 8 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 3 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 10 ][ 2 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 10 ][ 4 ] = $now ;
2020-12-16 00:50:26 +00:00
$state [ 'arsse_marks' ][ 'rows' ][] = [ 13 , 5 , 1 , 1 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 13 , 6 , 1 , 1 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 14 , 7 , 1 , 1 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 14 , 8 , 1 , 1 , $now , '' , 0 ];
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-06-22 17:07:56 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkAllArticlesUnreadAndStarred () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'read' => false , 'starred' => true ]);
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-05 13:09:38 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
2017-06-30 17:53:19 +00:00
$state [ 'arsse_marks' ][ 'rows' ][ 8 ][ 3 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 8 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 2 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 3 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 11 ][ 2 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 11 ][ 4 ] = $now ;
2020-12-16 00:50:26 +00:00
$state [ 'arsse_marks' ][ 'rows' ][] = [ 13 , 5 , 0 , 1 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 13 , 6 , 0 , 1 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 14 , 7 , 0 , 1 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 14 , 8 , 0 , 1 , $now , '' , 0 ];
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-06-30 17:53:19 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkAllArticlesReadAndUnstarred () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'read' => true , 'starred' => false ]);
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-05 13:09:38 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
2017-06-30 17:53:19 +00:00
$state [ 'arsse_marks' ][ 'rows' ][ 8 ][ 2 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 8 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 10 ][ 2 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 10 ][ 3 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 10 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 11 ][ 3 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 11 ][ 4 ] = $now ;
2020-12-16 00:50:26 +00:00
$state [ 'arsse_marks' ][ 'rows' ][] = [ 13 , 5 , 1 , 0 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 13 , 6 , 1 , 0 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 14 , 7 , 1 , 0 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 14 , 8 , 1 , 0 , $now , '' , 0 ];
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-11-09 19:21:12 +00:00
}
2020-01-20 18:52:48 +00:00
public function testSetNoteForAllArticles () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'note' => " New note " ]);
2017-11-09 19:21:12 +00:00
$now = Date :: transform ( time (), " sql " );
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
$state [ 'arsse_marks' ][ 'rows' ][ 8 ][ 5 ] = " New note " ;
$state [ 'arsse_marks' ][ 'rows' ][ 8 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 5 ] = " New note " ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 10 ][ 5 ] = " New note " ;
$state [ 'arsse_marks' ][ 'rows' ][ 10 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 11 ][ 5 ] = " New note " ;
$state [ 'arsse_marks' ][ 'rows' ][ 11 ][ 4 ] = $now ;
2020-12-16 00:50:26 +00:00
$state [ 'arsse_marks' ][ 'rows' ][] = [ 13 , 5 , 0 , 0 , $now , 'New note' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 13 , 6 , 0 , 0 , $now , 'New note' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 14 , 7 , 0 , 0 , $now , 'New note' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 14 , 8 , 0 , 0 , $now , 'New note' , 0 ];
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-06-30 17:53:19 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkATreeFolder () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'read' => true ], ( new Context ) -> folder ( 7 ));
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-05 13:09:38 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
2020-12-16 00:50:26 +00:00
$state [ 'arsse_marks' ][ 'rows' ][] = [ 13 , 5 , 1 , 0 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 13 , 6 , 1 , 0 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 14 , 7 , 1 , 0 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 14 , 8 , 1 , 0 , $now , '' , 0 ];
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-06-30 17:53:19 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkALeafFolder () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'read' => true ], ( new Context ) -> folder ( 8 ));
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-05 13:09:38 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
2020-12-16 00:50:26 +00:00
$state [ 'arsse_marks' ][ 'rows' ][] = [ 13 , 5 , 1 , 0 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 13 , 6 , 1 , 0 , $now , '' , 0 ];
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-06-30 17:53:19 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkAMissingFolder () : void {
2017-06-30 17:53:19 +00:00
$this -> assertException ( " idMissing " , " Db " , " ExceptionInput " );
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'read' => true ], ( new Context ) -> folder ( 42 ));
2017-06-30 17:53:19 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkASubscription () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'read' => true ], ( new Context ) -> subscription ( 13 ));
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-05 13:09:38 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
2020-12-16 00:50:26 +00:00
$state [ 'arsse_marks' ][ 'rows' ][] = [ 13 , 5 , 1 , 0 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 13 , 6 , 1 , 0 , $now , '' , 0 ];
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-06-30 17:53:19 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkAMissingSubscription () : void {
2017-06-30 17:53:19 +00:00
$this -> assertException ( " idMissing " , " Db " , " ExceptionInput " );
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'read' => true ], ( new Context ) -> folder ( 2112 ));
2017-06-30 17:53:19 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkAnArticle () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'starred' => true ], ( new Context ) -> article ( 20 ));
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-05 13:09:38 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
2017-06-30 17:53:19 +00:00
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 3 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 4 ] = $now ;
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-06-30 17:53:19 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkMultipleArticles () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'starred' => true ], ( new Context ) -> articles ([ 2 , 4 , 7 , 20 ]));
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-07 02:53:17 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 3 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 4 ] = $now ;
2020-12-16 00:50:26 +00:00
$state [ 'arsse_marks' ][ 'rows' ][] = [ 14 , 7 , 0 , 1 , $now , '' , 0 ];
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-07-07 02:53:17 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkMultipleArticlessUnreadAndStarred () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'read' => false , 'starred' => true ], ( new Context ) -> articles ([ 2 , 4 , 7 , 20 ]));
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-07 02:53:17 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 2 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 3 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 11 ][ 2 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 11 ][ 4 ] = $now ;
2020-12-16 00:50:26 +00:00
$state [ 'arsse_marks' ][ 'rows' ][] = [ 14 , 7 , 0 , 1 , $now , '' , 0 ];
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-07-07 02:53:17 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkTooManyMultipleArticles () : void {
2020-03-01 23:32:01 +00:00
$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 ))));
2017-07-07 02:53:17 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkAMissingArticle () : void {
2017-07-05 14:59:13 +00:00
$this -> assertException ( " subjectMissing " , " Db " , " ExceptionInput " );
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'starred' => true ], ( new Context ) -> article ( 1 ));
2017-06-30 17:53:19 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkAnEdition () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'starred' => true ], ( new Context ) -> edition ( 1001 ));
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-05 13:09:38 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
2017-06-30 17:53:19 +00:00
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 3 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 4 ] = $now ;
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-06-30 17:53:19 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkMultipleEditions () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'starred' => true ], ( new Context ) -> editions ([ 2 , 4 , 7 , 20 ]));
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-07 02:53:17 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 3 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 4 ] = $now ;
2020-12-16 00:50:26 +00:00
$state [ 'arsse_marks' ][ 'rows' ][] = [ 14 , 7 , 0 , 1 , $now , '' , 0 ];
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-07-07 02:53:17 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkMultipleMissingEditions () : void {
2020-03-01 20:16:50 +00:00
$this -> assertSame ( 0 , Arsse :: $db -> articleMark ( $this -> user , [ 'starred' => true ], ( new Context ) -> editions ([ 500 , 501 ])));
2018-12-05 22:07:47 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2018-12-05 22:07:47 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkMultipleEditionsUnread () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'read' => false ], ( new Context ) -> editions ([ 2 , 4 , 7 , 1001 ]));
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-07 02:53:17 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 2 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 11 ][ 2 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 11 ][ 4 ] = $now ;
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-07-07 02:53:17 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkMultipleEditionsUnreadWithStale () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'read' => false ], ( new Context ) -> editions ([ 2 , 4 , 7 , 20 ]));
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-07 02:53:17 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
$state [ 'arsse_marks' ][ 'rows' ][ 11 ][ 2 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 11 ][ 4 ] = $now ;
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-07-07 02:53:17 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkMultipleEditionsUnreadAndStarredWithStale () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'read' => false , 'starred' => true ], ( new Context ) -> editions ([ 2 , 4 , 7 , 20 ]));
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-07 02:53:17 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 3 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 11 ][ 2 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 11 ][ 4 ] = $now ;
2020-12-16 00:50:26 +00:00
$state [ 'arsse_marks' ][ 'rows' ][] = [ 14 , 7 , 0 , 1 , $now , '' , 0 ];
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-07-07 02:53:17 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkTooManyMultipleEditions () : void {
2020-03-01 20:16:50 +00:00
$this -> assertSame ( 7 , Arsse :: $db -> articleMark ( $this -> user , [ 'read' => false , 'starred' => true ], ( new Context ) -> editions ( range ( 1 , 51 ))));
2017-07-07 02:53:17 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkAStaleEditionUnread () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'read' => false ], ( new Context ) -> edition ( 20 )); // no changes occur
2017-07-05 13:09:38 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-07-05 13:09:38 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkAStaleEditionStarred () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'starred' => true ], ( new Context ) -> edition ( 20 ));
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-05 13:09:38 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 3 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 4 ] = $now ;
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-07-05 13:09:38 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkAStaleEditionUnreadAndStarred () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'read' => false , 'starred' => true ], ( new Context ) -> edition ( 20 )); // only starred is changed
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-05 13:09:38 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 3 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 4 ] = $now ;
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-07-05 13:09:38 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkAStaleEditionUnreadAndUnstarred () : void {
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'read' => false , 'starred' => false ], ( new Context ) -> edition ( 20 )); // no changes occur
2017-07-05 13:09:38 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-06-30 17:53:19 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkAMissingEdition () : void {
2017-07-05 14:59:13 +00:00
$this -> assertException ( " subjectMissing " , " Db " , " ExceptionInput " );
2020-03-01 20:16:50 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'starred' => true ], ( new Context ) -> edition ( 2 ));
2017-06-30 17:53:19 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkByOldestEdition () : void {
2022-04-20 02:53:36 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'starred' => true ], ( new Context ) -> editionRange ( 19 , null ));
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-05 13:09:38 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
$state [ 'arsse_marks' ][ 'rows' ][ 8 ][ 3 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 8 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 3 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 4 ] = $now ;
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-07-05 13:09:38 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkByLatestEdition () : void {
2022-04-20 02:53:36 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'starred' => true ], ( new Context ) -> editionRange ( null , 20 ));
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-05 13:09:38 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
$state [ 'arsse_marks' ][ 'rows' ][ 8 ][ 3 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 8 ][ 4 ] = $now ;
2020-12-16 00:50:26 +00:00
$state [ 'arsse_marks' ][ 'rows' ][] = [ 13 , 5 , 0 , 1 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 13 , 6 , 0 , 1 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 14 , 7 , 0 , 1 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 14 , 8 , 0 , 1 , $now , '' , 0 ];
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-07-05 13:09:38 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkByLastMarked () : void {
2022-04-20 00:19:51 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'starred' => true ], ( new Context ) -> markedRange ( '2017-01-01T00:00:00Z' , null ));
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-05 13:09:38 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
$state [ 'arsse_marks' ][ 'rows' ][ 8 ][ 3 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 8 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 3 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 9 ][ 4 ] = $now ;
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-07-05 13:09:38 +00:00
}
2020-01-20 18:52:48 +00:00
public function testMarkByNotLastMarked () : void {
2022-04-20 00:19:51 +00:00
Arsse :: $db -> articleMark ( $this -> user , [ 'starred' => true ], ( new Context ) -> markedRange ( null , '2000-01-01T00:00:00Z' ));
2017-07-17 11:47:57 +00:00
$now = Date :: transform ( time (), " sql " );
2017-07-05 13:09:38 +00:00
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
2020-12-16 00:50:26 +00:00
$state [ 'arsse_marks' ][ 'rows' ][] = [ 13 , 5 , 0 , 1 , $now , '' , 0 ];
$state [ 'arsse_marks' ][ 'rows' ][] = [ 14 , 7 , 0 , 1 , $now , '' , 0 ];
2019-06-21 22:52:27 +00:00
$this -> compareExpectations ( static :: $drv , $state );
2017-06-22 17:07:56 +00:00
}
2017-07-05 14:59:13 +00:00
2020-01-20 18:52:48 +00:00
public function testCountArticles () : void {
2020-03-01 23:32:01 +00:00
$setSize = ( new \ReflectionClassConstant ( Database :: class , " LIMIT_SET_SIZE " )) -> getValue ();
2017-10-07 00:26:22 +00:00
$this -> assertSame ( 2 , Arsse :: $db -> articleCount ( " john.doe@example.com " , ( new Context ) -> starred ( true )));
2017-10-11 16:55:50 +00:00
$this -> assertSame ( 4 , Arsse :: $db -> articleCount ( " john.doe@example.com " , ( new Context ) -> folder ( 1 )));
2020-12-17 23:12:52 +00:00
$this -> assertSame ( 1 , Arsse :: $db -> articleCount ( " jane.doe@example.com " , ( new Context ) -> starred ( true )));
2020-03-01 23:32:01 +00:00
$this -> assertSame ( 10 , Arsse :: $db -> articleCount ( " john.doe@example.com " , ( new Context ) -> articles ( range ( 1 , $setSize * 3 ))));
2017-07-05 14:59:13 +00:00
}
2020-01-20 18:52:48 +00:00
public function testFetchStarredCounts () : void {
2017-10-11 16:55:50 +00:00
$exp1 = [ 'total' => 2 , 'unread' => 1 , 'read' => 1 ];
$exp2 = [ 'total' => 0 , 'unread' => 0 , 'read' => 0 ];
2017-12-20 00:08:08 +00:00
$this -> assertEquals ( $exp1 , Arsse :: $db -> articleStarred ( " john.doe@example.com " ));
$this -> assertEquals ( $exp2 , Arsse :: $db -> articleStarred ( " jane.doe@example.com " ));
2017-10-11 16:55:50 +00:00
}
2020-01-20 18:52:48 +00:00
public function testFetchLatestEdition () : void {
2017-07-17 11:47:57 +00:00
$this -> assertSame ( 1001 , Arsse :: $db -> editionLatest ( $this -> user ));
$this -> assertSame ( 4 , Arsse :: $db -> editionLatest ( $this -> user , ( new Context ) -> subscription ( 12 )));
2020-12-20 22:34:32 +00:00
$this -> assertSame ( 5 , Arsse :: $db -> editionLatest ( " john.doe@example.com " , ( new Context ) -> subscription ( 3 ) -> hidden ( false )));
2017-07-05 14:59:13 +00:00
}
2020-01-20 18:52:48 +00:00
public function testFetchLatestEditionOfMissingSubscription () : void {
2017-07-05 14:59:13 +00:00
$this -> assertException ( " idMissing " , " Db " , " ExceptionInput " );
2017-07-17 11:47:57 +00:00
Arsse :: $db -> editionLatest ( $this -> user , ( new Context ) -> subscription ( 1 ));
2017-07-05 14:59:13 +00:00
}
2020-01-20 18:52:48 +00:00
public function testListTheLabelsOfAnArticle () : void {
2018-12-05 14:05:43 +00:00
$this -> assertEquals ([ 1 , 2 ], Arsse :: $db -> articleLabelsGet ( " john.doe@example.com " , 1 ));
2017-10-13 21:05:06 +00:00
$this -> assertEquals ([ 2 ], Arsse :: $db -> articleLabelsGet ( " john.doe@example.com " , 5 ));
$this -> assertEquals ([], Arsse :: $db -> articleLabelsGet ( " john.doe@example.com " , 2 ));
$this -> assertEquals ([ " Fascinating " , " Interesting " ], Arsse :: $db -> articleLabelsGet ( " john.doe@example.com " , 1 , true ));
$this -> assertEquals ([ " Fascinating " ], Arsse :: $db -> articleLabelsGet ( " john.doe@example.com " , 5 , true ));
$this -> assertEquals ([], Arsse :: $db -> articleLabelsGet ( " john.doe@example.com " , 2 , true ));
}
2020-01-20 18:52:48 +00:00
public function testListTheLabelsOfAMissingArticle () : void {
2017-11-21 14:22:58 +00:00
$this -> assertException ( " subjectMissing " , " Db " , " ExceptionInput " );
Arsse :: $db -> articleLabelsGet ( $this -> user , 101 );
}
2020-01-20 18:52:48 +00:00
public function testListTheCategoriesOfAnArticle () : void {
2017-11-21 14:22:58 +00:00
$exp = [ " Fascinating " , " Logical " ];
$this -> assertSame ( $exp , Arsse :: $db -> articleCategoriesGet ( $this -> user , 19 ));
$exp = [ " Interesting " , " Logical " ];
$this -> assertSame ( $exp , Arsse :: $db -> articleCategoriesGet ( $this -> user , 20 ));
$exp = [];
$this -> assertSame ( $exp , Arsse :: $db -> articleCategoriesGet ( $this -> user , 4 ));
}
2020-01-20 18:52:48 +00:00
public function testListTheCategoriesOfAMissingArticle () : void {
2017-11-21 14:22:58 +00:00
$this -> assertException ( " subjectMissing " , " Db " , " ExceptionInput " );
Arsse :: $db -> articleCategoriesGet ( $this -> user , 101 );
}
2019-04-02 22:37:46 +00:00
/** @dataProvider provideArrayContextOptions */
2020-01-20 18:52:48 +00:00
public function testUseTooFewValuesInArrayContext ( string $option ) : void {
2019-02-22 23:50:39 +00:00
$this -> assertException ( " tooShort " , " Db " , " ExceptionInput " );
2019-04-04 21:21:23 +00:00
Arsse :: $db -> articleList ( $this -> user , ( new Context ) -> $option ([]));
2019-02-22 23:50:39 +00:00
}
2019-10-16 18:42:43 +00:00
public function provideArrayContextOptions () : iterable {
2019-04-05 15:03:15 +00:00
foreach ([
" articles " , " editions " ,
2022-04-25 18:33:19 +00:00
" subscriptions " , " foldersShallow " , " folders " ,
2019-04-02 22:37:46 +00:00
" tags " , " tagNames " , " labels " , " labelNames " ,
" searchTerms " , " authorTerms " , " annotationTerms " ,
2022-04-25 18:33:19 +00:00
" modifiedRanges " , " markedRanges " ,
2019-04-02 22:37:46 +00:00
] as $method ) {
yield [ $method ];
}
2019-02-24 01:14:52 +00:00
}
2020-12-19 15:59:40 +00:00
public function testMarkAllArticlesNotHidden () : void {
Arsse :: $db -> articleMark ( " jane.doe@example.com " , [ 'hidden' => false ]);
$now = Date :: transform ( time (), " sql " );
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
$state [ 'arsse_marks' ][ 'rows' ][ 14 ][ 6 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 14 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 15 ][ 6 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 15 ][ 4 ] = $now ;
$this -> compareExpectations ( static :: $drv , $state );
}
public function testMarkAllArticlesHidden () : void {
Arsse :: $db -> articleMark ( " jane.doe@example.com " , [ 'hidden' => true ]);
$now = Date :: transform ( time (), " sql " );
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
$state [ 'arsse_marks' ][ 'rows' ][ 3 ][ 6 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 3 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][] = [ 7 , 19 , 0 , 0 , $now , '' , 1 ];
$this -> compareExpectations ( static :: $drv , $state );
}
public function testMarkAllArticlesUnreadAndNotHidden () : void {
Arsse :: $db -> articleMark ( " jane.doe@example.com " , [ 'read' => false , 'hidden' => false ]);
$now = Date :: transform ( time (), " sql " );
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
$state [ 'arsse_marks' ][ 'rows' ][ 3 ][ 2 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 3 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 14 ][ 6 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 14 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 15 ][ 2 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 15 ][ 6 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 15 ][ 4 ] = $now ;
$this -> compareExpectations ( static :: $drv , $state );
}
public function testMarkAllArticlesReadAndHidden () : void {
Arsse :: $db -> articleMark ( " jane.doe@example.com " , [ 'read' => true , 'hidden' => true ]);
$now = Date :: transform ( time (), " sql " );
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
$state [ 'arsse_marks' ][ 'rows' ][ 3 ][ 6 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 3 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 14 ][ 2 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 14 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][] = [ 7 , 19 , 1 , 0 , $now , '' , 1 ];
$this -> compareExpectations ( static :: $drv , $state );
}
public function testMarkAllArticlesUnreadAndHidden () : void {
Arsse :: $db -> articleMark ( " jane.doe@example.com " , [ 'read' => false , 'hidden' => true ]);
$now = Date :: transform ( time (), " sql " );
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
$state [ 'arsse_marks' ][ 'rows' ][ 3 ][ 2 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 3 ][ 6 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 3 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 15 ][ 2 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 15 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][] = [ 7 , 19 , 0 , 0 , $now , '' , 1 ];
$this -> compareExpectations ( static :: $drv , $state );
}
public function testMarkAllArticlesReadAndNotHidden () : void {
Arsse :: $db -> articleMark ( " jane.doe@example.com " , [ 'read' => true , 'hidden' => false ]);
$now = Date :: transform ( time (), " sql " );
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
$state [ 'arsse_marks' ][ 'rows' ][ 14 ][ 2 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 14 ][ 6 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 14 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 15 ][ 6 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 15 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][] = [ 7 , 19 , 1 , 0 , $now , '' , 0 ];
$this -> compareExpectations ( static :: $drv , $state );
}
public function testMarkMultipleEditionsUnreadAndHiddenWithStale () : void {
Arsse :: $db -> articleMark ( " jane.doe@example.com " , [ 'read' => false , 'hidden' => true ], ( new Context ) -> editions ([ 1 , 2 , 19 , 20 ]));
$now = Date :: transform ( time (), " sql " );
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
$state [ 'arsse_marks' ][ 'rows' ][ 3 ][ 6 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 3 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][ 15 ][ 2 ] = 0 ;
$state [ 'arsse_marks' ][ 'rows' ][ 15 ][ 6 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 15 ][ 4 ] = $now ;
$state [ 'arsse_marks' ][ 'rows' ][] = [ 7 , 19 , 0 , 0 , $now , '' , 1 ];
$this -> compareExpectations ( static :: $drv , $state );
}
public function testMarkAStaleEditionHidden () : void {
Arsse :: $db -> articleMark ( " jane.doe@example.com " , [ 'hidden' => true ], ( new Context ) -> edition ( 20 ));
$now = Date :: transform ( time (), " sql " );
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
$state [ 'arsse_marks' ][ 'rows' ][ 3 ][ 6 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 3 ][ 4 ] = $now ;
$this -> compareExpectations ( static :: $drv , $state );
}
public function testMarkAStaleEditionUnreadAndHidden () : void {
Arsse :: $db -> articleMark ( " jane.doe@example.com " , [ 'read' => false , 'hidden' => true ], ( new Context ) -> edition ( 20 )); // only starred is changed
$now = Date :: transform ( time (), " sql " );
$state = $this -> primeExpectations ( $this -> data , $this -> checkTables );
$state [ 'arsse_marks' ][ 'rows' ][ 3 ][ 6 ] = 1 ;
$state [ 'arsse_marks' ][ 'rows' ][ 3 ][ 4 ] = $now ;
$this -> compareExpectations ( static :: $drv , $state );
}
public function testMarkAStaleEditionUnreadAndNotHidden () : void {
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 );
$this -> compareExpectations ( static :: $drv , $state );
}
2021-01-16 22:58:31 +00:00
public function testSelectScrapedContent () : void {
$exp = [
[ 'id' => 101 , 'content' => " <p>Article content 1</p> " ],
[ 'id' => 102 , 'content' => " <p>Article content 2</p> " ],
];
$this -> assertResult ( $exp , Arsse :: $db -> articleList ( " john.doe@example.org " , ( new Context ) -> subscription ( 8 ), [ " id " , " content " ]));
$exp = [
[ 'id' => 101 , 'content' => " <p>Scraped content 1</p> " ],
[ 'id' => 102 , 'content' => " <p>Article content 2</p> " ],
];
$this -> assertResult ( $exp , Arsse :: $db -> articleList ( " jill.doe@example.com " , ( new Context ) -> subscription ( 15 ), [ " id " , " content " ]));
}
public function testSearchScrapedContent () : void {
$exp = [
[ 'id' => 101 , 'content' => " <p>Scraped content 1</p> " ],
[ 'id' => 102 , 'content' => " <p>Article content 2</p> " ],
];
$this -> assertResult ( $exp , Arsse :: $db -> articleList ( " jill.doe@example.com " , ( new Context ) -> subscription ( 15 ) -> searchTerms ([ " article " ]), [ " id " , " content " ]));
$exp = [
[ 'id' => 101 , 'content' => " <p>Scraped content 1</p> " ],
];
$this -> assertResult ( $exp , Arsse :: $db -> articleList ( " jill.doe@example.com " , ( new Context ) -> subscription ( 15 ) -> searchTerms ([ " scraped " ]), [ " id " , " content " ]));
}
2020-12-22 21:13:12 +00:00
}