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:----mxjf3ogWHxpdPBEFA6p81uVouwRnQlXIwWCy7ZwZunf2SuuvRKz1fnFseLcrE46CzS/0LyidBl1pN1S512vQ1GcgqcaXae9Q8cFnfhcY9WPfGnfDdb9kWJVR7zb8DSOutQzEphiMksMHeDigM9Rmw9f56zMghQdYB7g9k7lIh8bK/6jgdGD3cBrjh3V0Zb5lald0H9vJUNYFC66I79fD3s3z23xIfeeux5PTbdszdNAJBigJWttWcDxvpYIuUhUaGmmBcdoYNqZkhkJGDe+yB4X2IPx/oL7LQdekGp32b3wQ+bKXnKEJIci4hTTb7x8d4xa3YHoYvtPwQVq4jQg4k6PfWLtn+0rS87ORMaGTmJYNifEqamH2e2vIQhX0ng7I06nMjRQVxZWwIwfnVLTEBow6j4peUiUQnQfucug/bUJWjthcN0i0g68aMy7N3vqj/AcdVlW3qhgiREdnTRUDQ9+YyLoZVdjTdyp4lyFry2CmAy7VNcYUoIn1i9yjNojQJq0H7tZzoPxvWWUXKR+bKEhaWyvT32OdillF9+8njsiJXqUgBkGU8/qYA9Ujmppz54r+en8eC/uA0eNevtoYj71Xn7EMWSlMw1MXab+uG1g3QRLm8eOgZRUck2SCDpAwhy6j4bHvYp2lfAGFdEby/0SwokRdGMEOEkt77jTUWak=----ATTACHMENT:----NzY0NTEzMzY0NTk2MDk1OSAzNTUyMTg1OTA1NTEyMTA3IDY1NjA2NTIwMTc0MDYwNDE=