Improve tests for SyncService
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1k
- Forks
- 348
- Avg merge
- 12h 28m
- Merged PRs (30d)
- 91
Description
Follow up https://github.com/nextcloud/mail/pull/12548
The sync() expectation is matching against fresh stubs created inline for the IMAP client and logger. SyncService is very likely to pass the exact instances it uses internally (client from the factory, logger from the constructor), so these should be captured into variables/properties and reused in with(...) (or replaced with looser constraints) to avoid brittle, failing argument matching.
syncStats() is asserted with a newly created IMAP client stub. This will not be the same instance as the client returned by the factory in this test, so the expectation is likely to fail. Reuse the same $client stub (or use a type/constraint matcher) for both the factory return and the syncStats() expectation.
In this test you create a new IMAP client stub inline in the willReturn(...) call, but later the expectations use different stubs for the IMAP client argument. If SyncService::syncMailbox() passes the client returned by IMAPClientFactory::getClient() through, these argument comparisons will not match and the test will fail. Assign the client stub to a variable (or use a constraint like isInstanceOf) and reuse it consistently across all expectations.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open tests/Unit/Service/Sync/SyncServiceTest.php around lines 96, 105, and 114, then inspect how the IMAP client factory and SyncService are set up. Reuse the same client and logger stubs across the expectations, or apply the stated constraints, and run the SyncService unit test to confirm the argument matching works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- testing-qa
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100