-
Notifications
You must be signed in to change notification settings - Fork 199
Expand file tree
/
Copy pathGeoPluginTest.php
More file actions
55 lines (46 loc) · 1.58 KB
/
Copy pathGeoPluginTest.php
File metadata and controls
55 lines (46 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace Stevebauman\Location\Tests\Drivers;
use Illuminate\Support\Fluent;
use Mockery as m;
use Stevebauman\Location\Drivers\GeoPlugin;
use Stevebauman\Location\Facades\Location;
use Stevebauman\Location\Position;
it('it can process fluent response', function () {
$driver = m::mock(GeoPlugin::class)->makePartial();
$attributes = [
'geoplugin_countryCode' => 'US',
'geoplugin_countryName' => 'United States',
'geoplugin_regionName' => 'California',
'geoplugin_regionCode' => 'CA',
'geoplugin_city' => 'Long Beach',
'geoplugin_latitude' => '50',
'geoplugin_longitude' => '50',
'geoplugin_areaCode' => '555',
'geoplugin_timezone' => 'America/Toronto',
];
$driver
->shouldAllowMockingProtectedMethods()
->shouldReceive('process')->once()->andReturn(new Fluent($attributes));
Location::setDriver($driver);
$position = Location::get();
expect($position)->toBeInstanceOf(Position::class);
expect($position->toArray())->toEqual([
'countryName' => 'United States',
'currencyCode' => null,
'countryCode' => 'US',
'regionCode' => 'CA',
'regionName' => 'California',
'cityName' => 'Long Beach',
'zipCode' => null,
'isoCode' => null,
'postalCode' => null,
'latitude' => '50',
'longitude' => '50',
'metroCode' => null,
'areaCode' => '555',
'ip' => '66.102.0.0',
'timezone' => 'America/Toronto',
'driver' => get_class($driver),
'cached' => false,
]);
});