Changeset 8c356c1 for src/webservice/tests/StationsTest.php
- Timestamp:
- Aug 26, 2015, 8:14:40 PM (11 years ago)
- Branches:
- master
- Children:
- b38cc03
- Parents:
- 8f38d1e
- File:
-
- 1 moved
-
src/webservice/tests/StationsTest.php (moved) (moved from src/webservice/tests/TestStations.php ) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/webservice/tests/StationsTest.php
r8f38d1e r8c356c1 19 19 */ 20 20 21 class TestStationsextends PHPUnit_Framework_TestCase21 class StationsTest extends PHPUnit_Framework_TestCase 22 22 { 23 protected $config;24 25 23 protected function setUp() 26 24 { 27 $file = "webtests/webservice/testconfig/testconfig.php";25 $file = __DIR__ ."/testconfig/testconfig.php"; 28 26 $this->assertFileExists($file); 29 27 require($file); 30 $this->config = $testconfig; 31 $this->assertNotNull($this->config); 28 $this->_testconfig = $testconfig; 29 $this->assertNotNull($this->_testconfig); 30 31 require_once($testconfig["webserviceDirectory"] ."/SiWeather/Webservice/WebserviceConfig.php"); 32 33 $this->_webserviceConfig = new SiWeather\Webservice\WebserviceConfig(); 34 $this->assertNotNull($this->_webserviceConfig); 32 35 } 33 36 34 37 public function testEmptyStations() 35 38 { 36 $this->queryEmptyStationList($this->config["webserviceUrl"]); 39 $stations = $this->query("index.php/stations"); 40 41 $this->assertInternalType("array", $stations); 42 $this->assertEquals(count($stations), 0); 37 43 } 38 44 39 45 public function testStationRewrite() 40 46 { 41 $this->queryEmptyStationList($this->config["webserviceUrlRewrite"]); 47 $apiVersion = $this->_webserviceConfig->getConfig("webserviceApiVersion"); 48 $this->assertInternalType('string', $apiVersion); 49 $this->assertTrue(!empty($apiVersion)); 50 51 $stations = $this->query($apiVersion ."/stations"); 52 53 $this->assertInternalType("array", $stations); 54 $this->assertEquals(count($stations), 0); 42 55 } 43 56 44 protected function queryEmptyStationList($url){ 45 $this->assertInternalType('string', $url ."/"); 57 protected function query($url){ 58 require(__DIR__ ."/../vendor/autoload.php"); 59 60 $baseUrl = $this->_webserviceConfig->getConfig("webserviceBaseUrl"); 61 $this->assertInternalType('string', $baseUrl); 62 $this->assertTrue(!empty($baseUrl)); 46 63 $client = new GuzzleHttp\Client 47 64 ( 48 65 [ 49 "base_uri" => $ url,66 "base_uri" => $baseUrl, 50 67 "timeout" => 2.0, 68 "http_errors" => false, 51 69 ] 52 70 ); 53 $response = $client->get( "index.php/stations");71 $response = $client->get($url); 54 72 $this->assertNotNull($response); 55 73 $this->assertEquals($response->getStatusCode(), 200); … … 58 76 $body = $response->getBody(); 59 77 $this->assertTrue(!empty($body)); 60 $stations = json_decode($body); 61 $this->assertNotNull($stations); 62 $this->assertInternalType("array", $stations); 63 $this->assertEquals(count($stations), 0); 78 $json = json_decode($body); 79 $this->assertNotNull($json); 80 return $json; 64 81 } 82 83 protected $_testconfig; 84 protected $_webserviceConfig; 65 85 } 66 86 ?>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/siweather/chrome/site/your_project_logo.png)