Codeception / Codeception/AspectMock
Class Stripe\Exception\ExceptionInterface was not found
- Lenguaje dominante
- PHP
- Estrellas
- 784
- Forks
- 132
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
In my tests, I am forcing Stripe to fail by giving it a bogus API key, so that I can test the error logging etc.
However, when I have Aspect Mock enabled, it seems that due to some internal reflection, Stripe's actual error message is being tampered with. Instead of seeing:
```
[Stripe\Exception\AuthenticationException] Invalid API Key provided: boguskey
```
which is what I see when AspectMock is totally removed from my project, instead, I get:
```
[InvalidArgumentException] Class Stripe\Exception\ExceptionInterface was not found in the /path/to/stripe/vendor/files
```
Here is the trace:
```
/work/vendor/goaop/parser-reflection/src/ReflectionEngine.php:152
/work/vendor/goaop/parser-reflection/src/ReflectionClass.php:44
/work/vendor/goaop/parser-reflection/src/ReflectionClass.php:68
/work/vendor/goaop/parser-reflection/src/Traits/ReflectionClassLikeTrait.php:974
/work/vendor/goaop/parser-reflection/src/Traits/ReflectionClassLikeTrait.php:323
/work/vendor/goaop/parser-reflection/src/Traits/ReflectionClassLikeTrait.php:322
/work/vendor/goaop/parser-reflection/src/Traits/ReflectionClassLikeTrait.php:971
/work/vendor/goaop/parser-reflection/src/Traits/ReflectionClassLikeTrait.php:323
/work/vendor/goaop/parser-reflection/src/Traits/ReflectionClassLikeTrait.php:309
/work/vendor/codeception/aspect-mock/src/AspectMock/Intercept/BeforeMockTransformer.php:31
/work/vendor/goaop/framework/src/Instrument/Transformer/CachingTransformer.php:121
/work/vendor/goaop/framework/src/Instrument/Transformer/CachingTransformer.php:78
/work/vendor/goaop/framework/src/Instrument/ClassLoading/SourceTransformingLoader.php:136
/work/vendor/goaop/framework/src/Instrument/ClassLoading/SourceTransformingLoader.php:103
/work/vendor/goaop/framework/src/Instrument/ClassLoading/AopComposerLoader.php:139
/work/vendor/goaop/framework/src/Instrument/ClassLoading/AopComposerLoader.php:139
/work/vendor/stripe/stripe-php/lib/ApiRequestor.php:182
/work/vendor/stripe/stripe-php/lib/ApiRequestor.php:142
/work/vendor/stripe/stripe-php/lib/ApiRequestor.php:429
/work/vendor/stripe/stripe-php/lib/ApiRequestor.php:113
/work/vendor/stripe/stripe-php/lib/ApiOperations/Request.php:63
/work/vendor/stripe/stripe-php/lib/ApiOperations/Create.php:25
/work/library/stripe_functions.php:266
/work/tests/unit/library/StripeFunctionsTest.php:680
/work/vendor/phpunit/phpunit/src/Framework/TestCase.php:1408
/work/vendor/phpunit/phpunit/src/Framework/TestCase.php:1028
/work/vendor/phpunit/phpunit/src/Framework/TestResult.php:691
/work/vendor/phpunit/phpunit/src/Framework/TestCase.php:756
/work/vendor/phpunit/phpunit/src/Framework/TestSuite.php:597
/work/vendor/codeception/phpunit-wrapper/src/Runner.php:117
/work/vendor/codeception/codeception/src/Codeception/SuiteManager.php:158
/work/vendor/codeception/codeception/src/Codeception/Codecept.php:193
/work/vendor/codeception/codeception/src/Codeception/Codecept.php:160
/work/vendor/codeception/codeception/src/Codeception/Command/Run.php:391
/work/vendor/symfony/console/Command/Command.php:255
/work/vendor/symfony/console/Application.php:1012
/work/vendor/symfony/console/Application.php:272
/work/vendor/symfony/console/Application.php:148
/work/vendor/codeception/codeception/src/Codeception/Application.php:107
/work/vendor/codeception/codeception/codecept:43
```
It seems that when Stripe hits my (intentional) error, it gets rerouted into the internals of `AspectMock` and gets lost.
This is the trace when AspectMock is disabled:
```
/work/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php:38
/work/vendor/stripe/stripe-php/lib/ApiRequestor.php:189
/work/vendor/stripe/stripe-php/lib/ApiRequestor.php:149
/work/vendor/stripe/stripe-php/lib/ApiRequestor.php:438
/work/vendor/stripe/stripe-php/lib/ApiRequestor.php:118
/work/vendor/stripe/stripe-php/lib/ApiOperations/Request.php:63
/work/vendor/stripe/stripe-php/lib/ApiOperations/Create.php:25
/work/library/stripe_functions.php:266
/work/tests/unit/library/StripeFunctionsTest.php:680
/work/vendor/phpunit/phpunit/src/Framework/TestCase.php:1408
/work/vendor/phpunit/phpunit/src/Framework/TestCase.php:1028
/work/vendor/phpunit/phpunit/src/Framework/TestResult.php:691
/work/vendor/phpunit/phpunit/src/Framework/TestCase.php:756
/work/vendor/phpunit/phpunit/src/Framework/TestSuite.php:597
/work/vendor/codeception/phpunit-wrapper/src/Runner.php:117
/work/vendor/codeception/codeception/src/Codeception/SuiteManager.php:158
/work/vendor/codeception/codeception/src/Codeception/Codecept.php:193
/work/vendor/codeception/codeception/src/Codeception/Codecept.php:160
/work/vendor/codeception/codeception/src/Codeception/Command/Run.php:391
/work/vendor/symfony/console/Command/Command.php:255
/work/vendor/symfony/console/Application.php:1012
/work/vendor/symfony/console/Application.php:272
/work/vendor/symfony/console/Application.php:148
/work/vendor/codeception/codeception/src/Codeception/Application.php:107
/work/vendor/codeception/codeception/codecept:43
```
You can see it goes straight to `/work/vendor/stripe/stripe-php/lib/Exception/ApiErrorException.php:38`.
I should say that when using my correct Stripe API key (and no exceptions are thrown), my code connects fine to Stripe and does what it is supposed to on their platform.
I am using PHP-Unit 8.5, Codeception 3.1.2, Aspect Mock 3.1.0. Will upgrading to the latest versions of PHPUnit/CodeCeption make any difference? Suggestions?
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Reproduce el caso de bogus-key de tests/unit/library/StripeFunctionsTest.php:680 con AspectMock habilitado y, después, sigue el recorrido por goaop/parser-reflection/src/ReflectionEngine.php y codeception/aspect-mock/src/AspectMock/Intercept/BeforeMockTransformer.php. Compara la ruta que falla a través de stripe/stripe-php/lib/ApiRequestor.php con el trace con AspectMock deshabilitado. Se considera terminado cuando el fallo intencional de Stripe llega a ApiErrorException y conserva el mensaje de AuthenticationException, en lugar de informar de que falta la interfaz de excepción de Stripe.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- php
- Área
- testing-qa
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100