assertFileExists($file); require($file); $this->_testconfig = $testconfig; $this->assertNotNull($this->_testconfig); require_once($testconfig["webserviceDirectory"] ."/SiWeather/Webservice/WebserviceConfig.php"); $this->_webserviceConfig = new SiWeather\Webservice\WebserviceConfig(); $this->assertNotNull($this->_webserviceConfig); } public function testEmptyStations() { $stations = $this->query("index.php/stations"); $this->assertInternalType("array", $stations); $this->assertEquals(count($stations), 0); } public function testStationRewrite() { $apiVersion = $this->_webserviceConfig->getConfig("webserviceApiVersion"); $this->assertInternalType('string', $apiVersion); $this->assertTrue(!empty($apiVersion)); $stations = $this->query($apiVersion ."/stations"); $this->assertInternalType("array", $stations); $this->assertEquals(count($stations), 0); } protected function query($url){ $baseUrl = $this->_webserviceConfig->getConfig("webserviceBaseUrl"); $this->assertInternalType('string', $baseUrl); $this->assertTrue(!empty($baseUrl)); $client = new GuzzleHttp\Client ( [ "base_uri" => $baseUrl, "timeout" => 2.0, "http_errors" => false, ] ); $response = $client->get($url); $this->assertNotNull($response); $this->assertEquals($response->getStatusCode(), 200); $this->assertEquals($response->getReasonPhrase(), "OK"); $body = $response->getBody(); $this->assertTrue(!empty($body)); $json = json_decode($body); $this->assertNotNull($json); return $json; } protected $_testconfig; protected $_webserviceConfig; } ?>