Skip to content

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

Closed

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

Activity

  1. changed the title [-]Add setter for $apiBase to support for better testibility[/-] [+]Add get + setsetter for $apiBase to support for better testibility[/+] on Mar 31, 2022
  2. changed the title [-]Add get + setsetter for $apiBase to support for better testibility[/-] [+]Add get + set for `$apiBase` to increase testability[/+] on Mar 31, 2022
  3. DanielGSoftware commented on Apr 21, 2022

    @DanielGSoftware
    ContributorAuthor

    Any update on this?

  4. laurynas-convertapi commented on Jun 26, 2022

    @laurynas-convertapi
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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