| [69c8290] | 1 | <?php
|
|---|
| 2 | /*
|
|---|
| 3 | Copyright (C) 2015 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
|
|---|
| 4 |
|
|---|
| 5 | This library is free software; you can redistribute it and/or
|
|---|
| 6 | modify it under the terms of the GNU Lesser General Public
|
|---|
| 7 | License as published by the Free Software Foundation; either
|
|---|
| 8 | version 2.1 of the License, or (at your option) any later version.
|
|---|
| 9 |
|
|---|
| 10 | This library is distributed in the hope that it will be useful,
|
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 13 | Lesser General Public License for more details.
|
|---|
| 14 |
|
|---|
| 15 | You should have received a copy of the GNU Lesser General Public
|
|---|
| 16 | License along with this library; if not, write to the Free Software
|
|---|
| 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|---|
| 18 | MA 02110-1301 USA.
|
|---|
| 19 | */
|
|---|
| 20 |
|
|---|
| 21 | $file = __DIR__ ."/testconfig/testconfig.php";
|
|---|
| 22 | require($file);
|
|---|
| 23 | require_once($testconfig["webserviceDirectory"] ."/inc/envsetup.php");
|
|---|
| 24 |
|
|---|
| 25 | class GeoLocatorTest extends PHPUnit_Framework_TestCase
|
|---|
| 26 | {
|
|---|
| 27 | public function testConfigured(){
|
|---|
| 28 | $this->assertTrue(\SiWeather\Webservice\GeoLocator::configured());
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | /**
|
|---|
| 32 | * @dataProvider testLocations_data
|
|---|
| 33 | */
|
|---|
| 34 | public function testLocations($latiude, $longitude, $radius, $results){
|
|---|
| 35 | $errorMessage = "";
|
|---|
| 36 | $locations = \SiWeather\Webservice\GeoLocator::locations($latiude, $longitude, $radius, $errorMessage);
|
|---|
| 37 |
|
|---|
| 38 | $this->assertInternalType("array", $locations, $errorMessage);
|
|---|
| 39 | $this->assertTrue(empty($errorMessage));
|
|---|
| 40 |
|
|---|
| 41 | $this->assertEquals(count($locations), count($results));
|
|---|
| 42 |
|
|---|
| 43 | for($i = 0; $i < count($locations); $i++){
|
|---|
| 44 | $this->assertEquals($locations[$i]->city(), $results[$i]->city());
|
|---|
| 45 | $this->assertEquals($locations[$i]->postalCode(), $results[$i]->postalCode());
|
|---|
| 46 | $this->assertEquals($locations[$i]->regionName(), $results[$i]->regionName());
|
|---|
| 47 | $this->assertEquals($locations[$i]->regionCode(), $results[$i]->regionCode());
|
|---|
| 48 | $this->assertEquals($locations[$i]->countryName(), $results[$i]->countryName());
|
|---|
| 49 | $this->assertEquals($locations[$i]->countryCode(), $results[$i]->countryCode());
|
|---|
| 50 | $this->assertEquals($locations[$i]->latitude(), $results[$i]->latitude());
|
|---|
| 51 | $this->assertEquals($locations[$i]->longitude(), $results[$i]->longitude());
|
|---|
| 52 | $this->assertEquals($locations[$i]->locationWkt(), $results[$i]->locationWkt());
|
|---|
| 53 | $this->assertEquals($locations[$i]->timeZone(), $results[$i]->timeZone());
|
|---|
| 54 | }
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | public function testLocations_data(){
|
|---|
| 58 | $radius = 5;
|
|---|
| 59 | $result = array();
|
|---|
| 60 | $result[] = array
|
|---|
| 61 | (
|
|---|
| 62 | 51.828056,
|
|---|
| 63 | 10.2825,
|
|---|
| 64 | $radius,
|
|---|
| 65 | array
|
|---|
| 66 | (
|
|---|
| 67 | new \SiWeather\Webservice\Location("Wildemann", "", "Niedersachsen", "06", "Deutschland", "DE", 51.8281, 10.28152, "Europe/Berlin"),
|
|---|
| 68 | new \SiWeather\Webservice\Location("Bad Grund", "", "Niedersachsen", "06", "Deutschland", "DE", 51.81021, 10.23694, "Europe/Berlin"),
|
|---|
| 69 | new \SiWeather\Webservice\Location("Zellerfeld", "", "Niedersachsen", "06", "Deutschland", "DE", 51.81846, 10.33532, "Europe/Berlin"),
|
|---|
| 70 | new \SiWeather\Webservice\Location("Clausthal-Zellerfeld", "", "Niedersachsen", "06", "Deutschland", "DE", 51.80949, 10.33821, "Europe/Berlin"),
|
|---|
| 71 | new \SiWeather\Webservice\Location("Clausthal", "", "Niedersachsen", "06", "Deutschland", "DE", 51.80441, 10.33384, "Europe/Berlin"),
|
|---|
| 72 | new \SiWeather\Webservice\Location("Hahnenklee-Bockswiese", "", "Niedersachsen", "06", "Deutschland", "DE", 51.85487, 10.33178, "Europe/Berlin"),
|
|---|
| 73 | new \SiWeather\Webservice\Location("Lautenthal", "", "Niedersachsen", "06", "Deutschland", "DE", 51.86934, 10.28741, "Europe/Berlin"),
|
|---|
| 74 | new \SiWeather\Webservice\Location("Laubhütte", "", "Niedersachsen", "06", "Deutschland", "DE", 51.79609, 10.23479, "Europe/Berlin"),
|
|---|
| 75 | )
|
|---|
| 76 | );
|
|---|
| 77 | return $result;
|
|---|
| 78 | }
|
|---|
| 79 | }
|
|---|
| 80 | ?>
|
|---|