Codeception / Codeception/AspectMock
Function parameters initialized with a class constant throw an exception
- Dominant language
- PHP
- Stars
- 784
- Forks
- 132
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
In the following code :
```php
init([
'debug' => true,
'includePaths' => [
__DIR__ . '/../src',
'excludePaths' => [
__DIR__ . '/../tests'
]
]
]);
?>
"save is mocking"]);
}
protected function tearDown()
{
test::clean(); // remove all registered test doubles
}
}
```
when we launch the test we get the following exception :
```
PHPUnit 5.7.3 by Sebastian Bergmann and contributors.
Starting test 'AspectMockTest::testDouble'.
E 1 / 1 (100%)
Time: 1.6 seconds, Memory: 24.75MB
There was 1 error:
1) AspectMockTest::testDouble
InvalidArgumentException: Class PDO was not found by locator
/testgo/vendor/goaop/parser-reflection/src/ReflectionEngine.php:112
/testgo/vendor/goaop/parser-reflection/src/ReflectionEngine.php:127
/testgo/vendor/goaop/parser-reflection/src/ReflectionClass.php:45
/testgo/vendor/goaop/parser-reflection/src/ValueResolver/NodeExpressionResolver.php:301
/testgo/vendor/goaop/parser-reflection/src/ValueResolver/NodeExpressionResolver.php:259
/testgo/vendor/goaop/parser-reflection/src/ValueResolver/NodeExpressionResolver.php:118
/testgo/vendor/goaop/parser-reflection/src/ValueResolver/NodeExpressionResolver.php:99
/testgo/vendor/goaop/parser-reflection/src/ReflectionParameter.php:99
/testgo/vendor/goaop/parser-reflection/src/Traits/ReflectionFunctionLikeTrait.php:164
/testgo/vendor/codeception/aspect-mock/src/AspectMock/Intercept/BeforeMockTransformer.php:56
/testgo/vendor/goaop/framework/src/Instrument/Transformer/CachingTransformer.php:124
/testgo/vendor/goaop/framework/src/Instrument/Transformer/CachingTransformer.php:83
/testgo/vendor/goaop/framework/src/Instrument/ClassLoading/SourceTransformingLoader.php:134
/testgo/vendor/goaop/framework/src/Instrument/ClassLoading/SourceTransformingLoader.php:101
/testgo/vendor/goaop/framework/src/Instrument/ClassLoading/AopComposerLoader.php:136
/testgo/vendor/goaop/framework/src/Instrument/ClassLoading/AopComposerLoader.php:136
/testgo/vendor/codeception/aspect-mock/src/AspectMock/Test.php:97
/testgo/tests/AspectMockOrmTest.php:53
ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
```
Do you have any solution or fix to help us please ?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running tests/AspectMockTest.php with the bootstrap and UserModel.php example from the issue. Trace the failure through BeforeMockTransformer.php and the goaop parser-reflection stack, especially NodeExpressionResolver and ReflectionEngine. Done means the testDouble example runs without the PDO locator exception while preserving the class-constant default parameter.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100