<commit_before><?php
namespace Tonis\View\Strategy;

use Tonis\View\Model\JsonModel;
use Tonis\View\Model\ViewModel;

/**
 * @coversDefaultClass \Tonis\View\Strategy\TwigStrategy
 */
class TwigStrategyTest extends \PHPUnit_Framework_TestCase 
{
    /** @var TwigStrategy */
    private $s;

    /**
     * @covers ::canRender
     */
    public function testCanRender()
    {
        $model = new JsonModel([]);
        $this->assertFalse($this->s->canRender($model));

        $model = new ViewModel('does-not-exist');
        $this->assertFalse($this->s->canRender($model));

        $model = new ViewModel('test');
        $this->assertTrue($this->s->canRender($model));
    }

    /**
     * @covers ::render
     */
    public function testRenderWithInvalidModel()
    {
        $this->assertSame('', $this->s->render(new JsonModel([])));
    }

    /**
     * @covers ::__construct
     * @covers ::render
     */
    public function testRender()
    {
        $m = new ViewModel('variables', ['foo' => 'bar']);
        $this->assertSame("bar\n", $this->s->render($m));
    }

    protected function setUp()
    {
        $loader = new \Twig_Loader_Filesystem(__DIR__ . '/../_view');
        $twig = new \Twig_Environment($loader);
        $this->s = new TwigStrategy($twig);
    }
}
<commit_msg>100% coverage<commit_after><?php
namespace Tonis\View\Strategy;

use Tonis\View\Model\JsonModel;
use Tonis\View\Model\ViewModel;

/**
 * @coversDefaultClass \Tonis\View\Strategy\TwigStrategy
 */
class TwigStrategyTest extends \PHPUnit_Framework_TestCase 
{
    /** @var TwigStrategy */
    private $s;

    /**
     * @covers ::getTwig
     */
    public function testGetTwig()
    {
        $this->assertInstanceOf(\Twig_Environment::class, $this->s->getTwig());
    }

    /**
     * @covers ::canRender
     */
    public function testCanRender()
    {
        $model = new JsonModel([]);
        $this->assertFalse($this->s->canRender($model));

        $model = new ViewModel('does-not-exist');
        $this->assertFalse($this->s->canRender($model));

        $model = new ViewModel('test');
        $this->assertTrue($this->s->canRender($model));
    }

    /**
     * @covers ::render
     */
    public function testRenderWithInvalidModel()
    {
        $this->assertSame('', $this->s->render(new JsonModel([])));
    }

    /**
     * @covers ::__construct
     * @covers ::render
     */
    public function testRender()
    {
        $m = new ViewModel('variables', ['foo' => 'bar']);
        $this->assertSame("bar\n", $this->s->render($m));
    }

    protected function setUp()
    {
        $loader = new \Twig_Loader_Filesystem(__DIR__ . '/../_view');
        $twig = new \Twig_Environment($loader);
        $this->s = new TwigStrategy($twig);
    }
}

{'fraction_non_alphanumeric': 0.17857142857142858, 'fraction_numerical': 0.0010822510822510823, 'mean_word_length': 2.5596919127086006, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 40, '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': '3610369', 'n_tokens_mistral': 892, 'n_tokens_neox': 874, 'n_words': 146}