Permalink
Browse files

Added Test for closed bug 17063

  • Loading branch information...
1 parent eae0c9f commit 9e3504bef5bf9cb466332ed02014ded1699d5105 @clbustos committed Aug 6, 2010
Showing with 45 additions and 1 deletion.
  1. +1 −1 Beautifier/Filter/Pear.filter.php
  2. +44 −0 tests/BeautifierBugsTest.php
@@ -44,7 +44,7 @@
* Two extra options allows to break the spec about newline before braces
* on function and classes. By default, they are set to true. Use
* <code>
- * $oBeaut->addFilter('Pear',array('newline_class'=>false, 'newline_function'=>false));
+ * $oBeaut->addFilter('Pear', array('newline_class'=>false, 'newline_function'=>false));
* </code>
*
* @category PHP
@@ -1160,6 +1160,50 @@ class Z {
SCRIPT;
$this->assertEquals($sExpected, $this->oBeaut->get());
}
+ /**
+ * Pear filter PHP_Beautifier_Filter_Pear with enabled
+ * "switch_without_indent" setting, this is enabled by default,
+ * results in invalid code, if the case block contains
+ * closing brackets in strings.
+ */
+ function testBug17063() {
+ //$this->oBeaut->startLog();
+ $this->oBeaut->addFilter('Pear');
+ $sText = <<<SCRIPT
+function testFunction() {
+ \$foo = 'foo';
+ \$bar = 'bar';
+ switch (\$foo) {
+ case 'foo':
+ return "string with var having braces {\$foo}{\$bar}";
+ break;
+ case 'bar':
+ return \$foo{0} . \$bar{0};
+ break;
+ default:
+ return "\\$\${var}";
+ }
+}
+SCRIPT;
+$this->setText($sText);
+ $sExpected = <<<SCRIPT
+function testFunction() {
+ \$foo = 'foo';
+ \$bar = 'bar';
+ switch (\$foo) {
+ case 'foo':
+ return "string with var having braces {\$foo}{\$bar}";
+ break;
+ case 'bar':
+ return \$foo{0} . \$bar{0};
+ break;
+ default:
+ return "\\$\${var}";
+ }
+}
+SCRIPT;
+$this->assertEquals($sExpected, $this->oBeaut->get());
+ }
}
?>

0 comments on commit 9e3504b

Please sign in to comment.