<commit_before><?php

namespace Ivory\GoogleMapBundle\Tests\Templating\Helper;

use Ivory\GoogleMapBundle\Templating\Helper;
use Ivory\GoogleMapBundle\Templating\Helper\Base as BaseHelper;
use Ivory\GoogleMapBundle\Templating\Helper\Controls as ControlsHelper;
use Ivory\GoogleMapBundle\Templating\Helper\Overlays as OverlaysHelper;
use Ivory\GoogleMapBundle\Templating\Helper\Layers as LayersHelper;
use Ivory\GoogleMapBundle\Templating\Helper\Events as EventsHelper;
use Ivory\GoogleMapBundle\Templating\Helper\Geometry as GeometryHelper;

use Ivory\GoogleMapBundle\Model;
use Ivory\GoogleMapBundle\Model\Base;
use Ivory\GoogleMapBundle\Model\Controls;
use Ivory\GoogleMapBundle\Model\Overlays;
use Ivory\GoogleMapBundle\Model\Layers;
use Ivory\GoogleMapBundle\Model\Events;
use Ivory\GoogleMapBundle\Model\Geometry;

/**
 * Map helper test
 *
 * @author GeLo <<EMAIL>>
 */
class MapHelperTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var Ivory\GoogleMapBundle\Templating\Helper\MapHelper
     */
    protected static $mapHelper = null;

    /**
     * {@inheritdoc}
     */
    protected function setUp()
    {
        self::$mapHelper = new Helper\MapHelper(
            new BaseHelper\CoordinateHelper(),
            new Helper\MapTypeIdHelper(),
            new ControlsHelper\MapTypeControlHelper(
                new Helper\MapTypeIdHelper(),
                new ControlsHelper\ControlPositionHelper(),
                new ControlsHelper\MapTypeControlStyleHelper()
            ),
            new ControlsHelper\OverviewMapControlHelper(),
            new ControlsHelper\PanControlHelper(
                new ControlsHelper\ControlPositionHelper()
            ),
            new ControlsHelper\RotateControlHelper(
                new ControlsHelper\ControlPositionHelper()
            ),
            new ControlsHelper\ScaleControlHelper(
                new ControlsHelper\ControlPositionHelper(),
                new ControlsHelper\ScaleControlStyleHelper()
            ),
            new ControlsHelper\StreetViewControlHelper(
                new ControlsHelper\ControlPositionHelper()
            ),
            new ControlsHelper\ZoomControlHelper(
                new ControlsHelper\ControlPositionHelper(),
                new ControlsHelper\ZoomControlStyleHelper()
            ),
            new OverlaysHelper\MarkerHelper(
                new BaseHelper\CoordinateHelper(),
                new OverlaysHelper\AnimationHelper(),
                new OverlaysHelper\InfoWindowHelper(
                    new BaseHelper\CoordinateHelper(),
                    new BaseHelper\SizeHelper()
                ),
                new OverlaysHelper\MarkerImageHelper(new BaseHelper\PointHelper(), new BaseHelper\SizeHelper()),
                new OverlaysHelper\MarkerShapeHelper()
            ),
            new BaseHelper\BoundHelper(new BaseHelper\CoordinateHelper()),
            new OverlaysHelper\InfoWindowHelper(
                new BaseHelper\CoordinateHelper(),
                new BaseHelper\SizeHelper()
            ),
            new OverlaysHelper\PolylineHelper(new BaseHelper\CoordinateHelper()),
            new OverlaysHelper\EncodedPolylineHelper(new GeometryHelper\EncodingHelper()),
            new OverlaysHelper\PolygonHelper(new BaseHelper\CoordinateHelper()),
            new OverlaysHelper\RectangleHelper(new BaseHelper\BoundHelper(new BaseHelper\CoordinateHelper())),
            new OverlaysHelper\CircleHelper(new BaseHelper\CoordinateHelper()),
            new OverlaysHelper\GroundOverlayHelper(new BaseHelper\BoundHelper(new BaseHelper\CoordinateHelper())),
            new LayersHelper\KMLLayerHelper(),
            new EventsHelper\EventManagerHelper(new EventsHelper\EventHelper())
        );
    }

    /**
     * Checks the render container method
     */
    public function testRenderContainer()
    {
        $mapTest = new Model\Map();
        $mapTest->setHtmlContainerId('html_container_id');

        $this->assertEquals(self::$mapHelper->renderContainer($mapTest), '<div id="html_container_id" style="width:300px;height:300px;"></div>'.PHP_EOL);
    }

    /**
     * Checks the render stylesheets method
     */
    public function testRenderStylesheets()
    {
        $mapTest = new Model\Map();
        $mapTest->setHtmlContainerId('html_container_id');

        $mapTest->setStylesheetOptions(array(
            'height' => '100px',
            'width' => '200px',
            'option1' => 'value1'
        ));

        $this->assertEquals(self::$mapHelper->renderStylesheets($mapTest),
            '<style type="text/css">'.PHP_EOL.
            '#html_container_id{'.PHP_EOL.
            'width:200px;'.PHP_EOL.
            'height:100px;'.PHP_EOL.
            'option1:value1;'.PHP_EOL.
            '}'.PHP_EOL.
            '</style>'.PHP_EOL
        );
    }

    /**
     * Checks the render javascripts method
     */
    public function testRenderJavascripts()
    {
        $mapTest = new Model\Map();
        $mapTest->setHtmlContainerId('html_container_id');

        $centerTest = new Base\Coordinate(1.1, 2.1, true);
        $mapTest->setCenter($centerTest);

        $mapTest->setMapOption('mapTypeId', 'satellite');
        $mapTest->setMapOption('zoom', 5);
        $mapTest->setLanguage('en');

        $this->assertEquals(self::$mapHelper->renderJavascripts($mapTest),
            '<script type="text/javascript" src="http://maps.google.com/maps/api/js?libraries=geometry&sensor=false&language=en"></script>'.PHP_EOL.
            '<script type="text/javascript">'.PHP_EOL.
            'var '.$mapTest->getJavascriptVariable().' = new google.maps.Map(document.getElementById("html_container_id"), {"mapTypeId":google.maps.MapTypeId.SATELLITE,"zoom":5});'.PHP_EOL.
            $mapTest->getJavascriptVariable().'.setCenter(new google.maps.LatLng(1.1, 2.1, true));'.PHP_EOL.
            'var closable_info_windows = Array();'.PHP_EOL.
            '</script>'.PHP_EOL
        );
    }

    /**
     * Checks the render map method
     */
    public function testRenderMap()
    {
        $mapTest = new Model\Map();
        $mapTest->setHtmlContainerId('html_container_id');

        $mapTest->setMapOption('mapTypeId', 'satellite');
        $mapTest->setMapOption('zoom', 5);
<commit_msg>Fix test suite<commit_after><?php

namespace Ivory\GoogleMapBundle\Tests\Templating\Helper;

use Ivory\GoogleMapBundle\Templating\Helper;
use Ivory\GoogleMapBundle\Templating\Helper\Base as BaseHelper;
use Ivory\GoogleMapBundle\Templating\Helper\Controls as ControlsHelper;
use Ivory\GoogleMapBundle\Templating\Helper\Overlays as OverlaysHelper;
use Ivory\GoogleMapBundle\Templating\Helper\Layers as LayersHelper;
use Ivory\GoogleMapBundle\Templating\Helper\Events as EventsHelper;
use Ivory\GoogleMapBundle\Templating\Helper\Geometry as GeometryHelper;

use Ivory\GoogleMapBundle\Model;
use Ivory\GoogleMapBundle\Model\Base;
use Ivory\GoogleMapBundle\Model\Controls;
use Ivory\GoogleMapBundle\Model\Overlays;
use Ivory\GoogleMapBundle\Model\Layers;
use Ivory\GoogleMapBundle\Model\Events;
use Ivory\GoogleMapBundle\Model\Geometry;

/**
 * Map helper test
 *
 * @author GeLo <<EMAIL>>
 */
class MapHelperTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var Ivory\GoogleMapBundle\Templating\Helper\MapHelper
     */
    protected static $mapHelper = null;

    /**
     * {@inheritdoc}
     */
    protected function setUp()
    {
        self::$mapHelper = new Helper\MapHelper(
            new BaseHelper\CoordinateHelper(),
            new Helper\MapTypeIdHelper(),
            new ControlsHelper\MapTypeControlHelper(
                new Helper\MapTypeIdHelper(),
                new ControlsHelper\ControlPositionHelper(),
                new ControlsHelper\MapTypeControlStyleHelper()
            ),
            new ControlsHelper\OverviewMapControlHelper(),
            new ControlsHelper\PanControlHelper(
                new ControlsHelper\ControlPositionHelper()
            ),
            new ControlsHelper\RotateControlHelper(
                new ControlsHelper\ControlPositionHelper()
            ),
            new ControlsHelper\ScaleControlHelper(
                new ControlsHelper\ControlPositionHelper(),
                new ControlsHelper\ScaleControlStyleHelper()
            ),
            new ControlsHelper\StreetViewControlHelper(
                new ControlsHelper\ControlPositionHelper()
            ),
            new ControlsHelper\ZoomControlHelper(
                new ControlsHelper\ControlPositionHelper(),
                new ControlsHelper\ZoomControlStyleHelper()
            ),
            new OverlaysHelper\MarkerHelper(
                new BaseHelper\CoordinateHelper(),
                new OverlaysHelper\AnimationHelper(),
                new OverlaysHelper\InfoWindowHelper(
                    new BaseHelper\CoordinateHelper(),
                    new BaseHelper\SizeHelper()
                ),
                new OverlaysHelper\MarkerImageHelper(new BaseHelper\PointHelper(), new BaseHelper\SizeHelper()),
                new OverlaysHelper\MarkerShapeHelper()
            ),
            new BaseHelper\BoundHelper(new BaseHelper\CoordinateHelper()),
            new OverlaysHelper\InfoWindowHelper(
                new BaseHelper\CoordinateHelper(),
                new BaseHelper\SizeHelper()
            ),
            new OverlaysHelper\PolylineHelper(new BaseHelper\CoordinateHelper()),
            new OverlaysHelper\EncodedPolylineHelper(new GeometryHelper\EncodingHelper()),
            new OverlaysHelper\PolygonHelper(new BaseHelper\CoordinateHelper()),
            new OverlaysHelper\RectangleHelper(new BaseHelper\BoundHelper(new BaseHelper\CoordinateHelper())),
            new OverlaysHelper\CircleHelper(new BaseHelper\CoordinateHelper()),
            new OverlaysHelper\GroundOverlayHelper(new BaseHelper\BoundHelper(new BaseHelper\CoordinateHelper())),
            new LayersHelper\KMLLayerHelper(),
            new EventsHelper\EventManagerHelper(new EventsHelper\EventHelper())
        );
    }

    /**
     * Checks the render container method
     */
    public function testRenderContainer()
    {
        $mapTest = new Model\Map();
        $mapTest->setHtmlContainerId('html_container_id');

        $this->assertEquals(self::$mapHelper->renderContainer($mapTest), '<div id="html_container_id" style="width:300px;height:300px;"></div>'.PHP_EOL);
    }

    /**
     * Checks the render stylesheets method
     */
    public function testRenderStylesheets()
    {
        $mapTest = new Model\Map();
        $mapTest->setHtmlContainerId('html_container_id');

        $mapTest->setStylesheetOptions(array(
            'height' => '100px',
            'width' => '200px',
            'option1' => 'value1'
        ));

        $this->assertEquals(self::$mapHelper->renderStylesheets($mapTest),
            '<style type="text/css">'.PHP_EOL.
            '#html_container_id{'.PHP_EOL.
            'width:200px;'.PHP_EOL.
            'height:100px;'.PHP_EOL.
            'option1:value1;'.PHP_EOL.
            '}'.PHP_EOL.
            '</style>'.PHP_EOL
        );
    }

    /**
     * Checks the render javascripts method
     */
    public function testRenderJavascripts()
    {
        $mapTest = new Model\Map();
        $mapTest->setHtmlContainerId('html_container_id');

        $centerTest = new Base\Coordinate(1.1, 2.1, true);
        $mapTest->setCenter($centerTest);

        $mapTest->setMapOption('mapTypeId', 'satellite');
        $mapTest->setMapOption('zoom', 5);
        $mapTest->setLanguage('en');

        $this->assertEquals(self::$mapHelper->renderJavascripts($mapTest),
            '<script type="text/javascript" src="http://maps.google.com/maps/api/js?language=en&amp;sensor=false"></script>'.PHP_EOL.
            '<script type="text/javascript">'.PHP_EOL.
            'var '.$mapTest->getJavascriptVariable().' = new google.maps.Map(document.getElementById("html_container_id"), {"mapTypeId":google.maps.MapTypeId.SATELLITE,"zoom":5});'.PHP_EOL.
            $mapTest->getJavascriptVariable().'.setCenter(new google.maps.LatLng(1.1, 2.1, true));'.PHP_EOL.
            'var closable_info_windows = Array();'.PHP_EOL.
            '</script>'.PHP_EOL
        );
    }

    /**
     * Checks the render map method
     */
    public function testRenderMap()
    {
        $mapTest = new Model\Map();
        $mapTest->setHtmlContainerId('html_container_id');

        $mapTest->setMapOption('mapTypeId', 'satellite');
        $mapTest->setMapOption('zoom', 5);

{'fraction_non_alphanumeric': 0.11367262284620294, 'fraction_numerical': 0.005264837268666241, 'mean_word_length': 2.6202714409471555, 'pattern_counts': {'":': 4, '<': 25, '<?xml version=': 0, '>': 67, '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': '7307878', 'n_tokens_mistral': 3544, 'n_tokens_neox': 3401, 'n_words': 520}