public function __call($words, $args) { if (null !== $words) { $this->syntax .= strtolower(preg_replace('/([A-Z])/', ' $1', $words)) . ' '; } if (count($args) > 0) { $this->data[] = $args[0]; $this->syntax .= '? '; } try { $syntax = ModuleManager::getInstance()->getSyntaxCache()->getSyntax($this->getSyntax()); } catch (Exception $e) { $syntax = null; } if ($syntax) { self::$lastBuilder = null; $class = $syntax->getClass(); /** @var AbstractModule $instance */ $instance = new $class(); $data = $this->getData(); $types = $syntax->getArgumentTypes(); $checker = new DataTypeChecker(); for ($i = 0; $i < count($types); ++$i) { try { $data[$i] = $checker->check($types[$i], $data[$i]); } catch (DataTypeMismatchException $e) { $renderer = new ValueRenderer(); throw new Exception("Argument " . ($i + 1) . ' (' . $renderer->render($data[$i]) . ') must be ' . implode(' or ', $types[$i]) . '.'); } } $instance->setData($data); $instance->syntax = $syntax; try { $instance->{$syntax->getMethod()}(); $this->testCase->assertTrue(true); } catch (DidNotMatchException $e) { $this->handleFailure($e, $instance); } } return $this; }
protected function validateExpectation($mock, $method, array $rule) { $this->resetCallGraph(); if (null === $rule['with']) { /** @var $instance \Concise\Mock\MockInterface */ $instance = $mock['instance']; $this->validateSingleWith($rule, count($instance->getCallsForMethod($method)), $method); } else { $this->validateMultiWith($method, $rule, $mock); } $this->testCase->assertTrue(true); }