X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fconsolidation%2Flog%2Ftests%2Fsrc%2FTestDataPermuter.php;fp=vendor%2Fconsolidation%2Flog%2Ftests%2Fsrc%2FTestDataPermuter.php;h=c44ef53abc908b2888f41e2e5718e5da9acdb146;hp=0000000000000000000000000000000000000000;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/vendor/consolidation/log/tests/src/TestDataPermuter.php b/vendor/consolidation/log/tests/src/TestDataPermuter.php new file mode 100644 index 000000000..c44ef53ab --- /dev/null +++ b/vendor/consolidation/log/tests/src/TestDataPermuter.php @@ -0,0 +1,81 @@ + $values) { + $tests = static::expandOneValue($tests, $substitute, $values); + } + return $tests; + } + + /** + * Given an array of test data, where each element is + * data to pass to a unit test, find any element in any + * one test item whose value is exactly $substitute. + * Make a new test item for every item in $values, using + * each as the substitution for $substitute. + */ + public static function expandOneValue($tests, $substitute, $values) + { + $result = []; + + foreach($tests as $test) { + $position = array_search($substitute, $test); + if ($position === FALSE) { + $result[] = $test; + } + else { + foreach($values as $replacement) { + $test[$position] = $replacement; + $result[] = $test; + } + } + } + + return $result; + } +}