Commit graph

184 commits

Author SHA1 Message Date
c51ee594aa Last of the article series of tests 2017-07-05 10:59:13 -04:00
d78318bed7 Last of marking context tests 2017-07-05 09:09:38 -04:00
5742d949cc More article marking tests, some context tests
Various fixes as a result
2017-06-30 13:53:19 -04:00
c2f60bc5d2 More article tests
- Test the values returned by articleList
- Test paged and reversed listing
- Test marking, un/read, un/starred, and both
- Nearly complete rewrite of marking queries; previous efforts simply did not work, or overzealously updated or inserted
- Testing of marking contexts still required
2017-06-29 23:56:43 -04:00
ee9d8c1ceb First tests for articleList
Fixed many errors in queries:
- Prepared statement wasn't running at all :)
- Returning feed ID rather than subscription ID
- latestEdition wasn't matching
2017-06-22 13:07:56 -04:00
7e458dddbc More test re-organization 2017-06-18 12:48:29 -04:00
845b47e656 Re-organize test data for Database tests 2017-06-18 12:24:19 -04:00
483874e21d Implemented query contexts
- Fixes #55
- Included test for Context
- Adjusted Database::editionLatest() to use Context
- Adjusted NCN handler and tests accordingly
- Also refined experimental Database::articleList() method and added experimental Database::articlePropertiesSet() method
2017-06-18 10:23:37 -04:00
c37d476ba0 Changes to Database internals
- Driver->prepare() can now take a new Database\Query object as the first parameter
- The Query class allows for building a complex query out of a main body, common table expressions, WHERE coniditions, ordering conditions, a limit, and offset
- The subscriptionList method is the prototypical example of usage
- The experimental articleList method will in time be adapted to use this as well
- A generic means of specifying a selection context is forthcoming; this would remove subscriptionList's $folder and $id parameters, for instance
2017-06-04 18:00:18 -04:00
2332cd52a3 Cleanup 2017-06-04 08:15:10 -04:00
dd24246f49 Finished last of feedUpdate tests; implemented NCN API functions
- Fixes #26
- Fixes #27
2017-06-03 17:34:37 -04:00
0514321a76 Save enclosures and categories properly in feedUpdate 2017-06-03 14:08:33 -04:00
0ab6210214 Fix feed ID discovery so it doesn't short-circuit the item loop 2017-06-03 13:43:58 -04:00
ba61ca2b2c Add category list to feed items 2017-06-03 11:16:26 -04:00
140d608f0f Split feed fetching tests from feed parsing tests
Lack of curl should not skip all Feed tests, just those that require curl to be reliable.
2017-06-03 09:06:30 -04:00
c6b7e653c5 Tests for feedUpdate and feedListStale
The update process neglects to handle enclosures; this will have to be fixed
2017-06-02 19:16:36 -04:00
78e669fbfc Improvements to database test harness 2017-06-02 14:12:36 -04:00
81419452b5 Added topmost folder to output of subscriptionList. Fixes #54
- Adjusted NCN handler to use the topmost folder for folderId; suppressed the actual folder so as not to pollute output with non-standard data
- Updated tests
2017-06-01 18:12:08 -04:00
719290c82a Remove dependency on Webmozart's Glob outside of testing
Native glob is effectively tested via use of unmodified Lang throughout non-Lang tests
2017-06-01 13:50:46 -04:00
b778e8eacd Fix failing test 2017-05-30 20:55:29 -04:00
5b8f23441c Feed tests: article matching
These should be the last required tests for the Feed class
2017-05-30 20:18:04 -04:00
3e5343e3e8 Feed tests: last set of next-fetch tests, with fixes 2017-05-27 23:14:43 -04:00
7656de716b Feed tests: fetching and parsing 2017-05-27 18:15:52 -04:00
ff59f00356 Feed tests: deduplication 2017-05-26 17:55:51 -04:00
c800852f3a Remove stubs to support non-HTTP authentication
Also removes authPreferHTTP setting
2017-05-26 13:06:06 -04:00
6771e8916a Fixed more Feed bugs
- Two items with differing IDs but identical hashes were matching in the deduplicator; they shouldn't
- They would also match in the database matcher, and shouldn't
- The second-pass database matcher was overaggressively finding items as new
2017-05-23 22:15:57 -04:00
fd7d1c3192 Fixes to Feed class for bugs uncovered by initial deduplication tests
Three bugs:
- The parser wrapping was generating hashes for fallback values in absence of actual values for both URL and title (which is valid if obscure RSS), URL and content, or title and content; now fallback values are detected and empty strings used instead of hashes
- The deduplicator was assuming all three hashes would always exist, which is no longer the case
- The database matcher was making the same assumption as the deduplicator
2017-05-23 20:39:29 -04:00
148875c0dd Last cache-handling Feed test 2017-05-22 17:06:01 -04:00
ed3e3c12d6 More Feed tests: more cache header handling 2017-05-22 13:01:38 -04:00
ceeb23aea3 More Feed tests: cache header handling
- Also made all SQLite tests skippable if the extension is not loaded
- Fixed format of ETags in test server
- Passed any CLI arguments to PHPUnit in the test runner
2017-05-22 10:02:36 -04:00
f04ba956a9 Tweaks to Feed tests
- Ensure Web server is up before running tests (skip otherwise)
- Place expected timestamps closer to assertions, to lessen chances of off-by-one failures
2017-05-21 23:26:36 -04:00
757f2af343 More Linux/macOS fixes
- avoid iconv for now; causes problems with a nil-config server
- Set executable bit on Unix test runner
2017-05-21 22:20:21 -04:00
adfb22e922 macOS fixes 2017-05-21 21:49:54 -04:00
97a8f473a7 More Feed tests; Linux fixes
- Adjusted some namespace case
- Included Linux test runner; should also work with macOS
- Made the PHP server run in the background on Windows
2017-05-21 19:51:03 -04:00
590abaf0ef Start on tests for Feed
- Makes use of PHP's internal Web server to deliver expected responses from a real server
- Windows batch file can be used to run tests (Linux and Mac test runners to come later)
- Added PHPUnit to dev dependencies
2017-05-21 17:16:32 -04:00
88c0f4986c Implement NCN API v1-2 feed handling: tests
- Fixes #8
- Fixes #9
- Fixes #10
- Fixes #11
- Fixes #12

- Differentiated between a missing ID which is the subject of an action (e.g. the subscription when moving a subscription) and other missing IDs (e.g. the folder when moving a subscription)
- Enforced same rules for subscription titles as for folder names, save that null is valid for subscriptions
2017-05-21 10:10:36 -04:00
0972cff660 Completely revamped NCNv1 REST handler
- URLs are now matched centrally against a whitelist
- %-encoded URLs are still handled correctly
- Dispatched methods now only handle one specific task
- Filler methods (e.g. versionPOST) are no longer required
- Unhandled URLs now return 501 Not Implemented rather than 404 Not Found; this removes some ambiguity in the semantics of 404
2017-05-19 23:52:26 -04:00
4a816f827b NCNv1 feed calls and other changes
- Implemented all but one feed-related function (it's more ofan item function)
- Fixed time conversion for input into SQL; dates in PM were previously wrong
- Added miscellaneous tentative functions to Database to help with peculiarities of NCNv1; these may change
- Tests to come soon
2017-05-18 23:03:33 -04:00
0bc2841837 Last of subscription tests
- Also tweaked SQL dateformat() function to output proper HTTP dates
- Also introduced method to set a default output date format
2017-05-18 13:21:17 -04:00
99ae274ef8 Also test negative read marks 2017-05-16 22:24:36 -04:00
ef3cb4fa54 Test unread counts in subscriptionList 2017-05-16 22:19:40 -04:00
f635155687 Basic tests for subscription list
- Need entries and read marks to fully test
- Added assertion type to test result subsets
- Fixed custom subscription titles
2017-05-14 23:03:48 -04:00
acbb254bfb Tests for removing subscriptions 2017-05-11 23:20:10 -04:00
98c950de58 Removed most calls to userExists()
- functions not related to user management now have the existence of the affected user checked in the authorizer, when the affected user differs from the actor
- User::authorizationEnabled() now nests: disabling twice and then enabling once leaves the authorizer disabled
- Disabling of the authorizer is now tested
- User tests now use a partial mock instead of relying on User::authorizationEnabled()
- Added authorizer tests against a missing user
- Removed folder tests related to missing users
- Also added more subscription tests
2017-05-11 18:00:35 -04:00
a580579627 First set of Database subscription tests 2017-05-10 22:01:00 -04:00
554beacfdb Improved database tests
- Centralized initial state; this will be useful due to foreign key interdependence
- Added nextID() method to make insert tests less brittle
2017-05-10 21:21:23 -04:00
8ebcb01cb5 Made out-of-order transaction handling more predictable 2017-05-07 18:27:16 -04:00
2083c6e397 Change transactions to auto-rollback on exceptions 2017-05-06 12:02:27 -04:00
fb922e65e4 Tests for strict binding 2017-05-04 19:38:54 -04:00
db132c0c24 Various changes to Database
- Introduced "strict" binding types for use when inserting into NOT NULL columns: any null value supplied is always cast to the supplied type rather than passing through
- Fixed feed updating further
- Filled out full complement of subscription manipulation functions
- made folderPropertiesSet possibly return false
2017-05-04 19:12:33 -04:00
9c7f4710aa Fix feed fetching
There are almost certainly other bugs; proper tests forthcoming
2017-05-04 14:42:40 -04:00
717e74fb2e Refactored special case for testing 2017-05-03 20:00:29 -04:00
557d17ef5d Add rollbacks in error cases 2017-04-09 18:15:00 -04:00
a67fe30408 Fix whitespace
Also fixed my editor so tabs won't happen again!
2017-04-06 21:41:21 -04:00
b02abec250 Added test for recursive binding
Also fixed a bug uncovered by the test
2017-04-06 21:24:26 -04:00
74ae1106a4 Implement NCN API v1-2 server version reporting
- Fixes #29
- Yes, it's trivial, but now it's done!
2017-04-02 21:49:37 -04:00
9cbfa378bc Implement NCN API v1-2 folder deleting/renaming
- Fixes #5
- Fixes #6
- Rewrote the NCNv1 dispatcher to better handle URL edge cases
2017-04-02 21:34:30 -04:00
19abce85c3 Implement NCN API v1-2 folder creation
- Fixes #4
- Tests for failure modes still required
2017-04-02 12:14:15 -04:00
842e277d43 Implemented NCN API v1-2 folder list
- Fixes #2
- Also re-organized REST handling
2017-04-01 23:06:52 -04:00
718c5a04dd Add authz verification to folder tests 2017-04-01 15:06:34 -04:00
1e1b848c62 Remove root field from folders table
The field is no longer required with the use of recursive common table expressions, and  presents a possible loss of referential integrity
2017-04-01 14:49:31 -04:00
a111bcc231 Folder get/set prop funcs and other changes
- Simplified folder removal; now properly relies on foreign keys for dependency resolution
- simplified *propertiesSet() methods by offloading input validation and query building to a generic function
- Implemented function to get the properties of a single folder (useful for internal use)
- Implemented a function to set the properties of a folder
2017-04-01 10:27:26 -04:00
2344911f78 Tests for removing folders 2017-03-31 18:48:24 -04:00
458eaac5c6 Tests for listing folders
- Fixed checking for existence of parent before listing
- Changed Result->getAll() to return an empty array rather than null for an empty result set
2017-03-31 17:42:28 -04:00
b68cea1188 Tests for adding folders 2017-03-31 15:27:59 -04:00
82e4838162 Re-organize Database tests
- Test files now consist entirely of traits:
 - General setup trait mocking User class and cleaning up
 - Driver trait to set up the database connection
 - Series trait containing tests for the series, independent of driver used
2017-03-31 13:24:00 -04:00
dbd735f1f3 Full set of tests for user-related Database funcs
- Fixed a few inconsistencies and bugs along the way
- User manager tests need some equivalent fleshing out
2017-03-29 23:41:05 -04:00
6b2be0a877 Use Phake to create mock objects in tests 2017-03-28 20:30:40 -04:00
6bb129db2f Mock correct method of Lang 2017-03-28 19:58:20 -04:00
f902346b6c Eliminated passing of RuntimeData instances
- RuntimeData has now been replaced by a single static Data class
- The Data class has a load() method which fills the same role as the constructor of RuntimeData
- The static Lang class is now an instantiable class and is a member of Data
- All tests have been adjusted and pass
- The Exception tests no longer require convoluted workarounds: a simple mock  for Data::$l suffices; Lang tests also use a mock to prevent loops now instead of using a workaround
2017-03-28 18:50:00 -04:00
2b8aa75ee3 Row index is not a string 2017-03-28 10:31:49 -04:00
7236020b8b Changed "NewsSync" to "Arsse" 2017-03-27 23:12:12 -05:00
9d5dab249c Helper methods for testing Database class
May not actually work yet
2017-03-27 23:19:05 -04:00
8b50297e6d Complete tests for NCN version list
- Fixes #47
- Implemented an AbstractHandler class with a generic URL parser
2017-03-24 13:16:34 -04:00
25d9158171 Fix output of NCN version list
List is supposed to be contained in a JSON object, not a bare list
2017-03-19 21:54:28 -04:00
536fa5c4fd Implement NextCloud News version detection
- Improves #47
- Still needs wrapping to actually output to clients
2017-03-19 21:50:00 -04:00
20abd277eb Don't muck with test file for now 2017-03-18 22:32:16 -04:00
9a8def03c2 Fill in more of the REST handler.
Not yet functional.
2017-03-18 22:30:36 -04:00
8c268581fb Properly handle adding a folder
Also added test file for now
2017-03-09 22:41:11 -05:00
18c8076a0f Database update tests 2017-03-09 21:39:42 -05:00
6c16ba133c More database driver tests 2017-03-09 17:25:50 -05:00
689c1c77d0 Test for advisory locking 2017-03-09 17:14:26 -05:00
f0663e99c3 Add tests for transactions and savepoints
Existing code had subtle bugs; using increment and decrement operators actually makes things easier to understand (for once)
2017-03-09 16:36:33 -05:00
485400df2b Rename Result->get() to Result->getRow
It should be slightly clearer what it does
2017-03-09 15:01:18 -05:00
bdf3182305 Add result->lastId method; cleanup
- Result->lastId() added as MySQL and PostgreSQL have equivalent functionality
- Adjusted tests accordingly
- Cleaned up Database class to make use of this and getAll()
2017-03-09 14:48:42 -05:00
f0adf08b1e Add tests for type mismatches 2017-03-09 09:44:50 -05:00
95ee51563d First battery of SQLite driver tests 2017-03-08 22:16:35 -05:00
7f7d0cd1e7 All test for constraint violation exception 2017-03-08 13:59:20 -05:00
7687109132 Reorganize Db namespace; alter User ns to match 2017-03-07 18:01:13 -05:00
37dad63dee Impelemented Result->getAll()
- Fixes #45
- Renamed getSingle to getValue to avoid possible confusion
- Added test to ensure getValue() always returns the first datum of each row rather than going column-to-column
2017-03-06 16:34:38 -05:00
eeb1818bb5 Still more database changes
- Restructured tests
- Localized driver name for SQLite driver (fixes #37)
- Ensured that binding type definitions are required
2017-03-03 13:20:26 -05:00
007e3747ef Various database fixes
Authentication appears to be broken with a real database
2017-03-02 20:47:00 -05:00
0c410fcf50 More binding tests and related changes
- Introduced abstract Statement class to hold common methods
- Common methods currently consist of a date formatter and type caster
- Moved binding tests to a trait for reuse with future drivers
2017-03-02 18:42:19 -05:00
1529fc367a Partial proper tests for parameter bindings
Null and (>0) integer tested so far

Many related changes to accomodate the necessary type juggling (required for databases other than SQLite).
2017-03-02 14:19:16 -05:00
f19f683e38 Make it possible to redefine Statement type binds 2017-03-01 23:12:42 -05:00
b4d178c33f Remove most PDO stuff
PDO will not be supported: the feature-set is less than any of the common native APIs, so why bother?
2017-03-01 22:47:51 -05:00
176247894d Tests for Db\ResultSQLite3 2017-03-01 19:00:14 -05:00
34c69fbf92 Be explicit about the loaded locale 2017-03-01 12:13:38 -05:00
104f646973 Code comments 2017-03-01 08:38:44 -05:00
13c17f5dd4 Small fixes to authorization exception tests 2017-02-28 14:04:14 -05:00