<commit_before><?php
namespace CsvMigrations\Test\TestCase\FieldHandlers\Renderer;

use CsvMigrations\FieldHandlers\Renderer\ListRenderer;
use PHPUnit_Framework_TestCase;

class ListRendererTest extends PHPUnit_Framework_TestCase
{
    protected $renderer;

    protected function setUp()
    {
        $this->renderer = new ListRenderer();
    }

    public function testInterface()
    {
        $implementedInterfaces = array_keys(class_implements($this->renderer));
        $this->assertTrue(in_array('CsvMigrations\FieldHandlers\Renderer\RendererInterface', $implementedInterfaces), "RendererInterface is not implemented");
    }

    public function basicValues()
    {
        return [
            ['text', 'text', 'Text'],
            ['<p>HTML</p>', 'HTML', 'HTML'],
            ['<script>alert("hello");</script>', 'alert(&#34;hello&#34;);', 'JavaScript'],
        ];
    }

    /**
     * @dataProvider basicValues
     */
    public function testRenderValueBasic($value, $expected, $description)
    {
        $result = $this->renderer->renderValue($value);
        $this->assertEquals($expected, $result, "Value rendering is broken for: $description");
    }

    public function testRenderValueNotFound()
    {
        $result = $this->renderer->renderValue('text', ['listItems' => ['foo' => 'Foo']]);
        $expected = sprintf($this->renderer::VALUE_NOT_FOUND_HTML, 'text');
        $this->assertEquals($expected, $result, "Value rendering is broken for missing text value");

        $result = $this->renderer->renderValue('<p>HTML</p>', ['listItems' => ['foo' => 'Foo']]);
        $expected = sprintf($this->renderer::VALUE_NOT_FOUND_HTML, 'HTML');
        $this->assertEquals($expected, $result, "Value rendering is broken for missing HTML value");
    }

    public function testRenderValue()
    {
        $listItems = [<commit_msg>Fixing T_PAAMAYIM_NEKUDOTAYIM parser errors for PHP 5 (task #3809)<commit_after><?php
namespace CsvMigrations\Test\TestCase\FieldHandlers\Renderer;

use CsvMigrations\FieldHandlers\Renderer\ListRenderer;
use PHPUnit_Framework_TestCase;

class ListRendererTest extends PHPUnit_Framework_TestCase
{
    protected $renderer;

    protected function setUp()
    {
        $this->renderer = new ListRenderer();
    }

    public function testInterface()
    {
        $implementedInterfaces = array_keys(class_implements($this->renderer));
        $this->assertTrue(in_array('CsvMigrations\FieldHandlers\Renderer\RendererInterface', $implementedInterfaces), "RendererInterface is not implemented");
    }

    public function basicValues()
    {
        return [
            ['text', 'text', 'Text'],
            ['<p>HTML</p>', 'HTML', 'HTML'],
            ['<script>alert("hello");</script>', 'alert(&#34;hello&#34;);', 'JavaScript'],
        ];
    }

    /**
     * @dataProvider basicValues
     */
    public function testRenderValueBasic($value, $expected, $description)
    {
        $result = $this->renderer->renderValue($value);
        $this->assertEquals($expected, $result, "Value rendering is broken for: $description");
    }

    public function testRenderValueNotFound()
    {
        $result = $this->renderer->renderValue('text', ['listItems' => ['foo' => 'Foo']]);
        $expected = sprintf(ListRenderer::VALUE_NOT_FOUND_HTML, 'text');
        $this->assertEquals($expected, $result, "Value rendering is broken for missing text value");

        $result = $this->renderer->renderValue('<p>HTML</p>', ['listItems' => ['foo' => 'Foo']]);
        $expected = sprintf(ListRenderer::VALUE_NOT_FOUND_HTML, 'HTML');
        $this->assertEquals($expected, $result, "Value rendering is broken for missing HTML value");
    }

    public function testRenderValue()
    {
        $listItems = [
{'fraction_non_alphanumeric': 0.15099866844207724, 'fraction_numerical': 0.0034620505992010654, 'mean_word_length': 3.6085889570552148, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 49, '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': '414732', 'n_tokens_mistral': 1060, 'n_tokens_neox': 1057, 'n_words': 214}