From e88d47b4a2c19b698f7d0f1e764fa9ad04d45e6a Mon Sep 17 00:00:00 2001 From: David Monllao Date: Mon, 11 Mar 2013 10:00:33 +0800 Subject: [PATCH] MDL-38352 behat: Removing extra double quotes escape --- lib/testing/classes/nasty_strings.php | 2 +- lib/tests/behat/behat_transformations.php | 21 +++------------------ 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/lib/testing/classes/nasty_strings.php b/lib/testing/classes/nasty_strings.php index 95026d7b0f2..826a8ed287d 100644 --- a/lib/testing/classes/nasty_strings.php +++ b/lib/testing/classes/nasty_strings.php @@ -56,7 +56,7 @@ class nasty_strings { '\' \\" \ \'$@NULL@$ @@TEST@@ < > & < > & \\\" \\ , ; : . 日本語­% %%', '\\\" \\ , ; : . 日本語­% < > & < > & \' \\" \ \'$@NULL@$ @@TEST@@ %%', '< > & < > & \' \\" \ \'$@NULL@$ 日本語­% %% @@TEST@@ \\\" \\ . , ; :', - '. 日本語& \' \\"< > & < > \\\" \\ , ; : \ \'$@NULL@$ @@TEST@@­% %%', + '. 日本語& \' \\" < > & < > \\ , ; : \ \'$@NULL@$ \\\" @@TEST@@­% %%', '& \' \\" \ < > & < > \\\" \\ , ; : . 日本語\'$@NULL@$ @@TEST@@­% %%', ); diff --git a/lib/tests/behat/behat_transformations.php b/lib/tests/behat/behat_transformations.php index c684c8a7504..a5591c8af33 100644 --- a/lib/tests/behat/behat_transformations.php +++ b/lib/tests/behat/behat_transformations.php @@ -56,7 +56,7 @@ class behat_transformations extends behat_base { * @return string The string with the arguments fixed. */ public function arg_replace_slashes($string) { - return $this->replace_slashes($string); + return str_replace('\"', '"', $string); } /** @@ -73,8 +73,8 @@ class behat_transformations extends behat_base { /** * Transformations for TableNode arguments. * - * All the transformations have to be applied to tables, - * adding them in a different method for Behat API restrictions. + * Transformations applicable to TableNode arguments should also + * be applied, adding them in a different method for Behat API restrictions. * * @Transform /^table:(.*)/ * @param TableNode $tablenode @@ -87,9 +87,6 @@ class behat_transformations extends behat_base { foreach ($rows as $rowkey => $row) { foreach ($row as $colkey => $value) { - // TableNodes values doesn't need to be escaped, but maybe somebody does it. - $rows[$rowkey][$colkey] = $this->replace_slashes($value); - // Transforms vars into nasty strings. if (preg_match('/\$NASTYSTRING(\d)/', $rows[$rowkey][$colkey])) { $rows[$rowkey][$colkey] = $this->replace_nasty_strings($rows[$rowkey][$colkey]); @@ -102,18 +99,6 @@ class behat_transformations extends behat_base { return $tablenode; } - /** - * Removes the escaped double quotes. - * - * Method reused by TableNode transformation. - * - * @param string $string - * @return string - */ - public function replace_slashes($string) { - return str_replace('\"', '"', $string); - } - /** * Replaces $NASTYSTRING vars for a nasty string. *