DeepLcom / deepl-php

Official PHP library for the DeepL language translation API.
MIT License
202 stars 23 forks source link

Problems with "final class Translator in phpunit integration Tests #1

Closed VimS closed 2 years ago

VimS commented 2 years ago

Hey, at the moment I try to replace https://github.com/Baby-Markt/deepl-php-lib with your Library. Everything went relatively smooth but I ran into an Issues when it comes to user the Library in integration Tests. Since I am not able to start an API-Mock-Server during our Tests, I want to Mock your Translator class and to manipulate the return value of for example the translateText-Method. At the moment this is not possible because the Translator-Class is final and phpunit uses Class-Extension to create Mockclasses. I tried Mockery but since we use type hinting this fails too.

Is it possible for you to Change the definition or do you have an other suggestion for this Problem?

daniel-jones-deepl commented 2 years ago

Hi Sebastian,

First of all, I want to say thanks to you and your team for developing https://github.com/Baby-Markt/deepl-php-lib and supporting DeepL API users!

Great to hear the transition went relatively smoothly, and thank you for the feedback. We've removed the final keyword to support your use-case in v0.2.0, but be aware we will add new functions to the Translator class soon, for example to support document translation and glossary management. There is also the possibility to add an interface for the HTTP client, similar to your library, but that would require more work.

If you have more feedback about the library or DeepL API in general, I'd be very keen to hear it.

VimS commented 2 years ago

Thanks v0.2.0. that worked like a charm.