Error in code template
I'm trying to add some custom behaviour to code templates, if a method starts with "Get", add some boilerplate test code
public function test${CAPITALIZED_NAME}()
{
#if(${CAPITALIZED_NAME}.startsWith("Get"))
$this->assertNull($this->sut->${NAME}());
$this->assertSame($this->sut, $this->sut->${CAPITALIZED_NAME}('12345'));
$this->assertEquals(12345, $this->sut->${NAME}());
#end
}
But when I try and generate I get an error
"Error parsing file template: Lexical Error Encountered "s" (115), after "." as *unset*[line 3, column 33]"
Anyone know what I'm doing wrong?
Please sign in to leave a comment.
Hi there,
Either get rid of the `{` and `}` there (so it's just `$CAPITALIZED_NAME`) or assign that to a local variable and use it instead, e.g.
#set($capitalizedName = ${CAPITALIZED_NAME})public function test${CAPITALIZED_NAME}()
{
#if($capitalizedName.startsWith("Get"))
...