{"action":"created","issue":{"url":"https://api.github.com/repos/padraic/mockery/issues/461","labels_url":"https://api.github.com/repos/padraic/mockery/issues/461/labels{/name}","comments_url":"https://api.github.com/repos/padraic/mockery/issues/461/comments","events_url":"https://api.github.com/repos/padraic/mockery/issues/461/events","html_url":"https://github.com/padraic/mockery/issues/461","id":64964268,"number":461,"title":"Mocking methods, that are handled via \"__call\" method","user":{"login":"aik099","id":1277526,"avatar_url":"https://avatars.githubusercontent.com/u/1277526?v=3","gravatar_id":"","url":"https://api.github.com/users/aik099","html_url":"https://github.com/aik099","followers_url":"https://api.github.com/users/aik099/followers","following_url":"https://api.github.com/users/aik099/following{/other_user}","gists_url":"https://api.github.com/users/aik099/gists{/gist_id}","starred_url":"https://api.github.com/users/aik099/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aik099/subscriptions","organizations_url":"https://api.github.com/users/aik099/orgs","repos_url":"https://api.github.com/users/aik099/repos","events_url":"https://api.github.com/users/aik099/events{/privacy}","received_events_url":"https://api.github.com/users/aik099/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-03-28T16:51:10Z","updated_at":"2015-03-30T08:07:26Z","closed_at":null,"body":"I have a class with `__call` method defined, that catches calls to all `get*` method. I need to mock single method in that class and I'm using partial mock this way:\r\n\r\n```php\r\nclass MockMe {\r\n\r\n    protected $properties = array();\r\n\r\n    public function __constuct()\r\n    {\r\n        $this->otherMethod();\r\n    }\r\n\r\n    public function __call($method, array $args)\r\n    {\r\n        if ( substr($method, 0, 3) === 'get' ) {\r\n            return $this->properties[substr($method, 3)];\r\n        }\r\n    }\r\n\r\n    public function otherMethod()\r\n    {\r\n    }\r\n\r\n    public function doWork()\r\n    {\r\n        return $this->getMagicSetting() * 5;\r\n    }\r\n\r\n}\r\n\r\n$mock = m::mock('MockMe[methodName]', array('constructor-arg'));\r\n$mock->doWork();\r\n```\r\nBecause Mockery doesn't know these magic method names it can't mock them in advance it throws an exception whenever `doWork` method is called.\r\n\r\nThen I've tried to do this:\r\n```php\r\n$mock->shouldReceive('getMagicSetting')-> passthru();\r\n```\r\nThat however resulted in Fatal Error about maximal nesting level reached.\r\n \r\nAlso the method call in constructor totally breaks it because constructor is called before I'm able to call `->makePartial()` on the mock.\r\n\r\nAny idea?"},"comment":{"url":"https://api.github.com/repos/padraic/mockery/issues/comments/87584567","html_url":"https://github.com/padraic/mockery/issues/461#issuecomment-87584567","issue_url":"https://api.github.com/repos/padraic/mockery/issues/461","id":87584567,"user":{"login":"aik099","id":1277526,"avatar_url":"https://avatars.githubusercontent.com/u/1277526?v=3","gravatar_id":"","url":"https://api.github.com/users/aik099","html_url":"https://github.com/aik099","followers_url":"https://api.github.com/users/aik099/followers","following_url":"https://api.github.com/users/aik099/following{/other_user}","gists_url":"https://api.github.com/users/aik099/gists{/gist_id}","starred_url":"https://api.github.com/users/aik099/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aik099/subscriptions","organizations_url":"https://api.github.com/users/aik099/orgs","repos_url":"https://api.github.com/users/aik099/repos","events_url":"https://api.github.com/users/aik099/events{/privacy}","received_events_url":"https://api.github.com/users/aik099/received_events","type":"User","site_admin":false},"created_at":"2015-03-30T08:07:26Z","updated_at":"2015-03-30T08:07:26Z","body":"Avoid which of what I've tried exactly?"}}