File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,16 @@ class Geocoder implements GeocoderInterface
4444 */
4545 public function __construct (ProviderInterface $ provider = null , ResultFactory $ resultFactory = null )
4646 {
47- $ this ->provider = $ provider ;
47+ $ this ->provider = $ provider ;
48+
49+ $ this ->setResultFactory ($ resultFactory );
50+ }
51+
52+ /**
53+ * @param ResultFactory $resultFactory
54+ */
55+ public function setResultFactory (ResultFactory $ resultFactory = null )
56+ {
4857 $ this ->resultFactory = $ resultFactory ?: new ResultFactory ();
4958 }
5059
Original file line number Diff line number Diff line change @@ -126,6 +126,19 @@ public function testUseCustomResultFactory()
126126 $ this ->assertInstanceOf ('Geocoder\Tests\DummyResult ' , $ geocoder ->returnResult (array ()));
127127 }
128128
129+ public function testSetAndUseCustomResultFactory ()
130+ {
131+ $ factoryMock = $ this ->getMock ('Geocoder\Result\ResultFactory ' );
132+ $ factoryMock
133+ ->expects ($ this ->once ())
134+ ->method ('newInstance ' )
135+ ->will ($ this ->returnValue (new DummyResult ()));
136+
137+ $ geocoder = new TestableGeocoder (null );
138+ $ geocoder ->setResultFactory ($ factoryMock );
139+ $ this ->assertInstanceOf ('Geocoder\Tests\DummyResult ' , $ geocoder ->returnResult (array ()));
140+ }
141+
129142 protected function assertEmptyResult ($ result )
130143 {
131144 $ this ->assertEquals (0 , $ result ->getLatitude ());
You can’t perform that action at this time.
0 commit comments