Ignore:
Timestamp:
Aug 29, 2017, 6:19:00 PM (9 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
0.5, debian/bullseye, debian/jessie, master
Children:
89c510f
Parents:
fc63b30
Message:

First more or less working version of visualising logfiles on the map

Location:
src/webapp/webservice
Files:
3 added
16 edited

Legend:

Unmodified
Added
Removed
  • src/webapp/webservice/inc/GnuBoat/Config.php

    rfc63b30 r008bce9  
    2626        public function __construct()
    2727        {
    28                 $configFile = __DIR__ ."/../config/config.php";
     28                $configFile = __DIR__ ."/../../config/config.php";
    2929                if(file_exists($configFile)){
    3030                        include($configFile);
    … …  
    5151        {
    5252                if(array_key_exists("datadirectory", $this->_config))
    53                         return addTrailingSlash($this->_config["datadirectory"]);
     53                        return $this->addTrailingSlash($this->_config["datadirectory"]);
    5454                return "/var/lib/gnuboat/";
    5555        }
    … …  
    5858        {
    5959                if(array_key_exists("logdirectory", $this->_config))
    60                         return addTrailingSlash($this->_config["logdirectory"]);
     60                        return $this->addTrailingSlash($this->_config["logdirectory"]);
    6161                return "/var/log/gnuboat/";
    6262        }
  • src/webapp/webservice/inc/GnuBoat/Nmea/Nmea0183/Nmea0183Dpt.php

    rfc63b30 r008bce9  
    3333                        return;
    3434               
    35                 $this->_depth = $content[1];
     35                $this->_depth = (float)$content[1];
    3636                $tmp = explode("*", $content[2]);
    3737                $this->_offset = $tmp[0];
  • src/webapp/webservice/inc/GnuBoat/Nmea/Nmea0183/Nmea0183Mtw.php

    rfc63b30 r008bce9  
    3333                        return;
    3434               
    35                 $this->_temperature = $content[1];
     35                $this->_temperature = (float)$content[1];
    3636                $tmp = explode("*", $content[2]);
    3737                $this->_unit = $tmp[0];
  • src/webapp/webservice/inc/GnuBoat/Nmea/Nmea0183/Nmea0183Rmc.php

    rfc63b30 r008bce9  
    1919namespace GnuBoat\Nmea\Nmea0183;
    2020
     21/**
     22 * @brief NMEA0183 RMC Naviation sentence
     23 *
     24 * Keep in mind, that the latitude() and longitude() is converted to +/- values
     25 */
    2126class Nmea0183Rmc extends Nmea0183Sentence
    2227{
    … …  
    4954                if($content[2] == 'A')
    5055                        $this->_status = Nmea0183RmcStatus::A;
    51                        
    52                 $this->_latitude = $content[3];
    53                 $this->_latitudeDirection = Nmea0183Rmc::directionToEnum($content[4]);
    5456               
    55                 $this->_longitude = $content[5];
    56                 $this->_longitudeDirection = Nmea0183Rmc::directionToEnum($content[6]);
     57                $this->_latitude = (float)$content[3];
     58                if(Nmea0183Rmc::directionToEnum($content[4]) == Nmea0183Direction::South)
     59                        $this->_latitude = $this->_latitude * -1;
    5760               
    58                 $this->_speedOverGround = $content[7];
     61                $this->_longitude = (float)$content[5];
     62                if(Nmea0183Rmc::directionToEnum($content[6]) == Nmea0183Direction::West)
     63                        $this->_longitude = $this->_longitude * -1;
    5964               
    60                 $this->_courseOverGround = $content[8];
     65                $this->_speedOverGround = (float)$content[7];
    6166               
    62                 $this->_magneticDeclination = $content[10];
     67                $this->_courseOverGround = (float)$content[8];
     68               
     69                $this->_magneticDeclination = (float)$content[10];
    6370                $this->_magneticDeclinationDirection = Nmea0183Rmc::directionToEnum($content[11]);
    6471               
    … …  
    8289        }
    8390       
     91        /**
     92         * @brief Latitude with North (+) and South (-)
     93         */
    8494        public function latitude()
    8595        {
    … …  
    8797        }
    8898       
    89         public function latitudeDirection()
    90         {
    91                 return $this->_latitudeDirection;
    92         }
    93        
     99        /**
     100         * @brief Longitude with East (+) and West (-)
     101         */
    94102        public function longitude()
    95103        {
    96104                return $this->_longitude;
    97         }
    98 
    99         public function longitudeDirection()
    100         {
    101                 return $this->_longitudeDirection;
    102105        }
    103106       
    … …  
    162165        private $_status;
    163166        private $_latitude;
    164         private $_latitudeDirection;
    165167        private $_longitude;
    166         private $_longitudeDirection;
    167168        private $_speedOverGround;
    168169        private $_courseOverGround;
  • src/webapp/webservice/inc/GnuBoat/Nmea/Nmea0183/Parser.php

    rfc63b30 r008bce9  
    3535                $result = array();
    3636                if(!file_exists($file)){
    37                         $message = "NMEA file to parse does not exists: ". $file ."\n";
     37                        $message = "NMEA file to parse does not exists: ". $file;
    3838                        error_log($message);
    3939                        if($debug > 0)
    40                                 print $message;
     40                                print $message ."\n";
    4141                        return $result;
    4242                }
    … …  
    4444                $fileHandler = fopen($file, 'r');
    4545                if(!$fileHandler){
    46                         $message = "NMEA file to parse could not be opend for reading: ". $file ."\n";
     46                        $message = "NMEA file to parse could not be opend for reading: ". $file;
    4747                        error_log($message);
    4848                        if($debug > 0)
    49                                 print $message;
     49                                print $message ."\n";
    5050                        return $result;
    5151                }
    … …  
    6161                                $result[] = $parsedSentence;
    6262                        else{
    63                                 $message = "Skipped sentence on line ". $line .": ". $sentence ."\n";
     63                                $message = "Skipped sentence on line ". $line .": ". $sentence;
    6464                                error_log($message);
    6565                                if($debug > 0)
    66                                         print $message;
     66                                        print $message ."\n";
    6767                        }
    6868                }
    … …  
    7575                $sentence = trim($sentence);
    7676                if(empty($sentence)){
    77                         $message = "Empty sentence\n";
     77                        $message = "Empty sentence";
    7878                        error_log($message);
    7979                        if($debug > 0)
    80                                 print $message;
     80                                print $message ."\n";
    8181                        return null;
    8282                }
    … …  
    8585                $result = preg_match('/^[\$!]{1}([\w]{2})([\w]{3})([^\*]+)\*([\da-zA-Z]+)$/', $sentence, $matches);
    8686                if($result === false || $result != 1 || count($matches) != 5){
    87                         $message = "Could not detect talker, type and checksum from ". $sentence ."\n";
     87                        $message = "Could not detect talker, type and checksum from ". $sentence;
    8888                        error_log($message);
    8989                        if($debug > 0)
    90                                 print $message;
     90                                print $message ."\n";
    9191                        return null;
    9292                }
    … …  
    9797               
    9898                if(!array_key_exists(strtolower($type), $this->_types)){
    99                         $message = "Skipping unknown NMEA0183 sentence of type ". $type .": ". $sentence ."\n";
     99                        $message = "Skipping unknown NMEA0183 sentence of type ". $type .": ". $sentence;
    100100                        error_log($message);
    101101                        if($debug > 0)
    102                                 print $message;
     102                                print $message ."\n";
    103103                        return null;
    104104                }
  • src/webapp/webservice/inc/GnuBoat/Nmea/NmeaSentence.php

    rfc63b30 r008bce9  
    4848        public function type()
    4949        {
    50                 return $this->_type;
     50                return strtolower($this->_type);
    5151        }
    5252       
  • src/webapp/webservice/inc/GnuBoat/Service.php

    rfc63b30 r008bce9  
    4444                $this->process();
    4545        }
     46       
     47        public static function error($message)
     48        {
     49                Service::output(["error" => 1, "errormessage" => $message]);
     50        }
     51       
     52        public static function output($content)
     53        {
     54                header('Content-Type: application/json');
     55                echo json_encode($content);
     56        }
    4657
    4758        /**
  • src/webapp/webservice/inc/GnuBoat/ServiceData.php

    rfc63b30 r008bce9  
    4949
    5050                if(!file_exists($dbFile)){
    51                         echo json_encode("");
    5251                        if($debug > 0)
    5352                                echo "Database file ". $dbFile ." does not exist!";
    5453                        error_log("Database file ". $dbFile ." does not exist");
    55                         exit;
     54                        return;
    5655                }
    5756                // Fetch entries of the last 30s with maximum (available) resolution of 2s
  • src/webapp/webservice/inc/GnuBoat/ServiceLogFiles.php

    rfc63b30 r008bce9  
    3232                $debug = $this->debug();
    3333                $config = new Config();
     34                if($debug > 1)
     35                        print "Log directory: ". $config->logDirectory() ."\n";
    3436
    3537                if(!array_key_exists("logfilesSelected", $_POST)){
  • src/webapp/webservice/inc/GnuBoat/Webservice.php

    rfc63b30 r008bce9  
    2323class WebService
    2424{
    25         function __construct()
     25        function __construct($debug)
    2626        {
    2727                $this->_requests = array();
    … …  
    3030                $this->_requests["logfiles"] = "GnuBoat\ServiceLogFiles";
    3131                $this->_requests["map"] = "GnuBoat\ServiceMap";
     32                $this->_requests["replay"] = "GnuBoat\ServiceReplay";
     33               
     34                $this->_debug = $debug;
    3235        }
    3336
    3437        public function process()
    3538        {
    36                 $debug = 0;
    37                 if(is_array($_GET) && array_key_exists("debug", $_GET))
    38                         $debug = $_GET["debug"];
    39 
    4039                $request = array_keys($this->_requests)[0];
    4140                if(is_array($_GET) && array_key_exists("request", $_GET)){
    … …  
    4443
    4544                if(!array_key_exists($request, $this->_requests)){
    46                         $result["error"] = 1;
    47                         $result["errormessage"] = "Request ". $request ." not implemented";
    48                        
    49                         header('Content-Type: application/json');
    50                         echo json_encode($result) ."\n";
    51                         return;
     45                        return Service::error("Request ". $request ." not implemented");
    5246                }
    53 
    54                 call_user_func(array(new $this->_requests[$request], "processRequest"), $debug);
     47               
     48                call_user_func(array(new $this->_requests[$request], "processRequest"), $this->_debug);
    5549        }
    5650
    5751        private $_requests;
     52        private $_debug;
    5853}
    5954
  • src/webapp/webservice/index.php

    rfc63b30 r008bce9  
    1919require_once(__DIR__ ."/inc/autoloader.php");
    2020
    21 $webservice = new GnuBoat\Webservice();
     21$debug = 0;
     22if(array_key_exists("debug", $_GET))
     23        $debug = $_GET["debug"];
     24
     25$webservice = new GnuBoat\Webservice($debug);
    2226$webservice->process();
    2327
  • src/webapp/webservice/tests/Nmea0183DptTest.php

    rfc63b30 r008bce9  
    4646        {
    4747                return [
    48                         "wrong_data_count" => ['$SDDPT,00.71,00.71,00.00*51', 'SD', 'DPT', 0, 0, 51, false],
    49                         "wrong_checksum" => ['$SDDPT,00.71,00.00*22', 'SD', 'DPT', 0.71, 0.0, 22, false],
    50                         "valid1" => ['$SDDPT,00.71,00.00*51', 'SD', 'DPT', 0.71, 0.0, 51, true],
    51                         "valid2" => ['!SDDPT,00.71,00.00*51', 'SD', 'DPT', 0.71, 0.0, 51, true],
     48                        "wrong_data_count" => ['$SDDPT,00.71,00.71,00.00*51', 'SD', 'dpt', 0, 0, 51, false],
     49                        "wrong_checksum" => ['$SDDPT,00.71,00.00*22', 'SD', 'dpt', 0.71, 0.0, 22, false],
     50                        "valid1" => ['$SDDPT,00.71,00.00*51', 'SD', 'dpt', 0.71, 0.0, 51, true],
     51                        "valid2" => ['!SDDPT,00.71,00.00*51', 'SD', 'dpt', 0.71, 0.0, 51, true],
    5252                ];
    5353        }
  • src/webapp/webservice/tests/Nmea0183MtwTest.php

    rfc63b30 r008bce9  
    4646        {
    4747                return [
    48                         "wrong_data_count" => ['$YXMTW,C*15', 'YX', 'MTW', 0, '', 15, false],
    49                         "wrong_checksum" => ['$YXMTW,26.3,C*22', 'YX', 'MTW', 26.3, 'C', 22, false],
    50                         "valid1" => ['$YXMTW,26.3,C*15', 'YX', 'MTW', 26.3, 'C', 15, true],
    51                         "valid2" => ['!YXMTW,26.3,C*15', 'YX', 'MTW', 26.3, 'C', 15, true],
     48                        "wrong_data_count" => ['$YXMTW,C*15', 'YX', 'mtw', 0, '', 15, false],
     49                        "wrong_checksum" => ['$YXMTW,26.3,C*22', 'YX', 'mtw', 26.3, 'C', 22, false],
     50                        "valid1" => ['$YXMTW,26.3,C*15', 'YX', 'mtw', 26.3, 'C', 15, true],
     51                        "valid2" => ['!YXMTW,26.3,C*15', 'YX', 'mtw', 26.3, 'C', 15, true],
    5252                ];
    5353        }
  • src/webapp/webservice/tests/Nmea0183RmcTest.php

    rfc63b30 r008bce9  
    4949                $this->assertEquals($sentence->status(), $status);
    5050                $this->assertEquals($latitude, $sentence->latitude());
    51                 $this->assertEquals($latitudeDirection, $sentence->latitudeDirection());
    5251                $this->assertEquals($longitude, $sentence->longitude());
    53                 $this->assertEquals($longitudeDirection, $sentence->longitudeDirection());
    5452                $this->assertEquals($speedOverGround, $sentence->speedOverGround());
    5553                $this->assertEquals($courseOverGround, $sentence->courseOverGround());
    … …  
    7169                        "wrong_data_count" => [
    7270                                '$GPRMC,162614,A,N,01322.3900,E,10.0,90.0,131006,1.2,E,A*13',
    73                                 "GP", "RMC", null,
     71                                "GP", "rmc", null,
    7472                                GnuBoat\Nmea\Nmea0183\Nmea0183RmcStatus::V, 0, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::Invalid,
    7573                                0, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::Invalid,
    … …  
    7977                        "wrong_checksum" => [
    8078                                '$GPRMC,162614,A,5230.5900,N,01322.3900,E,10.0,90.0,131006,1.2,E,A*22',
    81                                 "GP", "RMC", DateTime::createFromFormat($format, "2006-10-13 16:26:14", new DateTimeZone("UTC")),
     79                                "GP", "rmc", DateTime::createFromFormat($format, "2006-10-13 16:26:14", new DateTimeZone("UTC")),
    8280                                GnuBoat\Nmea\Nmea0183\Nmea0183RmcStatus::A, 5230.59, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::North,
    8381                                1322.39, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
    … …  
    8785                        "valid1" => [
    8886                                '$GPRMC,162614,A,5230.5900,N,01322.3900,E,10.0,90.0,131006,1.2,E,A*13',
    89                                 "GP", "RMC", DateTime::createFromFormat($format, "2006-10-13 16:26:14", new DateTimeZone("UTC")),
     87                                "GP", "rmc", DateTime::createFromFormat($format, "2006-10-13 16:26:14", new DateTimeZone("UTC")),
    9088                                GnuBoat\Nmea\Nmea0183\Nmea0183RmcStatus::A, 5230.59, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::North,
    9189                                1322.39, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
    … …  
    9492                        ],
    9593                        "valid2" => [
    96                                 '!GPRMC,162614,A,5230.5900,N,01322.3900,E,10.0,90.0,131006,1.2,E,A*13',
    97                                 "GP", "RMC", DateTime::createFromFormat($format, "2006-10-13 16:26:14", new DateTimeZone("UTC")),
    98                                 GnuBoat\Nmea\Nmea0183\Nmea0183RmcStatus::A, 5230.59, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::North,
    99                                 1322.39, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
     94                                '!GPRMC,162614,A,5230.5900,S,01322.3900,W,10.0,90.0,131006,1.2,E,A*1c',
     95                                "GP", "rmc", DateTime::createFromFormat($format, "2006-10-13 16:26:14", new DateTimeZone("UTC")),
     96                                GnuBoat\Nmea\Nmea0183\Nmea0183RmcStatus::A, -5230.59, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::North,
     97                                -1322.39, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
    10098                                10, 90, 1.2, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
    101                                 GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::AutonomousMode, 13, true
     99                                GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::AutonomousMode, '1c', true
    102100                        ],
    103101                        "valid3" => [
    104                                 '$GPRMC,162614.123,A,5230.5900,N,01322.3900,E,10.0,90.0,131006,1.2,E,A*d',
    105                                 "GP", "RMC", DateTime::createFromFormat($formatMilli, "2006-10-13 16:26:14.123", new DateTimeZone("UTC")),
     102                                '$GPRMC,162614.123,A,5230.5900,N,01322.3900,W,10.0,90.0,131006,1.2,E,A*1f',
     103                                "GP", "rmc", DateTime::createFromFormat($formatMilli, "2006-10-13 16:26:14.123", new DateTimeZone("UTC")),
    106104                                GnuBoat\Nmea\Nmea0183\Nmea0183RmcStatus::A, 5230.59, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::North,
    107                                 1322.39, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
     105                                -1322.39, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
    108106                                10, 90, 1.2, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
    109                                 GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::AutonomousMode, 'd', true
     107                                GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::AutonomousMode, '1f', true
    110108                        ]
    111109                ];
  • src/webapp/webservice/tests/NmeaTest.php

    rfc63b30 r008bce9  
    2020// declare(Strict_types=1);
    2121
    22 /**
    23   * @brief Covers Parser.php
    24   */
    25 final class NmeaTest extends PHPUnit_Framework_TestCase
     22namespace GnuBoat\Nmea
    2623{
     24
    2725        /**
    28           * @dataProvider formatsProvider
    29           */
    30         public function testFormats($format)
     26        * @brief Covers Parser.php
     27        */
     28        final class NmeaTest extends \PHPUnit_Framework_TestCase
    3129        {
    32                 $parser = new GnuBoat\Nmea\Parser(0);
    33                 $formats = $parser->formatsSupported();
    34                 $this->assertInternalType('array', $formats);
    35                 $this->assertContains($format, $formats);
    36         }
    37        
    38         public function formatsProvider()
    39         {
    40                 return [["0183"]];
     30                /**
     31                * @dataProvider formatsProvider
     32                */
     33                public function testFormats($format)
     34                {
     35                        $parser = new Parser(0);
     36                        $formats = $parser->formatsSupported();
     37                        $this->assertInternalType('array', $formats);
     38                        $this->assertContains($format, $formats);
     39                }
     40               
     41                public function formatsProvider()
     42                {
     43                        return [["0183"]];
     44                }
     45
     46                /**
     47                * @dataProvider nmeaSentenceProvider
     48                */
     49                public function testNmeaSentence($format, $sentence, $classType, $valid)
     50                {
     51                        $parser = new Parser(0);
     52                        $sentence = $parser->parseSentence($sentence, $format);
     53                        if($classType == null)
     54                                $this->assertNull($sentence);
     55                        else{
     56                                $this->assertInstanceOf($classType, $sentence);
     57                                $message = "";
     58                                $result = $sentence->valid($message);
     59                                $this->assertEquals($valid, $result, $message);
     60                        }
     61                }
     62               
     63                public function nmeaSentenceProvider()
     64                {
     65                        return [
     66                                "empty" => ['0183', '', null, false],
     67                                "unsupported_format" => ['abc', '', null, false],
     68                                "rmc0183" => ['0183', '$GNRMC,173658,A,0047.589,N,00010.713,E,01.1,147.4,260817,,,A*5F', Nmea0183\Nmea0183Rmc::class, true],
     69                                "dpt0183" => ['0183', '$SDDPT,00.71,00.00*51', Nmea0183\Nmea0183Dpt::class, true],
     70                                "mtw0183" => ['0183', '$YXMTW,26.3,C*15', Nmea0183\Nmea0183Mtw::class, true],
     71                        ];
     72                }
     73               
     74                /**
     75                * @dataProvider nmeaFileProvider
     76                */
     77                public function testNmeaFile($file, $format, $count)
     78                {
     79                        $parser = new Parser(0);
     80                        $sentences = $parser->parseFile($file, $format);
     81                        $this->assertInternalType('array', $sentences);
     82                        $this->assertCount($count, $sentences);
     83                        foreach($sentences as $sentence){
     84                                $this->assertNotNull($sentence);
     85                                $this->assertInstanceOf(NmeaSentence::class, $sentence);
     86                                $this->assertEquals(true, $sentence->valid());
     87                        }
     88                }
     89               
     90                public function nmeaFileProvider()
     91                {
     92                        return [["webservice/tests/data/nmea0183.log", '0183', 2000]];
     93                }
    4194        }
    4295
    43         /**
    44          * @dataProvider nmeaSentenceProvider
    45          */
    46         public function testNmeaSentence($format, $sentence, $classType, $valid)
     96        function error_log($msg)
    4797        {
    48                 $parser = new GnuBoat\Nmea\Parser(0);
    49                 $sentence = $parser->parseSentence($sentence, $format);
    50                 if($classType == null)
    51                         $this->assertNull($sentence);
    52                 else{
    53                         $this->assertInstanceOf($classType, $sentence);
    54                         $message = "";
    55                         $result = $sentence->valid($message);
    56                         $this->assertEquals($valid, $result, $message);
    57                 }
     98                echo "ERR Nmea: ". $msg ."\n";
    5899        }
    59        
    60         public function nmeaSentenceProvider()
     100}
     101
     102namespace GnuBoat\Nmea\Nmea0183
     103{
     104        function error_log($msg)
    61105        {
    62                 return [
    63                         "empty" => ['0183', '', null, false],
    64                         "unsupported_format" => ['abc', '', null, false],
    65                         "rmc0183" => ['0183', '$GNRMC,173658,A,0047.589,N,00010.713,E,01.1,147.4,260817,,,A*5F', GnuBoat\Nmea\Nmea0183\Nmea0183Rmc::class, true],
    66                         "dpt0183" => ['0183', '$SDDPT,00.71,00.00*51', GnuBoat\Nmea\Nmea0183\Nmea0183Dpt::class, true],
    67                         "mtw0183" => ['0183', '$YXMTW,26.3,C*15', GnuBoat\Nmea\Nmea0183\Nmea0183Mtw::class, true],
    68                 ];
    69         }
    70        
    71         /**
    72          * @dataProvider nmeaFileProvider
    73          */
    74         public function testNmeaFile($file, $format, $count)
    75         {
    76                 $parser = new GnuBoat\Nmea\Parser(0);
    77                 $sentences = $parser->parseFile($file, $format);
    78                 $this->assertInternalType('array', $sentences);
    79                 $this->assertCount($count, $sentences);
    80                 foreach($sentences as $sentence){
    81                         $this->assertNotNull($sentence);
    82                         $this->assertInstanceOf(GnuBoat\Nmea\NmeaSentence::class, $sentence);
    83                         $this->assertEquals(true, $sentence->valid());
    84                 }
    85         }
    86        
    87         public function nmeaFileProvider()
    88         {
    89                 return [["webservice/tests/data/nmea0183.log", '0183', 2000]];
     106                echo "ERR Nmea0183: ". $msg ."\n";
    90107        }
    91108}
  • src/webapp/webservice/tests/ServiceTest.php

    rfc63b30 r008bce9  
    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{
    2729        public function testData()
    2830        {
    29                 $webservice = new GnuBoat\Webservice();
    30                 $this->assertInstanceOf(GnuBoat\Webservice::class, $webservice);
     31                $webservice = new Webservice(0);
     32                $this->assertInstanceOf(Webservice::class, $webservice);
    3133                $_POST["request"] = "data";
    3234                $webservice->process();
    … …  
    3537        public function testLogFiles()
    3638        {
    37                 $webservice = new GnuBoat\Webservice();
    38                 $this->assertInstanceOf(GnuBoat\Webservice::class, $webservice);
     39                $webservice = new Webservice(0);
     40                $this->assertInstanceOf(Webservice::class, $webservice);
    3941                $_POST["request"] = "logfiles";
    4042                $webservice->process();
    … …  
    4345        public function testShutdown()
    4446        {
    45                 $webservice = new GnuBoat\Webservice();
    46                 $this->assertInstanceOf(GnuBoat\Webservice::class, $webservice);
     47                $webservice = new Webservice(0);
     48                $this->assertInstanceOf(Webservice::class, $webservice);
    4749                $_POST["request"] = "shutdown";
    4850                $webservice->process();
    … …  
    5153        public function testMap()
    5254        {
    53                 $webservice = new GnuBoat\Webservice();
    54                 $this->assertInstanceOf(GnuBoat\Webservice::class, $webservice);
     55                $webservice = new Webservice(0);
     56                $this->assertInstanceOf(Webservice::class, $webservice);
    5557                $_POST["request"] = "map";
     58                $webservice->process();
     59        }
     60       
     61        public function testReplay()
     62        {
     63                $webservice = new Webservice(0);
     64                $this->assertInstanceOf(Webservice::class, $webservice);
     65                $_POST["request"] = "replay";
    5666                $webservice->process();
    5767        }
    5868}
    5969
     70        function error_log($msg)
     71        {
     72                echo "ERR GnuBoat: ". $msg ."\n";
     73        }
     74
    6075?>
Note: See TracChangeset for help on using the changeset viewer.