4 * This file is part of the Prophecy.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6 * Marcello Duarte <marcello.duarte@gmail.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Prophecy\Prediction;
14 use Prophecy\Call\Call;
15 use Prophecy\Prophecy\ObjectProphecy;
16 use Prophecy\Prophecy\MethodProphecy;
17 use Prophecy\Util\StringUtil;
18 use Prophecy\Exception\Prediction\UnexpectedCallsException;
21 * No calls prediction.
23 * @author Konstantin Kudryashov <ever.zet@gmail.com>
25 class NoCallsPrediction implements PredictionInterface
30 * Initializes prediction.
32 * @param null|StringUtil $util
34 public function __construct(StringUtil $util = null)
36 $this->util = $util ?: new StringUtil;
40 * Tests that there were no calls made.
42 * @param Call[] $calls
43 * @param ObjectProphecy $object
44 * @param MethodProphecy $method
46 * @throws \Prophecy\Exception\Prediction\UnexpectedCallsException
48 public function check(array $calls, ObjectProphecy $object, MethodProphecy $method)
54 $verb = count($calls) === 1 ? 'was' : 'were';
56 throw new UnexpectedCallsException(sprintf(
57 "No calls expected that match:\n".
59 "but %d %s made:\n%s",
60 get_class($object->reveal()),
61 $method->getMethodName(),
62 $method->getArgumentsWildcard(),
65 $this->util->stringifyCalls($calls)