/** * Adds a new exception to the stack. * * The stack message is updated to contain the message of the exception. * * @param LimeMockInvocationException $exception */ public function add(LimeMockInvocationException $exception) { $this->exceptions[] = $exception; if (count($this->exceptions) > 1) { $this->message = "One of the following errors occured:\n"; for ($i = 1; $i <= count($this->exceptions); ++$i) { $message = LimeTools::indent(wordwrap($this->exceptions[$i - 1]->getMessage(), 70), strlen($i) + 2); $this->message .= sprintf("%s) %s\n", $i, trim($message)); } } else { $this->message = $this->exceptions[0]->getMessage(); } }
/** * (non-PHPdoc) * @see mock/matcher/LimeMockInvocationMatcherInterface#invoke($invocation) */ public function invoke(LimeMockInvocation $invocation) { try { if (!is_null($this->constraint)) { $this->constraint->evaluate($invocation->getParameter($this->index - 1)); } } catch (LimeConstraintException $e) { $message = LimeTools::indent($e->getMessage(), 2); throw new LimeMockInvocationMatcherException("was called with wrong parameter {$this->index}\n" . $message); } catch (OutOfRangeException $e) { throw new LimeMockInvocationMatcherException("was not called with {$this->index} or more parameters"); } }
<?php /* * This file is part of the Lime framework. * * (c) Fabien Potencier <*****@*****.**> * (c) Bernhard Schussek <*****@*****.**> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ LimeAnnotationSupport::enable(); $t = new LimeTest(); // @Test: indent() indents every line of the string $string = <<<EOF First line Second line Third line EOF; $expected = <<<EOF First line Second line Third line EOF; $t->is(LimeTools::indent($string, 3), $expected, 'All lines except the first one were indented');