{"action":"created","issue":{"url":"https://api.github.com/repos/sebastianbergmann/phpunit/issues/2270","repository_url":"https://api.github.com/repos/sebastianbergmann/phpunit","labels_url":"https://api.github.com/repos/sebastianbergmann/phpunit/issues/2270/labels{/name}","comments_url":"https://api.github.com/repos/sebastianbergmann/phpunit/issues/2270/comments","events_url":"https://api.github.com/repos/sebastianbergmann/phpunit/issues/2270/events","html_url":"https://github.com/sebastianbergmann/phpunit/pull/2270","id":171652483,"number":2270,"title":"Allow `createPartialMock()` to not mock any methods.","user":{"login":"corphi","id":121417,"avatar_url":"https://avatars.githubusercontent.com/u/121417?v=3","gravatar_id":"","url":"https://api.github.com/users/corphi","html_url":"https://github.com/corphi","followers_url":"https://api.github.com/users/corphi/followers","following_url":"https://api.github.com/users/corphi/following{/other_user}","gists_url":"https://api.github.com/users/corphi/gists{/gist_id}","starred_url":"https://api.github.com/users/corphi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/corphi/subscriptions","organizations_url":"https://api.github.com/users/corphi/orgs","repos_url":"https://api.github.com/users/corphi/repos","events_url":"https://api.github.com/users/corphi/events{/privacy}","received_events_url":"https://api.github.com/users/corphi/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/sebastianbergmann/phpunit/labels/enhancement","name":"enhancement","color":"009800"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-08-17T13:06:48Z","updated_at":"2016-08-17T22:10:11Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/sebastianbergmann/phpunit/pulls/2270","html_url":"https://github.com/sebastianbergmann/phpunit/pull/2270","diff_url":"https://github.com/sebastianbergmann/phpunit/pull/2270.diff","patch_url":"https://github.com/sebastianbergmann/phpunit/pull/2270.patch"},"body":"Right now, `createPartialMock($class, [])` does the same thing as `createMock($class)`; it mocks all methods. This is somewhat counter-intuitive and caused by the API of the mock builder, where calling `setMethods(null)` has the expected effect.\r\n\r\nAs a first idea, I allowed passing `null` as a parameter value for consistency. But there is no need for `createPartialMock` to return a complete one - `createMock` already does that. `[]` also expresses the meaning better than `null` (“exactly these methods”). As a bonus, the method signature doesn’t change.\r\n\r\nTest included."},"comment":{"url":"https://api.github.com/repos/sebastianbergmann/phpunit/issues/comments/240564868","html_url":"https://github.com/sebastianbergmann/phpunit/pull/2270#issuecomment-240564868","issue_url":"https://api.github.com/repos/sebastianbergmann/phpunit/issues/2270","id":240564868,"user":{"login":"corphi","id":121417,"avatar_url":"https://avatars.githubusercontent.com/u/121417?v=3","gravatar_id":"","url":"https://api.github.com/users/corphi","html_url":"https://github.com/corphi","followers_url":"https://api.github.com/users/corphi/followers","following_url":"https://api.github.com/users/corphi/following{/other_user}","gists_url":"https://api.github.com/users/corphi/gists{/gist_id}","starred_url":"https://api.github.com/users/corphi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/corphi/subscriptions","organizations_url":"https://api.github.com/users/corphi/orgs","repos_url":"https://api.github.com/users/corphi/repos","events_url":"https://api.github.com/users/corphi/events{/privacy}","received_events_url":"https://api.github.com/users/corphi/received_events","type":"User","site_admin":false},"created_at":"2016-08-17T22:10:11Z","updated_at":"2016-08-17T22:10:11Z","body":"I use such mock objects in tests for setters and getters; mostly it’s about avoiding a call to the constructor. The code to create such objects is the same as in `createPartialMock()` – except for the methods mocked. These tests could pass a random untested method name instead (in fact, that’s the way the tests work right now), but that’s a silly workaround and will likely break."}}
{"actor":{"display_login":"corphi"}}