Remove alternatives for deprecated methods
This commit is contained in:
parent
c3abe8ac65
commit
49aed6f6ca
|
@ -177,7 +177,7 @@ class WC_Geolocation {
|
|||
* @return string
|
||||
*/
|
||||
public static function get_local_database_path( $deprecated = '2' ) {
|
||||
wc_deprecated_function( 'WC_Geolocation::get_local_database_path', '3.9.0', 'WC_Integration_MaxMind_Database_Service::get_database_path' );
|
||||
wc_deprecated_function( 'WC_Geolocation::get_local_database_path', '3.9.0' );
|
||||
$integration = wc()->integrations->get_integration( 'maxmind_geolocation' );
|
||||
return $integration->get_database_service()->get_database_path();
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ class WC_Geolocation {
|
|||
* Extract files with PharData. Tool built into PHP since 5.3.
|
||||
*/
|
||||
public static function update_database() {
|
||||
wc_deprecated_function( 'WC_Geolocation::update_database', '3.9.0', 'WC_Integration_MaxMind_Geolocation::update_database' );
|
||||
wc_deprecated_function( 'WC_Geolocation::update_database', '3.9.0' );
|
||||
$integration = wc()->integrations->get_integration( 'maxmind_geolocation' );
|
||||
$integration->update_database();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/**
|
||||
* Class Functions.
|
||||
*
|
||||
* @package WooCommerce\Tests\Geolocation
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class WC_Tests_Integrations
|
||||
*/
|
||||
class WC_Tests_Geolite_Integration extends WC_Unit_Test_Case {
|
||||
|
||||
/**
|
||||
* Test get country ISO.
|
||||
*
|
||||
* @requires PHP 5.4
|
||||
*/
|
||||
public function test_get_country_iso() {
|
||||
require_once dirname( WC_PLUGIN_FILE ) . '/includes/class-wc-geolite-integration.php';
|
||||
|
||||
$integration = WC()->integrations->get_integration( 'maxmind_geolocation' );
|
||||
$integration->update_database();
|
||||
|
||||
// Download GeoLite2 database.
|
||||
WC_Geolocation::update_database();
|
||||
|
||||
// OpenDNS IP address.
|
||||
$ipv4 = '208.67.220.220';
|
||||
$ipv6 = '2620:0:ccc::2';
|
||||
|
||||
// Init GeoLite.
|
||||
$geolite = new WC_Geolite_Integration( WC_Geolocation::get_local_database_path() );
|
||||
|
||||
// Check for IPv4.
|
||||
$this->assertEquals( 'US', $geolite->get_country_iso( $ipv4 ) );
|
||||
|
||||
// Check for IPv6.
|
||||
$this->assertEquals( 'US', $geolite->get_country_iso( $ipv6 ) );
|
||||
|
||||
// Check for non-valid IP.
|
||||
$this->assertEquals( '', $geolite->get_country_iso( 'foobar' ) );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue