<commit_before><?php

namespace Tests\GeoTimeZone;

use GeoTimeZone\Calculator;
use PHPUnit\Framework\TestCase;

class CalculatorTest extends TestCase
{
    protected $calculator;
    
    protected function setUp()
    {
        $this->calculator = new Calculator();
    }
    
    public function getDataLocalDate()
    {
        return array(
            'Testing Lisbon' => array(
                'latitude' => 41.142700,
                'longitude' => -8.612150,
                'timestamp' => 1458844434,
                'expectedTimeZone' => 'Europe/Lisbon',
                '$expectedOffset' => 0
            ),
            'Testing Madrid' => array(
                'latitude' => 39.452800,
                'longitude' => -0.347038,
                'timestamp' => 1469387760,
                'expectedTimeZone' => 'Europe/Madrid',
                '$expectedOffset' => 7200
            )
        );
    }
    
    public function getDataCorrectTimestamp()
    {
        return array(
            'Testing Lisbon' => array(
                'latitude' => 41.142700,
                'longitude' => -8.612150,
                'timestamp' => 1458844434,
                'expectedTimestamp' => 1458844434,
            ),
            'Testing Madrid' => array(
                'latitude' => 39.452800,
                'longitude' => -0.347038,
                'timestamp' => 1469387760,
                'expectedTimestamp' => 1469380560,
            )
        );
    }
    
    public function getDataTimeZoneName()
    {
        return array(
            'Testing Lisbon' => array(
                'latitude' => 41.142700,
                'longitude' => -8.612150,
                'expectedTimeZone' => 'Europe/Lisbon',
            ),
            'Testing Madrid' => array(
                'latitude' => 39.452800,
                'longitude' => -0.347038,
                'expectedTimeZone' => 'Europe/Madrid',
            )
        );
    }
    
    public function getDataWrongLatitude()
    {
        return array(
            'Testing Wrong Latitude' => array(
                'latitude' => 10000000,
                'longitude' => -8.612150
            ),
            'Testing Null Latitude' => array(
                'latitude' => null,
                'longitude' => -8.612150
            )
        );
    }
    
    public function getDataWrongLongitude()
    {
        return array(
            'Testing Wrong Longitude' => array(
                'latitude' => 41.142700,
                'longitude' => 10000000,
            
            ),
            'Testing Null Longitude' => array(
                'latitude' => 41.142700,
                'longitude' => null,
            )
        );
    }
    
    public function getDataMaxLatitude()
    {
        return array(
            'Testing Positive Max Latitude' => array(
                'latitude' => 90.0,
                'longitude' => -8.612150
            ),
            'Testing Negative Max Latitude' => array(
                'latitude' => -90.0,
                'longitude' => -8.612150
            )
        );
    }
    
    public function getDataMaxLongitude()
    {
        return array(
            'Testing Positive Max Longitude' => array(
                'latitude' => -8.612150,
                'longitude' => 180.0
            ),
            'Testing Negative Max Longitude' => array(
                'latitude' => -8.612150,
                'longitude' => -180.0
            )
        );
    }
    
    /**
     * @dataProvider getDataWrongLatitude
     * @param $latitude
     * @param $longitude
     */
    public function testGetTimeZoneNameWithWrongLatitude($latitude, $longitude)
    {
        $this->expectExceptionMessage("Invalid latitude: {$latitude}");
        $timeZone = $this->calculator->getTimeZoneName($latitude, $longitude);
        $this->assertEquals($timeZone, "none");
    }
    
    /**
     * @dataProvider getDataWrongLongitude
     * @param $latitude
     * @param $longitude
     */
    public function testGetTimeZoneNameWithWrongLongitude($latitude, $longitude)
    {
        $this->expectExceptionMessage("Invalid longitude: {$longitude}");
        $timeZone = $this->calculator->getTimeZoneName($latitude, $longitude);
        $this->assertEquals($timeZone, "none");
    }

//    /**
//     * @dataProvider getDataMaxLatitude
//     * @param $latitude
//     * @param $longitude
//     */
//    public function testGetTimeZoneNameWithMaxLatitude($latitude, $longitude)
//    {
//        $timeZone = $this->calculator->getTimeZoneName($latitude, $longitude);
//        $this->assertTrue(is_string($timeZone));
//    }
    
    /**
     * @dataProvider getDataLocalDate
     * @param $latitude
     * @param $longitude
     * @param $timestamp
     * @param $expectedTimeZone<commit_msg>Max latitude and longitude cases resolved.<commit_after><?php

namespace Tests\GeoTimeZone;

use GeoTimeZone\Calculator;
use Tests\AbstractUnitTestCase;

class CalculatorTest extends AbstractUnitTestCase
{
    protected $calculator;
    
    protected function setUp()
    {
        $this->calculator = new Calculator();
    }
    
    public function getDataLocalDate()
    {
        return array(
            'Testing Lisbon' => array(
                'latitude' => 41.142700,
                'longitude' => -8.612150,
                'timestamp' => 1458844434,
                'expectedTimeZone' => 'Europe/Lisbon',
                '$expectedOffset' => 0
            ),
            'Testing Madrid' => array(
                'latitude' => 39.452800,
                'longitude' => -0.347038,
                'timestamp' => 1469387760,
                'expectedTimeZone' => 'Europe/Madrid',
                '$expectedOffset' => 7200
            )
        );
    }
    
    public function getDataCorrectTimestamp()
    {
        return array(
            'Testing Lisbon' => array(
                'latitude' => 41.142700,
                'longitude' => -8.612150,
                'timestamp' => 1458844434,
                'expectedTimestamp' => 1458844434,
            ),
            'Testing Madrid' => array(
                'latitude' => 39.452800,
                'longitude' => -0.347038,
                'timestamp' => 1469387760,
                'expectedTimestamp' => 1469380560,
            )
        );
    }
    
    public function getDataTimeZoneName()
    {
        return array(
            'Testing Lisbon' => array(
                'latitude' => 41.142700,
                'longitude' => -8.612150,
                'expectedTimeZone' => 'Europe/Lisbon',
            ),
            'Testing Madrid' => array(
                'latitude' => 39.452800,
                'longitude' => -0.347038,
                'expectedTimeZone' => 'Europe/Madrid',
            )
        );
    }
    
    public function getDataWrongLatitude()
    {
        return array(
            'Testing Wrong Latitude' => array(
                'latitude' => 10000000,
                'longitude' => -8.612150
            ),
            'Testing Null Latitude' => array(
                'latitude' => null,
                'longitude' => -8.612150
            )
        );
    }
    
    public function getDataWrongLongitude()
    {
        return array(
            'Testing Wrong Longitude' => array(
                'latitude' => 41.142700,
                'longitude' => 10000000,
            
            ),
            'Testing Null Longitude' => array(
                'latitude' => 41.142700,
                'longitude' => null,
            )
        );
    }
    
    public function getDataMaxLatitude()
    {
        return array(
            'Testing Positive Max Latitude' => array(
                'latitude' => 90.0,
                'longitude' => -8.612150,
                'adjustedLatitude' => 89.9999
            ),
            'Testing Negative Max Latitude' => array(
                'latitude' => -90.0,
                'longitude' => -8.612150,
                'adjustedLatitude' => -89.9999
            )
        );
    }
    
    public function getDataMaxLongitude()
    {
        return array(
            'Testing Positive Max Longitude' => array(
                'latitude' => -8.612150,
                'longitude' => 180.0,
                'adjustedLongitude' => 179.9999
            ),
            'Testing Negative Max Longitude' => array(
                'latitude' => -8.612150,
                'longitude' => -180.0,
                'adjustedLongitude' => -179.9999
            )
        );
    }
    
    /**
     * @dataProvider getDataWrongLatitude
     * @param $latitude
     * @param $longitude
     */
    public function testGetTimeZoneNameWithWrongLatitude($latitude, $longitude)
    {
        $this->expectExceptionMessage("Invalid latitude: {$latitude}");
        $timeZone = $this->calculator->getTimeZoneName($latitude, $longitude);
        $this->assertEquals($timeZone, "none");
    }
    
    /**
     * @dataProvider getDataWrongLongitude
     * @param $latitude
     * @param $longitude
     */
    public function testGetTimeZoneNameWithWrongLongitude($latitude, $longitude)
    {
        $this->expectExceptionMessage("Invalid longitude: {$longitude}");
        $timeZone = $this->calculator->getTimeZoneName($latitude, $longitude);
        $this->assertEquals($timeZone, "none");
    }

    /**
     * @dataProvider getDataMaxLatitude
     * @param $latitude
     * @param $longitude
     */
    public function testGetTimeZoneNameWithMaxLatitude($latitude, $longitude)
    {
        $timeZone = $this->calculator->getTimeZoneName($latitude, $longitude);
        $this->assertTrue(is_string($timeZone));
    }
    
    /**
     * @dataProvider getDataMaxLatitude
     * @param $latitude
     * @param $longitude
     * @param $adjustedLatitude
     */
    public function testAdjustLatitudeWithMaxLatitude($latitude, $longitude, $adjustedLatitude)
    {
        $method = $this->getPrivateMethod(get_class($this->calculator), 'adjustLatitude');
        $latitudeToTest = $method->invokeArgs($this->calculator, array($latitude));
        $this->assertEquals($adjustedLatitude, $latitudeToTest);
    }
    
    /**
     * @dataProvider getDataMaxLongitude
     * @param $latitude
     * @param $longitude
     * @param $adjustedLongitude
     */
    public function testAdjustLongitudeWithMaxLongitude($latitude, $longitude, $adjustedLongitude)
    {
        $method = $this->getPrivateMethod(get_class($this->calculator), 'adjustLongitude');
        $longitudeToTest = $method->invokeArgs($this->calculator, array($longitude));
        $this->assertEquals($adjustedLongitude, $longitudeToTest);
    }
    
    /**
     * @dataProvider getDataLocalDate
     * @param $latitude
     * @param $longitude
     * @param $timestamp
     * @param $expectedTimeZone
     * @param $expectedOffset
{'fraction_non_alphanumeric': 0.12335086262570348, 'fraction_numerical': 0.04723682996586401, 'mean_word_length': 1.6183574879227054, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 149, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, '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': '1770050', 'n_tokens_mistral': 3468, 'n_tokens_neox': 3008, 'n_words': 552}