close Warning: AdminModule failed with TracError: Unable to instantiate component <class 'trac.admin.web_ui.BasicsAdminPanel'> (super(type, obj): obj (type BasicsAdminPanel) is not an instance or subtype of type (Markup).)

source: src/webservice/tests/StationsTest.php@ b38cc03

Last change on this file since b38cc03 was b38cc03, checked in by Joachim Langenbach <joachim.langenbach@…>, 11 years ago
  • Translated more messages
    • Stripped out test externals, because they are not needed
    • Improved Setup class, to create all needed database tables
    • Smaller general improvements on the test classes
    • Extended the SetupTest extent
  • Property mode set to 100644
File size: 2.6 KB
RevLine 
[1c92d58]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
[8c356c1]21class StationsTest extends PHPUnit_Framework_TestCase
[1c92d58]22{
23 protected function setUp()
24 {
[8c356c1]25 $file = __DIR__ ."/testconfig/testconfig.php";
[1c92d58]26 $this->assertFileExists($file);
27 require($file);
[8c356c1]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);
[1c92d58]35 }
36
37 public function testEmptyStations()
38 {
[8c356c1]39 $stations = $this->query("index.php/stations");
40
41 $this->assertInternalType("array", $stations);
42 $this->assertEquals(count($stations), 0);
[1c92d58]43 }
44
45 public function testStationRewrite()
46 {
[8c356c1]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);
[1c92d58]55 }
56
[8c356c1]57 protected function query($url){
58 $baseUrl = $this->_webserviceConfig->getConfig("webserviceBaseUrl");
59 $this->assertInternalType('string', $baseUrl);
60 $this->assertTrue(!empty($baseUrl));
[1c92d58]61 $client = new GuzzleHttp\Client
62 (
63 [
[8c356c1]64 "base_uri" => $baseUrl,
[1c92d58]65 "timeout" => 2.0,
[8c356c1]66 "http_errors" => false,
[1c92d58]67 ]
68 );
[8c356c1]69 $response = $client->get($url);
[1c92d58]70 $this->assertNotNull($response);
71 $this->assertEquals($response->getStatusCode(), 200);
72 $this->assertEquals($response->getReasonPhrase(), "OK");
73
74 $body = $response->getBody();
75 $this->assertTrue(!empty($body));
[8c356c1]76 $json = json_decode($body);
77 $this->assertNotNull($json);
78 return $json;
[1c92d58]79 }
[8c356c1]80
81 protected $_testconfig;
82 protected $_webserviceConfig;
[1c92d58]83}
84?>
Note: See TracBrowser for help on using the repository browser.