File tree Expand file tree Collapse file tree 5 files changed +35
-22
lines changed
tests/Geocoder/Tests/HttpAdapter Expand file tree Collapse file tree 5 files changed +35
-22
lines changed Original file line number Diff line number Diff line change @@ -37,12 +37,7 @@ public function getContent($url)
3737 {
3838 try {
3939 $ response = $ this ->client ->setUri ($ url )->send ();
40-
41- if ($ response ->isSuccess ()) {
42- $ content = $ response ->getBody ();
43- } else {
44- $ content = null ;
45- }
40+ $ content = $ response ->isSuccess () ? $ response ->getBody () : null ;
4641 } catch (\Exception $ e ) {
4742 $ content = null ;
4843 }
Original file line number Diff line number Diff line change 1111 */
1212class BuzzHttpAdapterTest extends TestCase
1313{
14+ protected $ buzz ;
15+
1416 protected function setUp ()
1517 {
1618 if (!class_exists ('Buzz\Browser ' )) {
1719 $ this ->markTestSkipped ('Buzz library has to be installed ' );
1820 }
21+
22+ $ this ->buzz = new BuzzHttpAdapter ();
1923 }
2024
2125 public function testGetNullContent ()
2226 {
23- $ buzz = new BuzzHttpAdapter ();
24- $ this ->assertNull ($ buzz ->getContent (null ));
27+ $ this ->assertNull ($ this ->buzz ->getContent (null ));
2528 }
2629
2730 public function testGetFalseContent ()
2831 {
29- $ buzz = new BuzzHttpAdapter ();
30- $ this ->assertNull ($ buzz ->getContent (false ));
32+ $ this ->assertNull ($ this ->buzz ->getContent (false ));
33+ }
34+
35+ public function testGetName ()
36+ {
37+ $ this ->assertEquals ('buzz ' , $ this ->buzz ->getName ());
3138 }
3239
3340 public function testGetContentWithCustomBrowser ()
Original file line number Diff line number Diff line change 1111 */
1212class CurlHttpAdapterTest extends TestCase
1313{
14+ protected $ curl ;
15+
1416 protected function setUp ()
1517 {
1618 if (!function_exists ('curl_init ' )) {
1719 $ this ->markTestSkipped ('cURL has to be enabled. ' );
1820 }
21+
22+ $ this ->curl = new CurlHttpAdapter ();
1923 }
2024
2125 public function testGetNullContent ()
2226 {
23- $ curl = new CurlHttpAdapter ();
24- $ this ->assertNull ($ curl ->getContent (null ));
27+ $ this ->assertNull ($ this ->curl ->getContent (null ));
2528 }
2629
2730 public function testGetFalseContent ()
2831 {
29- $ curl = new CurlHttpAdapter ();
30- $ this ->assertNull ($ curl ->getContent (null ));
32+ $ this ->assertNull ($ this ->curl ->getContent (false ));
33+ }
34+
35+ public function testGetName ()
36+ {
37+ $ this ->assertEquals ('curl ' , $ this ->curl ->getName ());
3138 }
3239}
Original file line number Diff line number Diff line change @@ -21,10 +21,7 @@ protected function setUp()
2121 }
2222 }
2323
24- /**
25- * @covers Geocoder\HttpAdapter\GuzzleHttpAdapter::__construct
26- */
27- public function testCreatesDefaultClient ()
24+ public function testGetName ()
2825 {
2926 $ adapter = new GuzzleHttpAdapter ();
3027 $ this ->assertEquals ('guzzle ' , $ adapter ->getName ());
Original file line number Diff line number Diff line change 1212 */
1313class ZendHttpAdapterTest extends TestCase
1414{
15+ protected $ zend ;
16+
1517 protected function setUp ()
1618 {
1719 if (!class_exists ('Zend\Http\Client ' )) {
1820 $ this ->markTestSkipped ('Zend library has to be installed ' );
1921 }
22+
23+ $ this ->zend = new ZendHttpAdapter ();
2024 }
2125
2226 public function testGetNullContent ()
2327 {
24- $ zend = new ZendHttpAdapter ();
25- $ this ->assertNull ($ zend ->getContent (null ));
28+ $ this ->assertNull ($ this ->zend ->getContent (null ));
2629 }
2730
2831 public function testGetFalseContent ()
2932 {
30- $ zend = new ZendHttpAdapter ();
31- $ this ->assertNull ($ zend ->getContent (false ));
33+ $ this ->assertNull ($ this ->zend ->getContent (false ));
34+ }
35+
36+ public function testGetName ()
37+ {
38+ $ this ->assertEquals ('zend ' , $ this ->zend ->getName ());
3239 }
3340
3441 public function testGetContentWithCustomAdapter ()
You can’t perform that action at this time.
0 commit comments