source: src/webservice/tests/IpGeoLocatorTest.php@ 519df6e

Last change on this file since 519df6e was db38696, checked in by Joachim Langenbach <joachim.langenbach@…>, 11 years ago
  • Added Location class, to store a city
  • Property mode set to 100644
File size: 2.3 KB
Line 
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";
22require($file);
23require_once($testconfig["webserviceDirectory"] ."/inc/envsetup.php");
24
25class IpGeoLocatorTest extends PHPUnit_Framework_TestCase
26{
27 /**
28 * @dataProvider testIpGeoLocator_data
29 */
30 public function testIpGeoLocator($ip, $result){
31 $errorMessage = "";
32 $location = \SiWeather\Webservice\IpGeoLocator::locate($ip, $errorMessage);
33
34 $this->assertInternalType("object", $location, $errorMessage);
35 $this->assertTrue(empty($errorMessagE));
36
37 $this->assertEquals($location->city(), $result->city());
38 $this->assertEquals($location->zipCode(), $result->zipCode());
39 $this->assertEquals($location->regionName(), $result->regionName());
40 $this->assertEquals($location->regionCode(), $result->regionCode());
41 $this->assertEquals($location->countryName(), $result->countryName());
42 $this->assertEquals($location->countryCode(), $result->countryCode());
43 $this->assertEquals($location->latitude(), $result->latitude());
44 $this->assertEquals($location->longitude(), $result->longitude());
45 $this->assertEquals($location->locationWkt(), $result->locationWkt());
46 }
47
48 public function testIpGeoLocator_data(){
49 $result = array();
50 $result[] = array("5.9.73.171", new \SiWeather\Webservice\Location("", "", "", "", "Germany", "DE", 51, 9, ""));
51 $result[] = array("173.194.113.168", new \SiWeather\Webservice\Location("Mountain View", "94043", "California", "CA", "United States", "US", 37.419, -122.058));
52 return $result;
53 }
54}
55?>
Note: See TracBrowser for help on using the repository browser.