Skip to content

Conversation

@tysonphillips
Copy link
Member

…at implement the magic methods __call or __callStatic
Fixes #23

…at implement the magic methods __call or __callStatic
# see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/275
#
/*
$magicController = $this->getMockBuilder('Controller')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not create a test controller that uses magic methods and assert it works as example expected?


$result = null;
if (method_exists($ctrl, $action)) {
if (method_exists($ctrl, $action) || is_callable([$ctrl, $action])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it makes sense to just use 'is_callable'? Seems like that covers method_exists.

|| $reflectedObj->isSubclassOf($inheritsFrom)
)
);
} catch (Exception $e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What Exception instance is possible here? Should probably catch the most specific avalable.

} catch (ReflectionException $e) {
return false;
} catch (Exception $e) {
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what this catch adds.

&& !in_array(strtolower($method), $publicUncallables)
&& (
$inheritsFrom === null
|| $reflectedObj->getName() == $inheritsFrom
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

===?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants