Skip to content

Commit e43eaa6

Browse files
committed
Update tests to reflect prefix changes
1 parent f3fdf21 commit e43eaa6

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

psalm-baseline.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
</PropertyNotSetInConstructor>
6666
</file>
6767
<file src="src/GeoIP.php">
68+
<DeprecatedMethod>
69+
<code><![CDATA[setPrefix]]></code>
70+
</DeprecatedMethod>
6871
<DocblockTypeContradiction>
6972
<code><![CDATA[$this->currencies === null]]></code>
7073
<code><![CDATA[$this->service === null]]></code>

tests/CacheTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace InteractionDesignFoundation\GeoIP\Tests;
44

5+
use Illuminate\Cache\CacheManager;
56
use Mockery;
67

78
class CacheTest extends TestCase
@@ -16,14 +17,15 @@ public function shouldReturnValidLocation()
1617
'lon' => -72.92,
1718
];
1819

19-
$cacheMock = Mockery::mock('Illuminate\Cache\CacheManager')
20+
$cacheMock = Mockery::mock(CacheManager::class)
2021
->shouldAllowMockingProtectedMethods();
2122

2223
$cacheMock->shouldReceive('get')
2324
->with($data['ip'])
2425
->andReturn($data);
2526

2627
$geo_ip = $this->makeGeoIP([], $cacheMock);
28+
$geo_ip->getCache()->setPrefix('');
2729

2830
$location = $geo_ip->getCache()->get($data['ip']);
2931

@@ -35,10 +37,11 @@ public function shouldReturnValidLocation()
3537
/** @test */
3638
public function shouldReturnInvalidLocation()
3739
{
38-
$cacheMock = Mockery::mock('Illuminate\Cache\CacheManager')
40+
$cacheMock = Mockery::mock(CacheManager::class)
3941
->shouldAllowMockingProtectedMethods();
4042

4143
$geo_ip = $this->makeGeoIP([], $cacheMock);
44+
$geo_ip->getCache()->setPrefix('');
4245

4346
$cacheMock->shouldReceive('get')
4447
->with('81.2.69.142')
@@ -61,10 +64,11 @@ public function shouldSetLocation()
6164
'lon' => -72.92,
6265
]);
6366

64-
$cacheMock = Mockery::mock('Illuminate\Cache\CacheManager')
67+
$cacheMock = Mockery::mock(CacheManager::class)
6568
->shouldAllowMockingProtectedMethods();
6669

6770
$geo_ip = $this->makeGeoIP([], $cacheMock);
71+
$geo_ip->getCache()->setPrefix('');
6872

6973
$cacheMock->shouldReceive('put')
7074
->withArgs(['81.2.69.142', $location->toArray(), $geo_ip->config('cache_expires')])
@@ -80,7 +84,7 @@ public function shouldSetLocation()
8084
/** @test */
8185
public function shouldFlushLocations()
8286
{
83-
$cacheMock = Mockery::mock('Illuminate\Cache\CacheManager')
87+
$cacheMock = Mockery::mock(CacheManager::class)
8488
->shouldAllowMockingProtectedMethods();
8589

8690
$geo_ip = $this->makeGeoIP([], $cacheMock);

tests/Services/MaxMindDatabaseTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function shouldReturnConfigValue()
1717
/** @test */
1818
public function shouldReturnValidLocation()
1919
{
20-
list($service, $config) = $this->getService();
20+
[$service] = $this->getService();
2121

2222
$location = $service->locate('81.2.69.142');
2323

@@ -27,9 +27,9 @@ public function shouldReturnValidLocation()
2727
}
2828

2929
/** @test */
30-
public function shouldReturnInvalidLocation()
30+
public function shouldReturnInvalidLocationForSpecialAddresses()
3131
{
32-
list($service, $config) = $this->getService();
32+
[$service] = $this->getService();
3333

3434
try {
3535
$location = $service->locate('1.1.1.1');

tests/TestCase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace InteractionDesignFoundation\GeoIP\Tests;
44

5+
use Illuminate\Cache\CacheManager;
56
use Mockery;
67
use PHPUnit\Framework\TestCase as PHPUnitTestCase;
78

@@ -21,7 +22,7 @@ public function tearDown(): void
2122

2223
protected function makeGeoIP(array $config = [], $cacheMock = null)
2324
{
24-
$cacheMock = $cacheMock ?: Mockery::mock('Illuminate\Cache\CacheManager');
25+
$cacheMock = $cacheMock ?: Mockery::mock(CacheManager::class);
2526

2627
$config = array_merge($this->getConfig(), $config);
2728

0 commit comments

Comments
 (0)