Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/webapp/webservice/tests/ServiceTest.php

    rc455d7b r26f77a6  
    2020// declare(Strict_types=1);
    2121
     22namespace GnuBoat;
     23
    2224/**
    23   * @brief Covers index.php tests
     25  * @brief Covers Service.php tests
    2426  */
    25 final class ServiceTest extends PHPUnit_Framework_TestCase
     27final class ServiceTest extends \PHPUnit_Framework_TestCase
    2628{
    27         /**
    28           * @runInSeparateProcess
    29           */
    3029        public function testData()
    3130        {
    32                 $webservice = new GnuBoat\Webservice();
    33                 $this->assertInstanceOf(GnuBoat\Webservice::class, $webservice);
    34                 $_POST["request"] = "data";
     31                $webservice = new Webservice(0);
     32                $this->assertInstanceOf(Webservice::class, $webservice);
     33                $_GET["request"] = "data";
    3534                $webservice->process();
    3635        }
    3736
    38         /**
    39           * @runInSeparateProcess
    40           */
    4137        public function testLogFiles()
    4238        {
    43                 $webservice = new GnuBoat\Webservice();
    44                 $this->assertInstanceOf(GnuBoat\Webservice::class, $webservice);
    45                 $_POST["request"] = "logfiles";
     39                $webservice = new Webservice(0);
     40                $this->assertInstanceOf(Webservice::class, $webservice);
     41                $_GET["request"] = "logfiles";
    4642                $webservice->process();
    4743        }
    4844       
    49         /**
    50           * @runInSeparateProcess
    51           */
    5245        public function testShutdown()
    5346        {
    54                 $webservice = new GnuBoat\Webservice();
    55                 $this->assertInstanceOf(GnuBoat\Webservice::class, $webservice);
    56                 $_POST["request"] = "shutdown";
     47                $webservice = new Webservice(0);
     48                $this->assertInstanceOf(Webservice::class, $webservice);
     49                $_GET["request"] = "shutdown";
    5750                $webservice->process();
    5851        }
    59        
    60         /**
    61           * @runInSeparateProcess
    62           */
     52
    6353        public function testMap()
    6454        {
    65                 $webservice = new GnuBoat\Webservice();
    66                 $this->assertInstanceOf(GnuBoat\Webservice::class, $webservice);
    67                 $_POST["request"] = "map";
     55                $webservice = new Webservice(0);
     56                $this->assertInstanceOf(Webservice::class, $webservice);
     57                $_GET["request"] = "map";
    6858                $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":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);
    6969        }
    7070}
    7171
     72function error_log($msg)
     73{
     74        echo "ERR GnuBoat: ". $msg ."\n";
     75}
     76
    7277?>
Note: See TracChangeset for help on using the changeset viewer.