<commit_before><?php
/**
 * Tests for the Phighchart\Options\Line class
 */

namespace Phighchart\Test\Renderer;

use Phighchart\Chart;
use Phighchart\Options\Container as OptionsContainer;
use Phighchart\Options\ExtendedContainer as ExtendedOptionsContainer;
use Phighchart\Data;
use Phighchart\Renderer\Line;

class LineTest extends \PHPUnit_Framework_TestCase
{
    public function testLineImplementsInterface()
    {
        $line = new Line();
        $this->assertInstanceOf('Phighchart\Renderer\RendererInterface', $line);
    }

    public function testRender()
    {
        $extOptions = new ExtendedOptionsContainer();
        $extOptions->setStickyColour('apples', '#629632');
        $extOptions->setStickyColour('oranges', '#CD3700');

        $options = new OptionsContainer('chart');
        $options->setRenderTo('chart_example_59');
        $options->setMarginRight(130);
        $options->setMarginBottom(25);

        $titleOptions = new OptionsContainer('title');
        $titleOptions->setText('Monthly Details');
        $titleOptions->setX(-20);

        $data = new Data();
        $data->addSeries('Apples', array(
            '2012-05-01' => 12,
            '2012-05-02' => 3,
            '2012-05-03' => 33
        ))
        ->addSeries('Oranges', array(
            '2012-05-01' => 32,
            '2012-05-02' => 36,
            '2012-05-03' => 18
        ));

        // put it all together
        $chart  = new Chart();
        $chart->addOptions($options);
        $chart->addOptions($titleOptions);
        $chart->addOptions($extOptions);
        $chart->setData($data);
        $chart->setRenderer(new Line());

        // test the full expected output
        $this->assertSame(
            'var chart_example_59; chart_example_59 = new Highcharts.Chart({"chart":{"renderTo":"chart_example_59","marginRight":130,"marginBottom":25,"type":"line"},"title":{"text":"Monthly Details","x":-20},"xAxis":{"categories":["2012-05-01","2012-05-02","2012-05-03"]},"series":[{"name":"Apples","data":[12,3,33],"color":"#629632"},{"name":"Oranges","data":[32,36,18],"color":"#CD3700"}]});',
            $chart->render()
        );
        $this->assertSame('<div id="chart_example_59"></div>', $chart->renderContainer());
    }

    public function testRenderWithoutExtendedOptions()
    {
        $options = new OptionsContainer('chart');
        $options->setRenderTo('chart_example_59');
        $options->setMarginRight(130);
        $options->setMarginBottom(25);

        $titleOptions = new OptionsContainer('title');
        $titleOptions->setText('Monthly Details');
        $titleOptions->setX(-20);

        $data = new Data();
        $data->addSeries('Apples', array(
            '2012-05-01' => 12,
            '2012-05-02' => 3,
            '2012-05-03' => 33
        ))
        ->addSeries('Oranges', array(
            '2012-05-01' => 32,
            '2012-05-02' => 36,
            '2012-05-03' => 18
        ));

        // put it all together
        $chart  = new Chart();
        $chart->addOptions($options);
        $chart->addOptions($titleOptions);
        $chart->setData($data);
        $chart->setRenderer(new Line());

        // test the full expected output
        $this->assertSame(
            'var chart_example_59; chart_example_59 = new Highcharts.Chart({"chart":{"renderTo":"chart_example_59","marginRight":130,"marginBottom":25,"type":"line"},"title":{"text":"Monthly Details","x":-20},"xAxis":{"categories":["2012-05-01","2012-05-02","2012-05-03"]},"series":[{"name":"Apples","data":[12,3,33]},{"name":"Oranges","data":[32,36,18]}]});',
            $chart->render()
        );
        $this->assertSame('<div id="chart_example_59"></div>', $chart->renderContainer());
    }
}<commit_msg>updated the Line renderer tests to include tests with the datetime format for xAxis<commit_after><?php
/**
 * Tests for the Phighchart\Options\Line class
 */

namespace Phighchart\Test\Renderer;

use Phighchart\Chart;
use Phighchart\Options\Container as OptionsContainer;
use Phighchart\Options\ExtendedContainer as ExtendedOptionsContainer;
use Phighchart\Format\Datetime as DatetimeFormat;
use Phighchart\Data;
use Phighchart\Renderer\Line;

class LineTest extends \PHPUnit_Framework_TestCase
{
    public function testLineImplementsInterface()
    {
        $line = new Line();
        $this->assertInstanceOf('Phighchart\Renderer\RendererInterface', $line);
    }

    public function testRender()
    {
        $extOptions = new ExtendedOptionsContainer();
        $extOptions->setStickyColour('apples', '#629632');
        $extOptions->setStickyColour('oranges', '#CD3700');

        $options = new OptionsContainer('chart');
        $options->setRenderTo('chart_example_59');
        $options->setMarginRight(130);
        $options->setMarginBottom(25);

        $titleOptions = new OptionsContainer('title');
        $titleOptions->setText('Monthly Details');
        $titleOptions->setX(-20);

        $data = new Data();
        $data->addSeries('Apples', array(
            '2012-05-01' => 12,
            '2012-05-02' => 3,
            '2012-05-03' => 33
        ))
        ->addSeries('Oranges', array(
            '2012-05-01' => 32,
            '2012-05-02' => 36,
            '2012-05-03' => 18
        ));

        // put it all together
        $chart  = new Chart();
        $chart->addOptions($options);
        $chart->addOptions($titleOptions);
        $chart->addOptions($extOptions);
        $chart->setData($data);
        $chart->setRenderer(new Line());

        // test the full expected output
        $this->assertSame(
            'var chart_example_59; chart_example_59 = new Highcharts.Chart({"chart":{"renderTo":"chart_example_59","marginRight":130,"marginBottom":25,"type":"line"},"title":{"text":"Monthly Details","x":-20},"xAxis":{"categories":["2012-05-01","2012-05-02","2012-05-03"]},"series":[{"name":"Apples","data":[12,3,33],"color":"#629632"},{"name":"Oranges","data":[32,36,18],"color":"#CD3700"}]});',
            $chart->render()
        );
        $this->assertSame('<div id="chart_example_59"></div>', $chart->renderContainer());
    }

    public function testRenderWithoutExtendedOptions()
    {
        $options = new OptionsContainer('chart');
        $options->setRenderTo('chart_example_59');
        $options->setMarginRight(130);
        $options->setMarginBottom(25);

        $titleOptions = new OptionsContainer('title');
        $titleOptions->setText('Monthly Details');
        $titleOptions->setX(-20);

        $data = new Data();
        $data->addSeries('Apples', array(
            '2012-05-01' => 12,
            '2012-05-02' => 3,
            '2012-05-03' => 33
        ))
        ->addSeries('Oranges', array(
            '2012-05-01' => 32,
            '2012-05-02' => 36,
            '2012-05-03' => 18
        ));

        // put it all together
        $chart  = new Chart();
        $chart->addOptions($options);
        $chart->addOptions($titleOptions);
        $chart->setData($data);
        $chart->setRenderer(new Line());

        // test the full expected output
        $this->assertSame(
            'var chart_example_59; chart_example_59 = new Highcharts.Chart({"chart":{"renderTo":"chart_example_59","marginRight":130,"marginBottom":25,"type":"line"},"title":{"text":"Monthly Details","x":-20},"xAxis":{"categories":["2012-05-01","2012-05-02","2012-05-03"]},"series":[{"name":"Apples","data":[12,3,33]},{"name":"Oranges","data":[32,36,18]}]});',
            $chart->render()
        );
        $this->assertSame('<div id="chart_example_59"></div>', $chart->renderContainer());
    }

    public function testRenderWithStandardDateTimeFormat()
    {
        $options = new OptionsContainer('chart');
        $options->setRenderTo('chart_example_59');
        $options->setMarginRight(130);
        $options->setMarginBottom(25);

        $titleOptions = new OptionsContainer('title');
        $titleOptions->setText('Monthly Details');
        $titleOptions->setX(-20);

        $data = new Data();
        $data->addSeries('Apples', array(
            '2012-05-01' => 12,
            '2012-05-02' => 3,
            '2012-05-03' => 33
        ))
        ->addSeries('Oranges', array(
            '2012-05-01' => 32,
            '2012-05-02' => 36,
            '2012-05-03' => 18
        ));

        // put it all together
        $chart  = new Chart();
        $chart->addOptions($options);
        $chart->addOptions($titleOptions);
        $chart->setData($data);
        $chart->setFormat(new DatetimeFormat());
        $chart->setRenderer(new Line());

        // test the full expected output
        $this->assertSame(
            'var chart_example_59; chart_example_59 = new Highcharts.Chart({"chart":{"renderTo":"chart_example_59","marginRight":130,"marginBottom":25,"type":"line"},"title":{"text":"Monthly Details","x":-20},"xAxis":{"type":"datetime"},"series":[{"name":"Apples","data":[[Date.UTC(2012,4,01,00,00,00),12],[Date.UTC(2012,4,02,00,00,00),3],[Date.UTC(2012,4,03,00,00,00),33]]},{"name":"Oranges","data":[[Date.UTC(2012,4,01,00,00,00),32],[Date.UTC(2012,4,02,00,00,00),36],[Date.UTC(2012,4,03,00,00,00),18]]}]});',
            $chart->render()
        );
        $this->assertSame('<div id="chart_example_59"></div>', $chart->renderContainer());
    }

    public function testRenderWithCustomDateTimeFormat()
    {
        $options = new OptionsContainer('chart');
        $options->setRenderTo('chart_example_59');
        $options->setMarginRight(130);
        $options->setMarginBottom(25);

        $titleOptions = new OptionsContainer('title');
        $titleOptions->setText('Monthly Details');
        $titleOptions->setX(-20);

        $data = new Data();
        $data->addSeries('Apples', array(
            '1st May, 2012 00:00:00' => 12, //non standard date time format
            '2nd May, 2012 00:00:00' => 3,
            '3rd May, 2012 00:00:00' => 33
        ))
        ->addSeries('Oranges', array(
            '1st May, 2012 00:00:00' => 32,
            '2nd May, 2012 00:00:00' => 36,
            '3rd May, 2012 00:00:00' => 18
        ));

        $format = new DatetimeFormat();
        $format->setDateTimeFormat('jS F, Y H:i:s');

        // put it all together
        $chart  = new Chart();
        $chart->addOptions($options);
        $chart->addOptions($titleOptions);
        $chart->setData($data);
        $chart->setFormat($format);
        $chart->setRenderer(new Line());

        // test the full expected output
        $this->assertSame(
            'var chart_example_59; chart_example_59 = new Highcharts.Chart({"chart":{"renderTo":"chart_example_59","marginRight":130,"marginBottom":25,"type":"line"},"title":{"text":"Monthly Details","x":-20},"xAxis":{"type":"datetime"},"series":[{"name":"Apples","data":[[Date.UTC(2012,4,01,00,00,00),12],[Date.UTC(2012,4,02,00,00,00),3],[Date.UTC(2012,4,03,00,00,00),33]]},{"name":"Oranges","data":[[Date.UTC(2012,4,01,00,00,00),32],[Date.UTC(2012,4,02,00,00,00),36],[Date.UTC(2012,4,03,00,00,00),18]]}]});',
            $chart->render()
        );
        $this->assertSame('<div id="chart_example_59"></div>', $chart->renderContainer());
    }
}
{'fraction_non_alphanumeric': 0.19343881290783946, 'fraction_numerical': 0.0781263967104675, 'mean_word_length': 2.9673758865248225, 'pattern_counts': {'":': 94, '<': 17, '<?xml version=': 0, '>': 152, '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': '5428473', 'n_tokens_mistral': 3995, 'n_tokens_neox': 3386, 'n_words': 506}