Skip to content

Commit

Permalink
Removed Provider tests are they are not required/covered by the lower…
Browse files Browse the repository at this point in the history
… level tests. Added remaining tests for the base Metar class.
  • Loading branch information
allebb committed Jan 29, 2016
1 parent 9be9768 commit d48d987
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 52 deletions.
4 changes: 0 additions & 4 deletions lib/Helpers/MetarHTTPClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,11 @@ public function __construct($config = [])
* Make a HTTP request and retrieve the body.
* @param string $url The URL to request
* @return string
* @throws Exception
*/
public function getMetarAPIResponse($url)
{
$client = new HttpClient($this->guzzle_conf);
$response = $client->get($url);
if ($response->getStatusCode() != 200) {
throw new Exception('An error occured when attempting to access the remote webservice, please try again shortly!');
}
return $response->getBody();
}
}
20 changes: 15 additions & 5 deletions tests/MetarHttpClientTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<?php
use \PHPUnit_Framework_TestCase;
use GuzzleHttp\Client;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Exception\RequestException;

/**
* Metar
Expand All @@ -19,7 +15,7 @@
* @link http://www.bobbyallen.me
*
*/
class MetarHttpClientTest extends PHPUnit_Framework_TestCase
class MetarHttpClientTest extends \PHPUnit_Framework_TestCase
{

/**
Expand Down Expand Up @@ -72,4 +68,18 @@ public function testInvalidReport()
$this->setExpectedException('Exception', 'Client error: `GET http://metar.vatsim.net/metar.php?id=EGSSA` resulted in a `404 Not Found` response:');
$client->getMetarAPIResponse(sprintf(self::VATSIM_SERVICE_URL, 'EGSSA'));
}

/**
* Test recieving an unprocessable response (eg. a 502 response).
*/
public function testServiceUnavailableRepsonse()
{
$mock = new MockHandler([
new Response(502),
]);
$this->handler = HandlerStack::create($mock);
$client = new Ballen\Metar\Helpers\MetarHTTPClient(['handler' => $this->handler]);
$this->setExpectedException('Exception', 'Server error: `GET http://metar.vatsim.net/metar.php?id=EGSS` resulted in a `502 Bad Gateway` respsone:');
$client->getMetarAPIResponse(sprintf(self::VATSIM_SERVICE_URL, 'EGSS'));
}
}
5 changes: 2 additions & 3 deletions tests/MetarTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
use \PHPUnit_Framework_TestCase;
use Ballen\Metar\Metar;

/**
Expand All @@ -14,7 +13,7 @@
* @link http://www.bobbyallen.me
*
*/
class MetarTest extends PHPUnit_Framework_TestCase
class MetarTest extends \PHPUnit_Framework_TestCase
{

public function testSetValidIcao()
Expand All @@ -35,7 +34,7 @@ public function testSetValidProvider()
}

public function testSetInvalidProvider()
{
{
$metar = new Metar('EGSS');
$this->setExpectedException('InvalidArgumentException', 'The service provider your specified does not exist in the namespace \'' . Metar::SERVICES_NAMESPACE . '\'');
$metar->setProvider('An_Invalid_Provider');
Expand Down
20 changes: 0 additions & 20 deletions tests/Providers/NoaaProviderTest.php

This file was deleted.

20 changes: 0 additions & 20 deletions tests/Providers/VatsimProviderTest.php

This file was deleted.

0 comments on commit d48d987

Please sign in to comment.