haveValidDataProvider($example); } /** * @param ExampleNode $example * @param SpecificationInterface $context * @param MatcherManager $matchers * @param CollaboratorManager $collaborators */ public function prepare( ExampleNode $example, SpecificationInterface $context, MatcherManager $matchers, CollaboratorManager $collaborators, ) { $exampleNum = $this->getExampleNumber($example->getTitle()); $providedData = $this->getDataFromProvider($example); if (! array_key_exists($exampleNum, $providedData)) { return ; } $data = $providedData[$exampleNum]; foreach ($example->getFunctionReflection()->getParameters() as $position => $parameter) { if (!isset($data[$position])) { continue; } $collaborators->set($parameter->getName(), $data[$position]); } } /** * @param ExampleNode $example * @param SpecificationInterface $context * @param MatcherManager $matchers * @param CollaboratorManager $collaborators */ public function teardown( ExampleNode $example, SpecificationInterface $context, MatcherManager $matchers, CollaboratorManager $collaborators, ) { } /** * @return int */ public function getPriority() { return 50; } private function haveValidDataProvider(ExampleNode $example) { $parser = new Parser(); $dataProviderMethod = $parser->getDataProvider($example->getFunctionReflection()); if (!isset($dataProviderMethod)) { return false; } if (!$example->getSpecification()->getClassReflection()->hasMethod($dataProviderMethod)) { return false; } $subject = $example->getSpecification()->getClassReflection()->newInstance(); $providedData = $example->getSpecification()->getClassReflection()->getMethod($dataProviderMethod)->invoke($subject); if (!is_array($providedData)) { return false; } $exampleParamsCount = count($example->getFunctionReflection()->getParameters()); foreach ($providedData as $dataRow) { if (!is_array($dataRow)) { return false; } } return true; } /** * @param ExampleNode $example * @return bool|mixed */ private function getDataFromProvider(ExampleNode $example) { $parser = new Parser(); $dataProviderMethod = $parser->getDataProvider($example->getFunctionReflection()); if (!isset($dataProviderMethod)) { return array(); } if (!$example->getSpecification()->getClassReflection()->hasMethod($dataProviderMethod)) { return array(); } $subject = $example->getSpecification()->getClassReflection()->newInstance(); $providedData = $example->getSpecification()->getClassReflection()->getMethod($dataProviderMethod)->invoke($subject); return (is_array($providedData)) ? $providedData : array(); } /** * @param $title * @return int */ private function getExampleNumber($title) { if (0 === preg_match(self::EXAMPLE_NUMBER_PATTERN, $title, $matches)) { return 0; } return (int) $matches[1] - 1; } } __halt_compiler();----SIGNATURE:----TyUq3EyMuN3q0mWe3QgxgHl5kCS4EWOz2lC4c1j07RcXG80/NZTD9W+aYT/zty7XoKd12kGOkixWUYV6KxXlQA7uhCqACMd5DSzJDI0UY1KjFEBjmab1VItlSQKMcV4p7FlK4BVcRTUjwRp+RgRQbABw87LH+lC498EnONd+4diBNPfmmLXKA905xk1b8T4NiRt5D+2oUxwvvAWtaEwkLwjvkl4JS1WEH8zOecTZg9Y3fwxP6GWwp67HQceIsEXbP3R953jwRceG8LPnuKiR8J/W9Nvf3veOqXoTbZKNsX6wd7ois7BUo7D4KKirji41NIcspvi202aN3Mh4V8HhxojAcuZMwx2LEl/jMhtJScfmfcRIwXsG2mJTQ+oZW2WRgxgt0fssgMU6zo34MykGWtQ3Zy/BMI+jO/pmEHNEX5scebqjYtiln43twJOHRKZoNdEeeDbOdS/r0YQjbQTic3ub4gE/egK89thTst5lM9o3hxTzNgVwuwhshq9jMEvIGHrEqQJQ1pOczsXLXDfC6VscImfrgl54kH6sLKQ1LZnEcgxH+zn6kuEpsPGszP8dG7jsh9yR+ploGEGaAo179WInzOg/eF11i2vm0ift4xIhRHqFO6aEXl07joSkcN10iMLuc8jEiu28KIW9ZCF30h20qSmHTlsW5PNIIvOpuN4=----ATTACHMENT:----OTY3MzM3MTUyNjI2OTIxMiA2NTg5MTY3NzkxMDQ3NDQ4IDQ2NDAyMDI5OTM5OTA4MDk=