Add test for method default values with special chars

This commit is contained in:
Loilo
2020-03-26 09:37:33 +01:00
parent fe2890925e
commit da59650fb2
+20
View File
@@ -47,6 +47,21 @@ class ExampleTest extends TestCase
$this->assertEquals(['$last', '$first = \'Barry\'', '...$middle'], $method->getParamsWithDefault(false));
$this->assertEquals(true, $method->shouldReturn());
}
/**
* Test special characters in method
*/
public function testSpecialChars()
{
$reflectionClass = new \ReflectionClass(ExampleClass::class);
$reflectionMethod = $reflectionClass->getMethod('setSpecialChars');
$method = new Method($reflectionMethod, 'Example', $reflectionClass);
$this->assertEquals('$chars', $method->getParams(true));
$this->assertEquals(['$chars'], $method->getParams(false));
$this->assertEquals('$chars = \'$\\\'\\\\\'', $method->getParamsWithDefault(true));
$this->assertEquals(['$chars = \'$\\\'\\\\\''], $method->getParamsWithDefault(false));
}
}
class ExampleClass
@@ -60,4 +75,9 @@ class ExampleClass
{
return;
}
public function setSpecialChars($chars = "\$'\\")
{
return;
}
}