{"action":"created","issue":{"url":"https://api.github.com/repos/padraic/mockery/issues/507","labels_url":"https://api.github.com/repos/padraic/mockery/issues/507/labels{/name}","comments_url":"https://api.github.com/repos/padraic/mockery/issues/507/comments","events_url":"https://api.github.com/repos/padraic/mockery/issues/507/events","html_url":"https://github.com/padraic/mockery/issues/507","id":108442586,"number":507,"title":"The first expectation is matched, rather than the most specific","user":{"login":"KimPrince","id":1072441,"avatar_url":"https://avatars.githubusercontent.com/u/1072441?v=3","gravatar_id":"","url":"https://api.github.com/users/KimPrince","html_url":"https://github.com/KimPrince","followers_url":"https://api.github.com/users/KimPrince/followers","following_url":"https://api.github.com/users/KimPrince/following{/other_user}","gists_url":"https://api.github.com/users/KimPrince/gists{/gist_id}","starred_url":"https://api.github.com/users/KimPrince/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KimPrince/subscriptions","organizations_url":"https://api.github.com/users/KimPrince/orgs","repos_url":"https://api.github.com/users/KimPrince/repos","events_url":"https://api.github.com/users/KimPrince/events{/privacy}","received_events_url":"https://api.github.com/users/KimPrince/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-09-26T05:45:58Z","updated_at":"2015-10-06T09:50:32Z","closed_at":null,"body":"In the code below I am configuring expectations for when the get() method is called on a mock ZF2 service locator.  As a general rule, if the argument to the get() method starts with Mapper\\ regex pattern, I return a mocked mapper interface (Core\\iMapper\\Mapper).  If, however, the argument is Mapper\\User, I return a $userMapper.\r\n\r\nThe argument validation for Mapper\\User is more specific than the regex matcher, so I think it should match in preference to the general Mapper matcher.  This is not how it works, however.  I can only get it to match the literal Mapper\\User by configuration this expectation prior to the regex one.\r\n\r\n      $this->serviceLocator = m::mock('Zend\\ServiceManager\\ServiceLocatorInterface')\r\n\r\n            // generally mock calls to get a mapper\r\n            ->shouldReceive('get')\r\n            ->with(matchesPattern('/^Mapper\\\\\\\\/'))\r\n            ->andReturn(m::mock('Core\\iMapper\\Mapper'))\r\n            ->getMock()\r\n\r\n            // specifically mock calls to the user mapper\r\n            ->shouldReceive('get')\r\n            ->with('Mapper\\User')\r\n            ->andReturn($userMapper)\r\n            ->getMock();"},"comment":{"url":"https://api.github.com/repos/padraic/mockery/issues/comments/145802774","html_url":"https://github.com/padraic/mockery/issues/507#issuecomment-145802774","issue_url":"https://api.github.com/repos/padraic/mockery/issues/507","id":145802774,"user":{"login":"davedevelopment","id":61351,"avatar_url":"https://avatars.githubusercontent.com/u/61351?v=3","gravatar_id":"","url":"https://api.github.com/users/davedevelopment","html_url":"https://github.com/davedevelopment","followers_url":"https://api.github.com/users/davedevelopment/followers","following_url":"https://api.github.com/users/davedevelopment/following{/other_user}","gists_url":"https://api.github.com/users/davedevelopment/gists{/gist_id}","starred_url":"https://api.github.com/users/davedevelopment/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davedevelopment/subscriptions","organizations_url":"https://api.github.com/users/davedevelopment/orgs","repos_url":"https://api.github.com/users/davedevelopment/repos","events_url":"https://api.github.com/users/davedevelopment/events{/privacy}","received_events_url":"https://api.github.com/users/davedevelopment/received_events","type":"User","site_admin":false},"created_at":"2015-10-06T09:50:32Z","updated_at":"2015-10-06T09:50:32Z","body":"Aye, I just don't see those cases very often and therefore I'm reluctant to add a large amount of effort in to making it possible. "}}