RequirementsTest.php in GeoIP API 8.2
File
tests/src/Kernel/RequirementsTest.php
View source
<?php
namespace Drupal\Tests\geoip\Kernel;
use Drupal\KernelTests\KernelTestBase;
class RequirementsTest extends KernelTestBase {
public static $modules = [
'system',
'geoip',
];
protected function setUp() {
parent::setUp();
$this
->installSchema('system', 'file');
}
public function testRequirements() {
module_load_install('geoip');
$requirements = geoip_requirements('install');
$this
->assertTrue(!isset($requirements['geoip_local_database']['severity']));
$requirements = geoip_requirements('runtime');
$this
->assertNotEmpty($requirements['geoip_local_database']['title']);
$this
->assertEquals($requirements['geoip_local_database']['severity'], REQUIREMENT_WARNING);
$file = file_unmanaged_copy(__DIR__ . '/../../fixtures/GeoLite2-Country.mmdb', 'public://GeoLite2-Country.mmdb');
$requirements = geoip_requirements('runtime');
$this
->assertNotEmpty($requirements['geoip_local_database']['title']);
$this
->assertEquals($requirements['geoip_local_database']['severity'], REQUIREMENT_OK);
touch($file);
$this
->assertNotEmpty($requirements['geoip_local_database_age']['title']);
$this
->assertEquals(REQUIREMENT_OK, $requirements['geoip_local_database_age']['severity']);
touch($file, strtotime('2 months ago'));
$requirements = geoip_requirements('runtime');
$this
->assertNotEmpty($requirements['geoip_local_database_age']['title']);
$this
->assertEquals(REQUIREMENT_WARNING, $requirements['geoip_local_database_age']['severity']);
}
}