
Update Torann/GeoIP package from 0.2 to 1.0.0 which is being used to show country code in phone nuber in various forms.
55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Torann\GeoIP\Tests;
|
|
|
|
use Mockery;
|
|
use PHPUnit_Framework_TestCase;
|
|
|
|
class TestCase extends PHPUnit_Framework_TestCase
|
|
{
|
|
public static $functions;
|
|
|
|
public function setUp()
|
|
{
|
|
self::$functions = Mockery::mock();
|
|
}
|
|
|
|
public function tearDown()
|
|
{
|
|
Mockery::close();
|
|
}
|
|
|
|
protected function makeGeoIP(array $config = [], $cacheMock = null)
|
|
{
|
|
$cacheMock = $cacheMock ?: Mockery::mock('Illuminate\Cache\CacheManager');
|
|
|
|
$config = array_merge($this->getConfig(), $config);
|
|
|
|
$cacheMock->shouldReceive('tags')->with(['torann-geoip-location'])->andReturnSelf();
|
|
|
|
return new \Torann\GeoIP\GeoIP($config, $cacheMock);
|
|
}
|
|
|
|
protected function getConfig()
|
|
{
|
|
$config = include(__DIR__ . '/../config/geoip.php');
|
|
|
|
$this->databaseCheck($config['services']['maxmind_database']['database_path']);
|
|
|
|
return $config;
|
|
}
|
|
|
|
/**
|
|
* Check for test database and make a copy of it
|
|
* if it does not exist.
|
|
*
|
|
* @param string $database
|
|
*/
|
|
protected function databaseCheck($database)
|
|
{
|
|
if (file_exists($database) === false) {
|
|
@mkdir(dirname($database), 0755, true);
|
|
copy(__DIR__ . '/../resources/geoip.mmdb', $database);
|
|
}
|
|
}
|
|
} |