PopTest\Code\FunctionTest::testRenderClosure PHP Method

testRenderClosure() public method

public testRenderClosure ( )
    public function testRenderClosure()
    {
        $f = FunctionGenerator::factory('newFunction');
        $f->setClosure(true);
        $f->setBody('some body code', true);
        $f->appendToBody('some more body code');
        $f->appendToBody('even more body code', false);
        $f->addArgument('testVar', 123, 'int');
        $f->addParameter('oneMoreTestVar', 789, 'int');
        $codeStr = (string) $f;
        $code = $f->render(true);
        ob_start();
        $f->render();
        $output = ob_get_clean();
        $this->assertContains('$newFunction = function($testVar = 123, $oneMoreTestVar = 789)', $output);
        $this->assertContains('$newFunction = function($testVar = 123, $oneMoreTestVar = 789)', $code);
        $this->assertContains('$newFunction = function($testVar = 123, $oneMoreTestVar = 789)', $codeStr);
        $this->assertContains('};', $output);
        $this->assertContains('};', $code);
        $this->assertContains('};', $codeStr);
    }