diff --git a/spec/Prophecy/Prophecy/ObjectProphecySpec.php b/spec/Prophecy/Prophecy/ObjectProphecySpec.php index c6afb3ef0..062ebd574 100644 --- a/spec/Prophecy/Prophecy/ObjectProphecySpec.php +++ b/spec/Prophecy/Prophecy/ObjectProphecySpec.php @@ -125,7 +125,7 @@ function its_addMethodProphecy_adds_method_prophecy( $this->addMethodProphecy($methodProphecy); $this->getMethodProphecies()->shouldReturn(array( - 'getUsername' => array($methodProphecy) + 'getusername' => array($methodProphecy) )); } @@ -145,7 +145,30 @@ function its_addMethodProphecy_handles_prophecies_with_different_arguments( $this->addMethodProphecy($methodProphecy2); $this->getMethodProphecies()->shouldReturn(array( - 'getUsername' => array( + 'getusername' => array( + $methodProphecy1, + $methodProphecy2, + ) + )); + } + + function its_addMethodProphecy_handles_prophecies_for_caseinsensitive_method_names( + MethodProphecy $methodProphecy1, + MethodProphecy $methodProphecy2, + ArgumentsWildcard $argumentsWildcard1, + ArgumentsWildcard $argumentsWildcard2 + ) { + $methodProphecy1->getArgumentsWildcard()->willReturn($argumentsWildcard1); + $methodProphecy1->getMethodName()->willReturn('getUsername'); + + $methodProphecy2->getArgumentsWildcard()->willReturn($argumentsWildcard2); + $methodProphecy2->getMethodName()->willReturn('getUserName'); + + $this->addMethodProphecy($methodProphecy1); + $this->addMethodProphecy($methodProphecy2); + + $this->getMethodProphecies()->shouldReturn(array( + 'getusername' => array( $methodProphecy1, $methodProphecy2, ) @@ -168,10 +191,10 @@ function its_addMethodProphecy_handles_prophecies_for_different_methods( $this->addMethodProphecy($methodProphecy2); $this->getMethodProphecies()->shouldReturn(array( - 'getUsername' => array( + 'getusername' => array( $methodProphecy1 ), - 'isUsername' => array( + 'isusername' => array( $methodProphecy2 ) )); diff --git a/src/Prophecy/Call/CallCenter.php b/src/Prophecy/Call/CallCenter.php index 92a651450..9a741765a 100644 --- a/src/Prophecy/Call/CallCenter.php +++ b/src/Prophecy/Call/CallCenter.php @@ -138,11 +138,11 @@ public function makeCall(ObjectProphecy $prophecy, $methodName, array $arguments */ public function findCalls($methodName, ArgumentsWildcard $wildcard) { - $lowerMethodName = strtolower($methodName); + $methodName = strtolower($methodName); return array_values( - array_filter($this->recordedCalls, function (Call $call) use ($lowerMethodName, $wildcard) { - return $lowerMethodName === strtolower($call->getMethodName()) + array_filter($this->recordedCalls, function (Call $call) use ($methodName, $wildcard) { + return $methodName === strtolower($call->getMethodName()) && 0 < $call->getScore($wildcard) ; }) diff --git a/src/Prophecy/Prophecy/ObjectProphecy.php b/src/Prophecy/Prophecy/ObjectProphecy.php index de1a31ddb..ecc22bf55 100644 --- a/src/Prophecy/Prophecy/ObjectProphecy.php +++ b/src/Prophecy/Prophecy/ObjectProphecy.php @@ -146,7 +146,7 @@ public function addMethodProphecy(MethodProphecy $methodProphecy) ), $methodProphecy); } - $methodName = $methodProphecy->getMethodName(); + $methodName = strtolower($methodProphecy->getMethodName()); if (!isset($this->methodProphecies[$methodName])) { $this->methodProphecies[$methodName] = array(); @@ -168,18 +168,13 @@ public function getMethodProphecies($methodName = null) return $this->methodProphecies; } - $lowerMethodName = strtolower($methodName); + $methodName = strtolower($methodName); - $result = array(); - foreach ($this->methodProphecies as $name => $prophecies) { - if (strtolower($name) === $lowerMethodName) { - foreach ($prophecies as $prophecy) { - $result[] = $prophecy; - } - } + if (!isset($this->methodProphecies[$methodName])) { + return array(); } - return $result; + return $this->methodProphecies[$methodName]; } /**