forked from geocoder-php/Geocoder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimedGeocoderTest.php
More file actions
74 lines (59 loc) · 2.13 KB
/
Copy pathTimedGeocoderTest.php
File metadata and controls
74 lines (59 loc) · 2.13 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
<?php
namespace Geocoder\Tests;
use Geocoder\TimedGeocoder;
use Symfony\Component\Stopwatch\Stopwatch;
class TimedGeocoderTest extends TestCase
{
protected function setUp()
{
$this->stopwatch = new Stopwatch();
$this->delegate = $this->getMock('Geocoder\Geocoder');
$this->geocoder = new TimedGeocoder($this->delegate, $this->stopwatch);
}
public function testGeocode()
{
$this->delegate->expects($this->once())
->method('geocode')
->with($this->equalTo('foo'))
->will($this->returnValue([]));
$this->geocoder->geocode('foo');
$this->assertCount(1, $this->stopwatch->getSectionEvents('__root__'));
}
public function testGeocodeThrowsException()
{
$this->delegate->expects($this->once())
->method('geocode')
->with($this->equalTo('foo'))
->will($this->throwException($exception = new \Exception()));
try {
$this->geocoder->geocode('foo');
$this->fail('Geocoder::geocode should throw an exception');
} catch (\Exception $e) {
$this->assertSame($exception, $e);
}
$this->assertCount(1, $this->stopwatch->getSectionEvents('__root__'));
}
public function testReverse()
{
$this->delegate->expects($this->once())
->method('reverse')
->with($this->equalTo(0, 0))
->will($this->returnValue([]));
$this->geocoder->reverse(0, 0);
$this->assertCount(1, $this->stopwatch->getSectionEvents('__root__'));
}
public function testReverseThrowsException()
{
$this->delegate->expects($this->once())
->method('reverse')
->with($this->equalTo(0, 0))
->will($this->throwException($exception = new \Exception()));
try {
$this->geocoder->reverse(0, 0);
$this->fail('Geocoder::reverse should throw an exception');
} catch (\Exception $e) {
$this->assertSame($exception, $e);
}
$this->assertCount(1, $this->stopwatch->getSectionEvents('__root__'));
}
}