You are here

function ip2countryTestCase::testDBDownload in IP-based Determination of a Visitor's Country 6

Same name and namespace in other branches
  1. 7 tests/ip2country.test \ip2countryTestCase::testDbDownload()

Tests DB download

File

./ip2country.test, line 306
Tests suite for the ip2country module.

Class

ip2countryTestCase
Need 1 class for unit tests, 1 class for functional tests 1 function for DB tests because filling takes so long

Code

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.'));
}