Skip to content

Commit

Permalink
Added IPv6 BIN for testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
ip2location committed Dec 1, 2020
1 parent cfb389c commit 8141a1c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
Binary file modified databases/IP2LOCATION-LITE-DB1.BIN
Binary file not shown.
Binary file added databases/IP2LOCATION-LITE-DB1.IPV6.BIN
Binary file not shown.
38 changes: 34 additions & 4 deletions tests/DatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function testInvalidDatabase() {
}
}

public function testCountryCode() {
public function testIpv4CountryCode() {
$db = new \IP2Location\Database('./databases/IP2LOCATION-LITE-DB1.BIN', \IP2Location\Database::FILE_IO);

$records = $db->lookup('8.8.8.8', \IP2Location\Database::ALL);
Expand All @@ -28,22 +28,52 @@ public function testCountryCode() {
);
}

public function testCountryName() {
public function testIpv4CountryName() {
$db = new \IP2Location\Database('./databases/IP2LOCATION-LITE-DB1.BIN', \IP2Location\Database::FILE_IO);

$records = $db->lookup('8.8.8.8', \IP2Location\Database::ALL);

$this->assertEquals(
'United States',
'United States of America',
$records['countryName'],
);
}

public function testUnsupportedField() {
public function testIpv4UnsupportedField() {
$db = new \IP2Location\Database('./databases/IP2LOCATION-LITE-DB1.BIN', \IP2Location\Database::FILE_IO);

$records = $db->lookup('8.8.8.8', \IP2Location\Database::ALL);

$this->assertStringContainsString('unavailable', $records['cityName']);
}

public function testIpv6CountryCode() {
$db = new \IP2Location\Database('./databases/IP2LOCATION-LITE-DB1.IPV6.BIN', \IP2Location\Database::FILE_IO);

$records = $db->lookup('2001:4860:4860::8888', \IP2Location\Database::ALL);

$this->assertEquals(
'US',
$records['countryCode'],
);
}

public function testIpv6CountryName() {
$db = new \IP2Location\Database('./databases/IP2LOCATION-LITE-DB1.IPV6.BIN', \IP2Location\Database::FILE_IO);

$records = $db->lookup('2001:4860:4860::8888', \IP2Location\Database::ALL);

$this->assertEquals(
'United States of America',
$records['countryName'],
);
}

public function testIpv6UnsupportedField() {
$db = new \IP2Location\Database('./databases/IP2LOCATION-LITE-DB1.IPV6.BIN', \IP2Location\Database::FILE_IO);

$records = $db->lookup('2001:4860:4860::8888', \IP2Location\Database::ALL);

$this->assertStringContainsString('unavailable', $records['cityName']);
}
}

0 comments on commit 8141a1c

Please sign in to comment.