<commit_before><?php

namespace League\Plates\Template;

use org\bovigo\vfs\vfsStream;

class TemplateTest extends \PHPUnit_Framework_TestCase
{
    private $template;

    public function setUp()
    {
        vfsStream::setup('templates');

        $engine = new \League\Plates\Engine(vfsStream::url('templates'));
        $engine->registerFunction('uppercase', 'strtoupper');

        $this->template = new \League\Plates\Template\Template($engine, 'template');
    }

    public function testCanCreateInstance()
    {
        $this->assertInstanceOf('League\Plates\Template\Template', $this->template);
    }

    public function testCanCallFunction()
    {
        vfsStream::create(
            array(
                'template.php' => '<?php echo $this->uppercase("jonathan") ?>',
            )
        );

        $this->assertEquals($this->template->render(), 'JONATHAN');
    }

    public function testAssignData()
    {
        vfsStream::create(
            array(
                'template.php' => '<?php echo $name ?>',
            )
        );

        $this->template->data(array('name' => 'Jonathan'));
        $this->assertEquals($this->template->render(), 'Jonathan');
    }

    public function testExists()
    {
        vfsStream::create(
            array(
                'template.php' => '',
            )
        );

        $this->assertEquals($this->template->exists(), true);
    }

    public function testDoesNotExist()
    {
        $this->assertEquals($this->template->exists(), false);
    }

    public function testGetPath()
    {
        $this->assertEquals($this->template->path(), 'vfs://templates/template.php');
    }

    public function testRender()
    {
        vfsStream::create(
            array(
                'template.php' => 'Hello World',
            )
        );

        $this->assertEquals($this->template->render(), 'Hello World');
    }

    public function testRenderWithData()
    {
        vfsStream::create(
            array(
                'template.php' => '<?php echo $name ?>',
            )
        );

        $this->assertEquals($this->template->render(array('name' => 'Jonathan')), 'Jonathan');
    }

    public function testRenderDoesNotExist()
    {
        $this->setExpectedException('LogicException', 'The template "template" could not be found at "vfs://templates/template.php".');
        var_dump($this->template->render());
    }

    public function testLayout()
    {
        vfsStream::create(
            array(
                'template.php' => '<?php $this->layout("layout") ?>',
                'layout.php' => 'Hello World',
            )
        );

        $this->assertEquals($this->template->render(), 'Hello World');
    }

    public function testSection()<commit_msg>add tests for render alias<commit_after><?php

namespace League\Plates\Template;

use org\bovigo\vfs\vfsStream;

class TemplateTest extends \PHPUnit_Framework_TestCase
{
    private $template;

    public function setUp()
    {
        vfsStream::setup('templates');

        $engine = new \League\Plates\Engine(vfsStream::url('templates'));
        $engine->registerFunction('uppercase', 'strtoupper');

        $this->template = new \League\Plates\Template\Template($engine, 'template');
    }

    public function testCanCreateInstance()
    {
        $this->assertInstanceOf('League\Plates\Template\Template', $this->template);
    }

    public function testCanCallFunction()
    {
        vfsStream::create(
            array(
                'template.php' => '<?php echo $this->uppercase("jonathan") ?>',
            )
        );

        $this->assertEquals($this->template->render(), 'JONATHAN');
    }

    public function testAssignData()
    {
        vfsStream::create(
            array(
                'template.php' => '<?php echo $name ?>',
            )
        );

        $this->template->data(array('name' => 'Jonathan'));
        $this->assertEquals($this->template->render(), 'Jonathan');
    }

    public function testExists()
    {
        vfsStream::create(
            array(
                'template.php' => '',
            )
        );

        $this->assertEquals($this->template->exists(), true);
    }

    public function testDoesNotExist()
    {
        $this->assertEquals($this->template->exists(), false);
    }

    public function testGetPath()
    {
        $this->assertEquals($this->template->path(), 'vfs://templates/template.php');
    }

    public function testRender()
    {
        vfsStream::create(
            array(
                'template.php' => 'Hello World',
            )
        );

        $this->assertEquals($this->template->render(), 'Hello World');
    }

    public function testRenderThroughStringAlias()
    {
        vfsStream::create(
            array(
                'template.php' => 'Hello World',
            )
        );

        // Capture the template rendered from __toString()
        ob_start();
            echo $this->template;
            $actual = ob_get_contents();
        ob_end_clean();

        $this->assertEquals($actual, 'Hello World');
    }

    public function testRenderWithData()
    {
        vfsStream::create(
            array(
                'template.php' => '<?php echo $name ?>',
            )
        );

        $this->assertEquals($this->template->render(array('name' => 'Jonathan')), 'Jonathan');
    }

    public function testRenderDoesNotExist()
    {
        $this->setExpectedException('LogicException', 'The template "template" could not be found at "vfs://templates/template.php".');
        var_dump($this->template->render());
    }

    public function testLayout()
    {
        vfsStream::create(
            array(
                'template.php' => '<?php $this->layout("layout") ?>',
                'layout.php' => 'Hello World',
            )
        );

        $this->assertEquals($this->template->render(), 'Hello World');
    }

    public function testSection()
{'fraction_non_alphanumeric': 0.15487763995977205, 'fraction_numerical': 0.0, 'mean_word_length': 2.0805369127516777, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 102, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3494969', 'n_tokens_mistral': 1676, 'n_tokens_neox': 1611, 'n_words': 276}