Skip to content

Commit efbc100

Browse files
committed
Fix test
1 parent a514d86 commit efbc100

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

tests/CacheTest.php

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ public function shouldReturnValidLocation()
1818
'lon' => -72.92,
1919
];
2020

21-
$cacheMock = Mockery::mock('Illuminate\Cache\CacheManager');
22-
$cacheMock->shouldReceive('get')->with($data['ip'])->andReturn($data);
21+
$cacheMock = Mockery::mock('Illuminate\Cache\CacheManager')
22+
->shouldAllowMockingProtectedMethods();
23+
24+
$cacheMock->shouldReceive('get')
25+
->with($data['ip'])
26+
->andReturn($data);
2327

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

@@ -35,12 +39,18 @@ public function shouldReturnValidLocation()
3539
*/
3640
public function shouldReturnInvalidLocation()
3741
{
38-
$cacheMock = Mockery::mock('Illuminate\Cache\CacheManager');
42+
$cacheMock = Mockery::mock('Illuminate\Cache\CacheManager')
43+
->shouldAllowMockingProtectedMethods();
3944

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

42-
$cacheMock->shouldReceive('get')->with('81.2.69.142')->andReturn(null);
43-
$cacheMock->shouldReceive('tags')->with($geo_ip->config('cache_tags'))->andReturnSelf();
47+
$cacheMock->shouldReceive('get')
48+
->with('81.2.69.142')
49+
->andReturn(null);
50+
51+
$cacheMock->shouldReceive('tags')
52+
->with($geo_ip->config('cache_tags'))
53+
->andReturnSelf();
4454

4555
$this->assertEquals($geo_ip->getCache()->get('81.2.69.142'), null);
4656
}
@@ -57,12 +67,18 @@ public function shouldSetLocation()
5767
'lon' => -72.92,
5868
]);
5969

60-
$cacheMock = Mockery::mock('Illuminate\Cache\CacheManager');
70+
$cacheMock = Mockery::mock('Illuminate\Cache\CacheManager')
71+
->shouldAllowMockingProtectedMethods();
6172

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

64-
$cacheMock->shouldReceive('put')->withArgs(['81.2.69.142', $location->toArray(), $geo_ip->config('cache_expires')])->andReturn(null);
65-
$cacheMock->shouldReceive('tags')->with($geo_ip->config('cache_tags'))->andReturnSelf();
75+
$cacheMock->shouldReceive('put')
76+
->withArgs(['81.2.69.142', $location->toArray(), $geo_ip->config('cache_expires')])
77+
->andReturn(null);
78+
79+
$cacheMock->shouldReceive('tags')
80+
->with($geo_ip->config('cache_tags'))
81+
->andReturnSelf();
6682

6783
$this->assertEquals($geo_ip->getCache()->set('81.2.69.142', $location), null);
6884
}
@@ -72,12 +88,17 @@ public function shouldSetLocation()
7288
*/
7389
public function shouldFlushLocations()
7490
{
75-
$cacheMock = Mockery::mock('Illuminate\Cache\CacheManager');
91+
$cacheMock = Mockery::mock('Illuminate\Cache\CacheManager')
92+
->shouldAllowMockingProtectedMethods();
7693

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

79-
$cacheMock->shouldReceive('flush')->andReturn(true);
80-
$cacheMock->shouldReceive('tags')->with($geo_ip->config('cache_tags'))->andReturnSelf();
96+
$cacheMock->shouldReceive('flush')
97+
->andReturn(true);
98+
99+
$cacheMock->shouldReceive('tags')
100+
->with($geo_ip->config('cache_tags'))
101+
->andReturnSelf();
81102

82103
$this->assertEquals($geo_ip->getCache()->flush(), true);
83104
}

0 commit comments

Comments
 (0)