Skip to content

Docuemnt access to Dependency injection for Tests #15296

Description

@christianlupus

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...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions