You are here

public function ip2countryTestCase::testDbDownload in IP-based Determination of a Visitor's Country 7

Same name and namespace in other branches
  1. 6 ip2country.test \ip2countryTestCase::testDBDownload()

Tests DB download.

File

tests/ip2country.test, line 284
Tests suite for the ip2country module.

Class

ip2countryTestCase
Tests operations of the IP to Country module.

Code

public function testDbDownload() {
  ip2country_empty_database();
  $this
    ->assertTrue(ip2country_get_count() == 0, t('Database is Empty.'));

  // Choose a random RIR.
  $rir = array_rand(array(
    //    'afrinic' => 'AFRINIC', // Don't use AFRINIC because it's incomplete.
    'arin' => 'ARIN',
    'apnic' => 'APNIC',
    'lacnic' => 'LACNIC',
    'ripe' => 'RIPE',
  ));
  ip2country_update_database($rir);
  $this
    ->assertTrue(($count = ip2country_get_count()) != 0, t('Database has been updated from %rir with @rows rows.', array(
    '%rir' => strtoupper($rir),
    '@rows' => $count,
  )));
  ip2country_empty_database();
  $this
    ->assertTrue(ip2country_get_count() == 0, t('Database is Empty.'));
}