mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 01:57:13 +00:00
Add test for method default values with special chars
This commit is contained in:
@@ -47,6 +47,21 @@ class ExampleTest extends TestCase
|
|||||||
$this->assertEquals(['$last', '$first = \'Barry\'', '...$middle'], $method->getParamsWithDefault(false));
|
$this->assertEquals(['$last', '$first = \'Barry\'', '...$middle'], $method->getParamsWithDefault(false));
|
||||||
$this->assertEquals(true, $method->shouldReturn());
|
$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
|
class ExampleClass
|
||||||
@@ -60,4 +75,9 @@ class ExampleClass
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setSpecialChars($chars = "\$'\\")
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user