forked from geocoder-php/Geocoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractProviderTest.php
More file actions
81 lines (65 loc) · 1.95 KB
/
Copy pathAbstractProviderTest.php
File metadata and controls
81 lines (65 loc) · 1.95 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
namespace Geocoder\Tests\Provider;
use Geocoder\Tests\TestCase;
use Geocoder\HttpAdapter\HttpAdapterInterface;
use Geocoder\Provider\AbstractProvider;
/**
* @author William Durand <william.durand1@gmail.com>
*/
class AbstractProviderTest extends TestCase
{
public function testSetGetAdapter()
{
$adapter = new MockHttpAdapter();
$adapter2 = new MockHttpAdapter();
$provider = new MockProvider($adapter);
$this->assertSame($adapter, $provider->getAdapter());
$this->assertNull($provider->getLocale());
$provider->setAdapter($adapter2);
$this->assertSame($adapter2, $provider->getAdapter());
}
public function testSetGetLocale()
{
$adapter = new MockHttpAdapter();
$provider = new MockProvider($adapter, 'fr_FR');
$this->assertEquals('fr_FR', $provider->getLocale());
$provider->setLocale('de_DE');
$this->assertEquals('de_DE', $provider->getLocale());
}
public function testGetLocalhostDefaults()
{
$adapter = new MockHttpAdapter();
$provider = new MockProvider($adapter);
$result = $provider->getLocalhostDefaults();
$this->assertEquals(4, count($result));
$this->assertEquals('localhost', $result['city']);
$this->assertEquals('localhost', $result['region']);
$this->assertEquals('localhost', $result['county']);
$this->assertEquals('localhost', $result['country']);
}
}
class MockProvider extends AbstractProvider
{
public function getAdapter()
{
return parent::getAdapter();
}
public function getLocale()
{
return parent::getLocale();
}
public function getLocalhostDefaults()
{
return parent::getLocalhostDefaults();
}
}
class MockHttpAdapter implements HttpAdapterInterface
{
public function getContent($url)
{
}
public function getName()
{
return 'mock_http_adapter';
}
}