4 * This file is part of the Behat.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\Testwork\Ordering\Orderer;
13 use Behat\Testwork\Specification\SpecificationArrayIterator;
16 * Prioritises Suites and Features into random order
18 * @author Ciaran McNulty <mail@ciaranmcnulty.com>
20 final class RandomOrderer implements Orderer
23 * @param SpecificationIterator[] $scenarioIterators
24 * @return SpecificationIterator[]
26 public function order(array $scenarioIterators)
28 $orderedFeatures = $this->orderFeatures($scenarioIterators);
29 shuffle($orderedFeatures);
31 return $orderedFeatures;
35 * @param array $scenarioIterators
38 private function orderFeatures(array $scenarioIterators)
40 $orderedSuites = array();
42 foreach ($scenarioIterators as $scenarioIterator) {
43 $orderedSpecifications = iterator_to_array($scenarioIterator);
44 shuffle($orderedSpecifications);
45 $orderedSuites[] = new SpecificationArrayIterator(
46 $scenarioIterator->getSuite(),
47 $orderedSpecifications
51 return $orderedSuites;
57 public function getName()