Skip to content

Commit 72aef96

Browse files
committed
Merge pull request #71 from shoyan/display-got-params
Display actually passed parameter in the error message
2 parents 56b70f3 + dbd4f2e commit 72aef96

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/AspectMock/Proxy/Verifier.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ abstract class Verifier {
1616
*/
1717
public $className;
1818

19-
protected $invokedFail = "Expected %s to be invoked but it never occur.";
19+
protected $invokedFail = "Expected %s to be invoked but it never occur. Got: %s";
2020
protected $notInvokedMultipleTimesFail = "Expected %s to be invoked %s times but it never occur.";
2121
protected $invokedMultipleTimesFail = "Expected %s to be invoked but called %s times but called %s.";
2222

@@ -61,14 +61,16 @@ public function verifyInvoked($name, $params = null)
6161
$calls = $this->getCallsForMethod($name);
6262
$separator = $this->callSyntax($name);
6363

64-
if (empty($calls)) throw new fail(sprintf($this->invokedFail, $this->className.$separator.$name));
64+
if (empty($calls)) throw new fail(sprintf($this->invokedFail, $this->className.$separator.$name, ''));
6565

6666
if (is_array($params)) {
6767
foreach ($calls as $args) {
6868
if ($this->onlyExpectedArguments($params, $args) === $params) return;
6969
}
70-
$params = ArgumentsFormatter::toString($params);
71-
throw new fail(sprintf($this->invokedFail, $this->className.$separator.$name."($params)"));
70+
$params = ArgumentsFormatter::toString($params);
71+
$gotParams = ArgumentsFormatter::toString($calls[0]);
72+
73+
throw new fail(sprintf($this->invokedFail, $this->className.$separator.$name."($params)", $this->className.$separator.$name."($gotParams)"));
7274
} else if(is_callable($params)) {
7375
$params($calls);
7476
}

0 commit comments

Comments
 (0)