Skip to content

Commit

Permalink
Merge pull request #160 from bhoehl/invocation/missing/asserts
Browse files Browse the repository at this point in the history
missing assertions for method call invocations
  • Loading branch information
Naktibalda committed Feb 29, 2020
2 parents da8b98a + 758413b commit 72fc3d6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/AspectMock/Proxy/Verifier.php
@@ -1,5 +1,7 @@
<?php
namespace AspectMock\Proxy;

use \PHPUnit\Framework\Assert;
use \PHPUnit\Framework\ExpectationFailedException as fail;
use AspectMock\Util\ArgumentsFormatter;

Expand Down Expand Up @@ -118,14 +120,18 @@ public function verifyInvokedMultipleTimes($name, $times, $params = null)
$equals++;
}
}
if ($equals == $times) return;
if ($equals == $times) {
Assert::assertTrue(true);
return;
}
$params = ArgumentsFormatter::toString($params);
throw new fail(sprintf($this->invokedMultipleTimesFail, $this->className.$separator.$name."($params)", $times, $equals));
} else if(is_callable($params)) {
$params($calls);
}
$num_calls = count($calls);
if ($num_calls != $times) throw new fail(sprintf($this->invokedMultipleTimesFail, $this->className.$separator.$name, $times, $num_calls));
Assert::assertTrue(true);
}

/**
Expand Down Expand Up @@ -153,6 +159,7 @@ public function verifyNeverInvoked($name, $params = null)

if (is_array($params)) {
if (empty($calls)) {
Assert::assertTrue(true);
return;
}

Expand All @@ -161,11 +168,13 @@ public function verifyNeverInvoked($name, $params = null)
throw new fail(sprintf($this->neverInvoked, $this->className));
}
}
Assert::assertTrue(true);
return;
}
if (count($calls)) {
throw new fail(sprintf($this->neverInvoked, $this->className.$separator.$name));
}
Assert::assertTrue(true);
}

}

0 comments on commit 72fc3d6

Please sign in to comment.