source: src/webapp/webservice/tests/ServiceTest.php@ ecee2e6

debian/bullseye debian/jessie
Last change on this file since ecee2e6 was a50c18f, checked in by Joachim Langenbach <joachim.langenbach@…>, 9 years ago

Impproved webservice testing

  • Property mode set to 100644
File size: 2.8 KB
Line 
1<?php
2/*
3 Copyright (C) 2017 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program 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
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19// enable in php 7
20// declare(Strict_types=1);
21
22namespace GnuBoat;
23
24/**
25 * @brief Covers Service.php tests
26 */
27final class ServiceTest extends \PHPUnit_Framework_TestCase
28{
29 public function testData()
30 {
31 $webservice = new Webservice(0);
32 $this->assertInstanceOf(Webservice::class, $webservice);
33 $_GET["request"] = "data";
34 $webservice->process();
35 }
36
37 public function testLogFiles()
38 {
39 $webservice = new Webservice(0);
40 $this->assertInstanceOf(Webservice::class, $webservice);
41 $_GET["request"] = "logfiles";
42 $webservice->process();
43 }
44
45 public function testShutdown()
46 {
47 $webservice = new Webservice(0);
48 $this->assertInstanceOf(Webservice::class, $webservice);
49 $_GET["request"] = "shutdown";
50 $webservice->process();
51 }
52
53 public function testMap()
54 {
55 $webservice = new Webservice(0);
56 $this->assertInstanceOf(Webservice::class, $webservice);
57 $_GET["request"] = "map";
58 $webservice->process();
59 }
60
61 public function testReplay()
62 {
63 $webservice = new Webservice(0);
64 $_GET["request"] = "replay";
65 $_POST["logfile"] = "replay-test.log";
66 $webservice->process();
67 $output = $this->getActualOutput();
68 $this->assertJsonStringEqualsJsonString('{"track":{"1503767412":{"latitude":10.001,"longitude":1.001,"speedthroughwater":"-","speedoverground":11,"courseoverground":21,"waterdepth":"-","watertemperature":"-","gpsfix":"-"},"1503767413":{"latitude":20.002,"longitude":2.002,"speedthroughwater":"-","speedoverground":12,"courseoverground":22,"waterdepth":"-","watertemperature":"-","gpsfix":"-"},"1503767414":{"latitude":30.003,"longitude":3.003,"speedthroughwater":"-","speedoverground":13,"courseoverground":23,"waterdepth":1,"watertemperature":21,"gpsfix":"-"},"1503767415":{"latitude":40.004,"longitude":4.004,"speedthroughwater":"-","speedoverground":14,"courseoverground":24,"waterdepth":2,"watertemperature":22,"gpsfix":"-"},"1503767416":{"latitude":50.005,"longitude":5.005,"speedthroughwater":"-","speedoverground":15,"courseoverground":25,"waterdepth":3,"watertemperature":23,"gpsfix":"-"}}}', $output);
69 }
70}
71
72function error_log($msg)
73{
74 echo "ERR GnuBoat: ". $msg ."\n";
75}
76
77?>
Note: See TracBrowser for help on using the repository browser.