| [c455d7b] | 1 | <?php
|
|---|
| 2 | /*
|
|---|
| [c0e66e6] | 3 | Copyright (C) 2017 - 2018 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
|
|---|
| [c455d7b] | 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
|
|---|
| [c0e66e6] | 20 | declare(Strict_types=1);
|
|---|
| 21 | use PHPUnit\Framework\TestCase;
|
|---|
| [c455d7b] | 22 |
|
|---|
| [008bce9] | 23 | namespace GnuBoat;
|
|---|
| 24 |
|
|---|
| [c455d7b] | 25 | /**
|
|---|
| [008bce9] | 26 | * @brief Covers Service.php tests
|
|---|
| [c455d7b] | 27 | */
|
|---|
| [c0e66e6] | 28 | final class ServiceTest extends \PHPUnit\Framework\TestCase
|
|---|
| [c455d7b] | 29 | {
|
|---|
| 30 | public function testData()
|
|---|
| 31 | {
|
|---|
| [008bce9] | 32 | $webservice = new Webservice(0);
|
|---|
| 33 | $this->assertInstanceOf(Webservice::class, $webservice);
|
|---|
| [a50c18f] | 34 | $_GET["request"] = "data";
|
|---|
| [c455d7b] | 35 | $webservice->process();
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | public function testLogFiles()
|
|---|
| 39 | {
|
|---|
| [008bce9] | 40 | $webservice = new Webservice(0);
|
|---|
| 41 | $this->assertInstanceOf(Webservice::class, $webservice);
|
|---|
| [a50c18f] | 42 | $_GET["request"] = "logfiles";
|
|---|
| [c455d7b] | 43 | $webservice->process();
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | public function testShutdown()
|
|---|
| 47 | {
|
|---|
| [008bce9] | 48 | $webservice = new Webservice(0);
|
|---|
| 49 | $this->assertInstanceOf(Webservice::class, $webservice);
|
|---|
| [a50c18f] | 50 | $_GET["request"] = "shutdown";
|
|---|
| [c455d7b] | 51 | $webservice->process();
|
|---|
| 52 | }
|
|---|
| [0662b2d] | 53 |
|
|---|
| [c455d7b] | 54 | public function testMap()
|
|---|
| 55 | {
|
|---|
| [008bce9] | 56 | $webservice = new Webservice(0);
|
|---|
| 57 | $this->assertInstanceOf(Webservice::class, $webservice);
|
|---|
| [a50c18f] | 58 | $_GET["request"] = "map";
|
|---|
| [c455d7b] | 59 | $webservice->process();
|
|---|
| 60 | }
|
|---|
| [0662b2d] | 61 |
|
|---|
| [008bce9] | 62 | public function testReplay()
|
|---|
| 63 | {
|
|---|
| 64 | $webservice = new Webservice(0);
|
|---|
| [a50c18f] | 65 | $_GET["request"] = "replay";
|
|---|
| 66 | $_POST["logfile"] = "replay-test.log";
|
|---|
| [008bce9] | 67 | $webservice->process();
|
|---|
| [a50c18f] | 68 | $output = $this->getActualOutput();
|
|---|
| [26f77a6] | 69 | $this->assertJsonStringEqualsJsonString('{"track":{"1503767412":{"latitude":1.001,"longitude":1.001,"speedthroughwater":"-","speedoverground":11,"courseoverground":21,"waterdepth":"-","watertemperature":"-","gpsfix":"-"},"1503767413":{"latitude":2.0186666666667001,"longitude":2.0186666666667001,"speedthroughwater":"-","speedoverground":12,"courseoverground":22,"waterdepth":"-","watertemperature":"-","gpsfix":"-"},"1503767414":{"latitude":3.1696666666666999,"longitude":3.1696666666666999,"speedthroughwater":"-","speedoverground":13,"courseoverground":23,"waterdepth":1,"watertemperature":21,"gpsfix":"-"},"1503767415":{"latitude":4.004,"longitude":4.004,"speedthroughwater":"-","speedoverground":14,"courseoverground":24,"waterdepth":2,"watertemperature":22,"gpsfix":"-"},"1503767416":{"latitude":5.005,"longitude":5.005,"speedthroughwater":"-","speedoverground":15,"courseoverground":25,"waterdepth":3,"watertemperature":23,"gpsfix":"-"}}}', $output);
|
|---|
| [008bce9] | 70 | }
|
|---|
| [c455d7b] | 71 | }
|
|---|
| 72 |
|
|---|
| [0662b2d] | 73 | function error_log($msg)
|
|---|
| 74 | {
|
|---|
| 75 | echo "ERR GnuBoat: ". $msg ."\n";
|
|---|
| 76 | }
|
|---|
| [008bce9] | 77 |
|
|---|
| [c455d7b] | 78 | ?>
|
|---|