8000 Add get + set for `$apiBase` to increase testability · Issue #27 · ConvertAPI/convertapi-library-php · GitHub
[go: up one dir, main page]

Skip to content

Add get + set for $apiBase to increase testability #27

@DanielGSoftware

Description

@DanielGSoftware

We're currently integrating the ConvertAPI into our project. When writing a unit test, we tried to mock the ConvertApi class. This works fine to a certain extend. In a piece of code we have the following:

ConvertApi::$apiBase = 'eu-v2.convertapi.com';

We use PhpUnit and Mockery to write tests, and currently mocking static properties is not supported. After some experimenting, we found the best solution would be to add a setter (like setApiSecret) so that we can finish our unit test. I think other people can also benefit from this, as it's not possible to write a unit test if you set a custom apiBase.

Thoughts about this? I can open a PR if there's interest in this.
PR here: #28

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0