|
7 | 7 |
|
8 | 8 | class TimedGeocoderTest extends TestCase
|
9 | 9 | {
|
10 |
| - protected function setUp() |
11 |
| - { |
12 |
| - $this->stopwatch = new Stopwatch(); |
13 |
| - $this->delegate = $this->getMock('Geocoder\Geocoder'); |
14 |
| - $this->geocoder = new TimedGeocoder($this->delegate, $this->stopwatch); |
15 |
| - } |
16 |
| - |
17 |
| - public function testGeocode() |
18 |
| - { |
19 |
| - $this->delegate->expects($this->once()) |
20 |
| - ->method('geocode') |
21 |
| - ->with($this->equalTo('foo')) |
22 |
| - ->will($this->returnValue([])); |
23 |
| - |
24 |
| - $this->geocoder->geocode('foo'); |
25 |
| - |
26 |
| - $this->assertCount(1, $this->stopwatch->getSectionEvents('__root__')); |
27 |
| - } |
28 |
| - |
29 |
| - public function testReverse() |
30 |
| - { |
31 |
| - $this->delegate->expects($this->once()) |
32 |
| - ->method('reverse') |
33 |
| - ->with($this->equalTo(0, 0)) |
34 |
| - ->will($this->returnValue([])); |
35 |
| - |
36 |
| - $this->geocoder->reverse(0, 0); |
37 |
| - |
38 |
| - $this->assertCount(1, $this->stopwatch->getSectionEvents('__root__')); |
39 |
| - } |
| 10 | + protected function setUp() |
| 11 | + { |
| 12 | + $this->stopwatch = new Stopwatch(); |
| 13 | + $this->delegate = $this->getMock('Geocoder\Geocoder'); |
| 14 | + $this->geocoder = new TimedGeocoder($this->delegate, $this->stopwatch); |
| 15 | + } |
| 16 | + |
| 17 | + public function testGeocode() |
| 18 | + { |
| 19 | + $this->delegate->expects($this->once()) |
| 20 | + ->method('geocode') |
| 21 | + ->with($this->equalTo('foo')) |
| 22 | + ->will($this->returnValue([])); |
| 23 | + |
| 24 | + $this->geocoder->geocode('foo'); |
| 25 | + |
| 26 | + $this->assertCount(1, $this->stopwatch->getSectionEvents('__root__')); |
| 27 | + } |
| 28 | + |
| 29 | + public function testGeocodeThrowsException() |
| 30 | + { |
| 31 | + $this->delegate->expects($this->once()) |
| 32 | + ->method('geocode') |
| 33 | + ->with($this->equalTo('foo')) |
| 34 | + ->will($this->throwException($exception = new \Exception())); |
| 35 | + |
| 36 | + try { |
| 37 | + $this->geocoder->geocode('foo'); |
| 38 | + $this->fail('Geocoder::geocode should throw an exception'); |
| 39 | + } catch (\Exception $e) { |
| 40 | + $this->assertSame($exception, $e); |
| 41 | + } |
| 42 | + |
| 43 | + $this->assertCount(1, $this->stopwatch->getSectionEvents('__root__')); |
| 44 | + } |
| 45 | + |
| 46 | + public function testReverse() |
| 47 | + { |
| 48 | + $this->delegate->expects($this->once()) |
| 49 | + ->method('reverse') |
| 50 | + ->with($this->equalTo(0, 0)) |
| 51 | + ->will($this->returnValue([])); |
| 52 | + |
| 53 | + $this->geocoder->reverse(0, 0); |
| 54 | + |
| 55 | + $this->assertCount(1, $this->stopwatch->getSectionEvents('__root__')); |
| 56 | + } |
| 57 | + |
| 58 | + public function testReverseThrowsException() |
| 59 | + { |
| 60 | + $this->delegate->expects($this->once()) |
| 61 | + ->method('reverse') |
| 62 | + ->with($this->equalTo(0, 0)) |
| 63 | + ->will($this->throwException($exception = new \Exception())); |
| 64 | + |
| 65 | + try { |
| 66 | + $this->geocoder->reverse(0, 0); |
| 67 | + $this->fail('Geocoder::reverse should throw an exception'); |
| 68 | + } catch (\Exception $e) { |
| 69 | + $this->assertSame($exception, $e); |
| 70 | + } |
| 71 | + |
| 72 | + $this->assertCount(1, $this->stopwatch->getSectionEvents('__root__')); |
| 73 | + } |
40 | 74 | }
|
0 commit comments