Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-existent functions can't be mocked since 2.1.0 #158

Open
wxa opened this issue Oct 11, 2018 · 0 comments · May be fixed by #194
Open

Non-existent functions can't be mocked since 2.1.0 #158

wxa opened this issue Oct 11, 2018 · 0 comments · May be fixed by #194

Comments

@wxa
Copy link

wxa commented Oct 11, 2018

The problem was introduced here:
https://github.com/Codeception/AspectMock/pull/133/files#diff-50b2697c4aa86740dcae323b3d7ebe44R44

The placeOptionalAndReferenceFunction method uses ReflectionFunction which throws an exception if a non-existent function name is passed:

[ReflectionException] Function somefunc() does not exist

Before that change it worked fine when trying to mock a non-existent function. This is a valid use case for a plugin architecture where you may not have desired functions in a test environment.

Can it be like this, for example:

if (function_exists($function)) {
    $this->placeOptionalAndReferenceFunction($namespace, $function);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant