| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Tests\GeoTimeZone; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use GeoTimeZone\Calculator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use PHPUnit\Runner\Exception; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Tests\AbstractUnitTestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | class CalculatorTest extends AbstractUnitTestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     const DATA_DIRECTORY = "/../../data/"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     protected $calculator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     protected function setUp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |         $this->calculator = new Calculator(__DIR__ . self::DATA_DIRECTORY); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     public function getDataLocalDate() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |         return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |             'Testing Lisbon' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |                 'latitude' => 41.142700, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |                 'longitude' => -8.612150, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |                 'timestamp' => 1458844434, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |                 'expectedTimeZone' => 'Europe/Lisbon', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |                 '$expectedOffset' => 0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |             'Testing Madrid' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |                 'latitude' => 39.452800, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |                 'longitude' => -0.347038, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |                 'timestamp' => 1469387760, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |                 'expectedTimeZone' => 'Europe/Madrid', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |                 '$expectedOffset' => 7200 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |             'Testing Caracas' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |                 'latitude' => 7.811258, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |                 'longitude' => -72.199897, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |                 'timestamp' => 1412482901, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |                 'expectedTimeZone' => 'America/Caracas', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |                 '$expectedOffset' => -16200 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     public function getDataCorrectTimestamp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |             'Testing Lisbon' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |                 'latitude' => 41.142700, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |                 'longitude' => -8.612150, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |                 'timestamp' => 1458844434, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |                 'expectedTimestamp' => 1458844434, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |             'Testing Madrid' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |                 'latitude' => 39.452800, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |                 'longitude' => -0.347038, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |                 'timestamp' => 1469387760, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |                 'expectedTimestamp' => 1469380560, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     public function getDataTimeZoneName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |             'Testing Lisbon' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |                 'latitude' => 41.142700, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |                 'longitude' => -8.612150, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |                 'expectedTimeZone' => 'Europe/Lisbon', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |             'Testing Madrid' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |                 'latitude' => 39.452800, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |                 'longitude' => -0.347038, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |                 'expectedTimeZone' => 'Europe/Madrid', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     public function getNoTimezone() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |             'Testing None Timezone' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |                 'latitude' => -1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |                 'longitude' => -1, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |                 'timestamp' => 0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |                 'expectedException' => "ERROR: TimeZone not found", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     public function getDataWrongLatitude() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |         return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |             'Testing Wrong Latitude' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |                 'latitude' => 10000000, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |                 'longitude' => -8.612150, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |                 'expectedException' => "Invalid latitude: 10000000", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |             'Testing Null Latitude' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |                 'latitude' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |                 'longitude' => -8.612150, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |                 'expectedException' => "Invalid latitude: ", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     public function getDataWrongLongitude() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |         return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |             'Testing Wrong Longitude' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |                 'latitude' => 41.142700, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |                 'longitude' => 10000000, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |                 'expectedException' => "Invalid longitude: 10000000", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |              | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |             'Testing Null Longitude' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |                 'latitude' => 41.142700, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |                 'longitude' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |                 'expectedException' => "Invalid longitude: ", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     public function getDataMaxLatitude() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |         return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |             'Testing Positive Max Latitude' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |                 'latitude' => 90.0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |                 'longitude' => -8.612150, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |                 'adjustedLatitude' => 89.9999, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |                 'expectedException' => "ERROR: TimeZone not found", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |             'Testing Negative Max Latitude' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |                 'latitude' => -90.0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |                 'longitude' => -8.612150, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |                 'adjustedLatitude' => -89.9999, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |                 'expectedException' => "ERROR: TimeZone not found", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |     public function getDataMaxLongitude() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |         return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |             'Testing Positive Max Longitude' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |                 'latitude' => -8.612150, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |                 'longitude' => 180.0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |                 'adjustedLongitude' => 179.9999, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |                 'expectedException' => "ERROR: TimeZone not found", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |             ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |             'Testing Negative Max Longitude' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |                 'latitude' => -8.612150, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |                 'longitude' => -180.0, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |                 'adjustedLongitude' => -179.9999, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |                 'expectedException' => "ERROR: TimeZone not found", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |      * @dataProvider getDataWrongLatitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |      * @param $latitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |      * @param $longitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |      * @param $expectedException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |     public function testGetTimeZoneNameWithWrongLatitude($latitude, $longitude, $expectedException) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |             $this->expectException(\ErrorException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |             $this->expectExceptionMessage($expectedException); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |             $timeZone = $this->calculator->getTimeZoneName($latitude, $longitude); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |         } catch (Exception $error) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |             echo $error->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |      * @dataProvider getDataWrongLongitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |      * @param $latitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |      * @param $longitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |      * @param $expectedException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |     public function testGetTimeZoneNameWithWrongLongitude($latitude, $longitude, $expectedException) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |             $this->expectException(\ErrorException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |             $this->expectExceptionMessage($expectedException); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |             $timeZone = $this->calculator->getTimeZoneName($latitude, $longitude); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         } catch (Exception $error) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |             echo $error->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |      * @dataProvider getDataMaxLatitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |      * @param $latitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |      * @param $longitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |      * @param $adjustedLatitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |      * @param $expectedException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |     public function testGetTimeZoneNameWithMaxLatitude($latitude, $longitude, $adjustedLatitude, $expectedException) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |             $this->expectException(\ErrorException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |             $this->expectExceptionMessage($expectedException); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |             $timeZone = $this->calculator->getTimeZoneName($latitude, $longitude); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |         } catch (Exception $error) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |             echo $error->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |      * @dataProvider getDataMaxLongitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |      * @param $latitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |      * @param $longitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |      * @param $adjustedLongitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |      * @param $expectedException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |     public function testGetTimeZoneNameWithMaxLongitude($latitude, $longitude, $adjustedLongitude, $expectedException) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |             $this->expectException(\ErrorException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |             $this->expectExceptionMessage($expectedException); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |             $timeZone = $this->calculator->getTimeZoneName($latitude, $longitude); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |         } catch (Exception $error) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |             echo $error->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |      * @dataProvider getDataMaxLatitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |      * @param $latitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |      * @param $longitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |      * @param $adjustedLatitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |      * @param $expectedException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |     public function testAdjustLatitudeWithMaxLatitude($latitude, $longitude, $adjustedLatitude, $expectedException) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |         $method = $this->getPrivateMethod(get_class($this->calculator), 'adjustLatitude'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |         $latitudeToTest = $method->invokeArgs($this->calculator, array($latitude)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |         $this->assertEquals($adjustedLatitude, $latitudeToTest); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |      * @dataProvider getDataMaxLongitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |      * @param $latitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |      * @param $longitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |      * @param $adjustedLongitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |      * @param $expectedException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |     public function testAdjustMaxLongitudeWithMaxLongitude($latitude, $longitude, $adjustedLongitude, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |                                                            $expectedException) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |         $method = $this->getPrivateMethod(get_class($this->calculator), 'adjustLongitude'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |         $longitudeToTest = $method->invokeArgs($this->calculator, array($longitude)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |         $this->assertEquals($adjustedLongitude, $longitudeToTest); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |      * @dataProvider getDataLocalDate | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |      * @param $latitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |      * @param $longitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |      * @param $timestamp | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |      * @param $expectedTimeZone | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |      * @param $expectedOffset | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |     public function testGetLocalDate($latitude, $longitude, $timestamp, $expectedTimeZone, $expectedOffset) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |         $localDate = $this->calculator->getLocalDate($latitude, $longitude, $timestamp); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |         $this->assertInstanceOf('DateTime', $localDate); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |         $this->assertEquals( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |             $localDate->getTimezone()->getName(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |             $expectedTimeZone | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |         $this->assertEquals( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |             $localDate->getOffset(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |             $expectedOffset | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |      * @dataProvider getNoTimezone | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |      * @param $latitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |      * @param $longitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |      * @param $timestamp | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |      * @param $expectedException | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 289 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 290 |  |  |     public function testGetLocalDateException($latitude, $longitude, $timestamp, $expectedException) | 
            
                                                                        
                            
            
                                    
            
            
                | 291 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 292 |  |  |         try { | 
            
                                                                        
                            
            
                                    
            
            
                | 293 |  |  |             $this->expectException(\ErrorException::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 294 |  |  |             $this->expectExceptionMessage($expectedException); | 
            
                                                                        
                            
            
                                    
            
            
                | 295 |  |  |             $localDate = $this->calculator->getLocalDate($latitude, $longitude, $timestamp); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 296 |  |  |         } catch (Exception $error) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 297 |  |  |             echo $error->getMessage(); | 
            
                                                                        
                            
            
                                    
            
            
                | 298 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 299 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |      * @dataProvider getDataCorrectTimestamp | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |      * @param $latitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |      * @param $longitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |      * @param $timestamp | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |      * @param $expectedTimestamp | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |     public function testGetCorrectTimestamp($latitude, $longitude, $timestamp, $expectedTimestamp) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |         $correctTimestamp = $this->calculator->getCorrectTimestamp($latitude, $longitude, $timestamp); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |         $this->assertEquals($correctTimestamp, $expectedTimestamp); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |      * @dataProvider getNoTimezone | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |      * @param $latitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |      * @param $longitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |      * @param $timestamp | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |      * @param $expectedException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |     public function testGetCorrectTimestampException($latitude, $longitude, $timestamp, $expectedException) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |             $this->expectException(\ErrorException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |             $this->expectExceptionMessage($expectedException); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |             $correctTimestamp = $this->calculator->getCorrectTimestamp($latitude, $longitude, $timestamp); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |         } catch (Exception $error) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |             echo $error->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |      * @dataProvider getDataTimeZoneName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |      * @param $latitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |      * @param $longitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |      * @param $expectedTimeZone | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |     public function testGetTimeZoneName($latitude, $longitude, $expectedTimeZone) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |             $timeZoneName = $this->calculator->getTimeZoneName($latitude, $longitude); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |             $this->assertEquals($timeZoneName, $expectedTimeZone); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |         } catch (Exception $error) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |             echo $error->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |      * @dataProvider getNoTimezone | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |      * @param $latitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |      * @param $longitude | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |      * @param $timestamp | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |      * @param $expectedException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |     public function testGetTimeZoneNameException($latitude, $longitude, $timestamp, $expectedException) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |             $this->expectException(\ErrorException::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |             $this->expectExceptionMessage($expectedException); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |             $timeZoneName = $this->calculator->getTimeZoneName($latitude, $longitude); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |         } catch (Exception $error) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |             echo $error->getMessage(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 365 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 366 |  |  |  | 
            
                        
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.