nextcloud / nextcloud/documentation
Docuemnt access to Dependency injection for Tests
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 628
- Forks
- 2.5k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 135
Description
Before You Submit
- I have checked for existing issues and pull requests related to my suggestion.
- I have posted on the Nextcloud Community Help Forum if my suggestion is a troubleshooting scenario or I'm unsure about the solution.
Type of Suggestion
Proposing new documentation content
Relevant Documentation Links
https://docs.nextcloud.com/server/latest/developer_manual/basics/testing.html#php
Summary
Explicitly state how to realize dependency injection for unit and integration tests
Details
The DI framework in NC is nice and works out of the box without manual configuration by the app devs. However, when testing classes using PHPUnit, the DI framework is not available. That is okay for simple unit tests that only rely on a few classes that can be mocked/stubbed.
However, once integration tests should be carried out or larger class structures should be addresses, the DI is very handy. In the example, there is a way presented to get the app container from the application class. I would like to see this more verbose and more present.
Additional Notes
I might write this myself. Here just to keep track...
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
Start with the PHP section of the linked developer testing documentation and review its existing application-container example. Expand the guidance to explain dependency injection for PHPUnit unit and integration tests, with enough detail for larger class structures; done means the workflow is explicit and usable without relying on unstated project knowledge.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- documentation, testing
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- Half a day
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100