| 1 | <?php
|
|---|
| 2 | /*
|
|---|
| 3 | Copyright (C) 2015 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
|
|---|
| 4 |
|
|---|
| 5 | This library is free software; you can redistribute it and/or
|
|---|
| 6 | modify it under the terms of the GNU Lesser General Public
|
|---|
| 7 | License as published by the Free Software Foundation; either
|
|---|
| 8 | version 2.1 of the License, or (at your option) any later version.
|
|---|
| 9 |
|
|---|
| 10 | This library is distributed in the hope that it will be useful,
|
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 13 | Lesser General Public License for more details.
|
|---|
| 14 |
|
|---|
| 15 | You should have received a copy of the GNU Lesser General Public
|
|---|
| 16 | License along with this library; if not, write to the Free Software
|
|---|
| 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|---|
| 18 | MA 02110-1301 USA.
|
|---|
| 19 | */
|
|---|
| 20 |
|
|---|
| 21 | class TestStations extends PHPUnit_Framework_TestCase
|
|---|
| 22 | {
|
|---|
| 23 | protected $config;
|
|---|
| 24 |
|
|---|
| 25 | protected function setUp()
|
|---|
| 26 | {
|
|---|
| 27 | $file = "webtests/webservice/testconfig/testconfig.php";
|
|---|
| 28 | $this->assertFileExists($file);
|
|---|
| 29 | require($file);
|
|---|
| 30 | $this->config = $testconfig;
|
|---|
| 31 | $this->assertNotNull($this->config);
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | public function testEmptyStations()
|
|---|
| 35 | {
|
|---|
| 36 | $this->queryEmptyStationList($this->config["webserviceUrl"]);
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | public function testStationRewrite()
|
|---|
| 40 | {
|
|---|
| 41 | $this->queryEmptyStationList($this->config["webserviceUrlRewrite"]);
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | protected function queryEmptyStationList($url){
|
|---|
| 45 | $this->assertInternalType('string', $url ."/");
|
|---|
| 46 | $client = new GuzzleHttp\Client
|
|---|
| 47 | (
|
|---|
| 48 | [
|
|---|
| 49 | "base_uri" => $url,
|
|---|
| 50 | "timeout" => 2.0,
|
|---|
| 51 | ]
|
|---|
| 52 | );
|
|---|
| 53 | $response = $client->get("index.php/stations");
|
|---|
| 54 | $this->assertNotNull($response);
|
|---|
| 55 | $this->assertEquals($response->getStatusCode(), 200);
|
|---|
| 56 | $this->assertEquals($response->getReasonPhrase(), "OK");
|
|---|
| 57 |
|
|---|
| 58 | $body = $response->getBody();
|
|---|
| 59 | $this->assertTrue(!empty($body));
|
|---|
| 60 | $stations = json_decode($body);
|
|---|
| 61 | $this->assertNotNull($stations);
|
|---|
| 62 | $this->assertInternalType("array", $stations);
|
|---|
| 63 | $this->assertEquals(count($stations), 0);
|
|---|
| 64 | }
|
|---|
| 65 | }
|
|---|
| 66 | ?>
|
|---|