Improve tests for SyncService
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- php
- Domain
- testing-qa
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.
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.
- Dominant language
- JavaScript
- Stars
- 1k
- Forks
- 348
- Avg merge
- 14h 51m
- Merged PRs (30d)
- 85
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.
More from nextcloud/mail
-
0. to triage enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
1. to develop bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
0. to triage bug
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
0. to triage enhancement
Difficulty 3/5 1-2 days Newbie friendliness 72/100
-
0. to triage bug
Difficulty 3/5 1-2 days Newbie friendliness 76/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·
-
client-controller-update ta-bot-triage team-money-movement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
MetaMask/metamask-mobile#36594 ·