From c353674f2173810585ef09559b306022cc245b2c Mon Sep 17 00:00:00 2001 From: Cameron Ball Date: Wed, 3 Aug 2016 02:52:12 +0800 Subject: [PATCH] MDL-54847 weblib: Test media attributes individually --- lib/tests/htmlpurifier_test.php | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/lib/tests/htmlpurifier_test.php b/lib/tests/htmlpurifier_test.php index 7246fe9ccf2..892d2fa50d8 100644 --- a/lib/tests/htmlpurifier_test.php +++ b/lib/tests/htmlpurifier_test.php @@ -335,25 +335,12 @@ class core_htmlpurifier_testcase extends basic_testcase { * Test cases for the test_media_tags test. */ public function media_tags_provider() { - // Given a 1D array, computes the power set of those elements. - $p = function(array $set) { - return array_reduce($set, function($carry, $element) { - return array_merge($carry, array_map(function($subset) use ($element) { - return array_merge([$element], $subset); - }, $carry)); - }, [[]]); - }; - - // Takes an array of attributes, then generates a test for every possible combination of them - // (i.e., every element of the power set). The testcases are named using $prefix and then - // a '/' delimited string describing the attributes being used. $templats is for the - // raw data and expected result. + // Takes an array of attributes, then generates a test for each of them. $generatetestcases = function($prefix, array $attrs, array $templates) use ($p) { - $attrcombinations = $p($attrs); - return array_reduce($attrcombinations, function($carry, $attrset) use ($prefix, $templates) { - $testcase = [$prefix . '/' . join('/', $attrset) => [ - sprintf($templates[0], join(" ", $attrset)), - sprintf($templates[1], join(" ", $attrset)) + return array_reduce($attrs, function($carry, $attr) use ($prefix, $templates) { + $testcase = [$prefix . '/' . $attr => [ + sprintf($templates[0], $attr), + sprintf($templates[1], $attr) ]]; return empty(array_values($carry)[0]) ? $testcase : $carry + $testcase; }, [[]]); -- 2.17.1