Changeset 008bce9 for src/webapp/webservice
- Timestamp:
- Aug 29, 2017, 6:19:00 PM (9 years ago)
- Branches:
- 0.5, debian/bullseye, debian/jessie, master
- Children:
- 89c510f
- Parents:
- fc63b30
- Location:
- src/webapp/webservice
- Files:
-
- 3 added
- 16 edited
-
inc/GnuBoat/Config.php (modified) (3 diffs)
-
inc/GnuBoat/Nmea/Nmea0183/Nmea0183Dpt.php (modified) (1 diff)
-
inc/GnuBoat/Nmea/Nmea0183/Nmea0183Mtw.php (modified) (1 diff)
-
inc/GnuBoat/Nmea/Nmea0183/Nmea0183Rmc.php (modified) (5 diffs)
-
inc/GnuBoat/Nmea/Nmea0183/Parser.php (modified) (6 diffs)
-
inc/GnuBoat/Nmea/NmeaSentence.php (modified) (1 diff)
-
inc/GnuBoat/Service.php (modified) (1 diff)
-
inc/GnuBoat/ServiceData.php (modified) (1 diff)
-
inc/GnuBoat/ServiceLogFiles.php (modified) (1 diff)
-
inc/GnuBoat/ServiceReplay.php (added)
-
inc/GnuBoat/TrackItem.php (added)
-
inc/GnuBoat/Webservice.php (modified) (3 diffs)
-
index.php (modified) (1 diff)
-
tests/Nmea0183DptTest.php (modified) (1 diff)
-
tests/Nmea0183MtwTest.php (modified) (1 diff)
-
tests/Nmea0183RmcTest.php (modified) (5 diffs)
-
tests/NmeaTest.php (modified) (1 diff)
-
tests/ServiceTest.php (modified) (4 diffs)
-
tests/config.php (added)
Legend:
- Unmodified
- Added
- Removed
-
src/webapp/webservice/inc/GnuBoat/Config.php
rfc63b30 r008bce9 26 26 public function __construct() 27 27 { 28 $configFile = __DIR__ ."/../ config/config.php";28 $configFile = __DIR__ ."/../../config/config.php"; 29 29 if(file_exists($configFile)){ 30 30 include($configFile); … … 51 51 { 52 52 if(array_key_exists("datadirectory", $this->_config)) 53 return addTrailingSlash($this->_config["datadirectory"]);53 return $this->addTrailingSlash($this->_config["datadirectory"]); 54 54 return "/var/lib/gnuboat/"; 55 55 } … … 58 58 { 59 59 if(array_key_exists("logdirectory", $this->_config)) 60 return addTrailingSlash($this->_config["logdirectory"]);60 return $this->addTrailingSlash($this->_config["logdirectory"]); 61 61 return "/var/log/gnuboat/"; 62 62 } -
src/webapp/webservice/inc/GnuBoat/Nmea/Nmea0183/Nmea0183Dpt.php
rfc63b30 r008bce9 33 33 return; 34 34 35 $this->_depth = $content[1];35 $this->_depth = (float)$content[1]; 36 36 $tmp = explode("*", $content[2]); 37 37 $this->_offset = $tmp[0]; -
src/webapp/webservice/inc/GnuBoat/Nmea/Nmea0183/Nmea0183Mtw.php
rfc63b30 r008bce9 33 33 return; 34 34 35 $this->_temperature = $content[1];35 $this->_temperature = (float)$content[1]; 36 36 $tmp = explode("*", $content[2]); 37 37 $this->_unit = $tmp[0]; -
src/webapp/webservice/inc/GnuBoat/Nmea/Nmea0183/Nmea0183Rmc.php
rfc63b30 r008bce9 19 19 namespace GnuBoat\Nmea\Nmea0183; 20 20 21 /** 22 * @brief NMEA0183 RMC Naviation sentence 23 * 24 * Keep in mind, that the latitude() and longitude() is converted to +/- values 25 */ 21 26 class Nmea0183Rmc extends Nmea0183Sentence 22 27 { … … 49 54 if($content[2] == 'A') 50 55 $this->_status = Nmea0183RmcStatus::A; 51 52 $this->_latitude = $content[3];53 $this->_latitudeDirection = Nmea0183Rmc::directionToEnum($content[4]);54 56 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; 57 60 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; 59 64 60 $this->_ courseOverGround = $content[8];65 $this->_speedOverGround = (float)$content[7]; 61 66 62 $this->_magneticDeclination = $content[10]; 67 $this->_courseOverGround = (float)$content[8]; 68 69 $this->_magneticDeclination = (float)$content[10]; 63 70 $this->_magneticDeclinationDirection = Nmea0183Rmc::directionToEnum($content[11]); 64 71 … … 82 89 } 83 90 91 /** 92 * @brief Latitude with North (+) and South (-) 93 */ 84 94 public function latitude() 85 95 { … … 87 97 } 88 98 89 public function latitudeDirection() 90 { 91 return $this->_latitudeDirection; 92 } 93 99 /** 100 * @brief Longitude with East (+) and West (-) 101 */ 94 102 public function longitude() 95 103 { 96 104 return $this->_longitude; 97 }98 99 public function longitudeDirection()100 {101 return $this->_longitudeDirection;102 105 } 103 106 … … 162 165 private $_status; 163 166 private $_latitude; 164 private $_latitudeDirection;165 167 private $_longitude; 166 private $_longitudeDirection;167 168 private $_speedOverGround; 168 169 private $_courseOverGround; -
src/webapp/webservice/inc/GnuBoat/Nmea/Nmea0183/Parser.php
rfc63b30 r008bce9 35 35 $result = array(); 36 36 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; 38 38 error_log($message); 39 39 if($debug > 0) 40 print $message ;40 print $message ."\n"; 41 41 return $result; 42 42 } … … 44 44 $fileHandler = fopen($file, 'r'); 45 45 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; 47 47 error_log($message); 48 48 if($debug > 0) 49 print $message ;49 print $message ."\n"; 50 50 return $result; 51 51 } … … 61 61 $result[] = $parsedSentence; 62 62 else{ 63 $message = "Skipped sentence on line ". $line .": ". $sentence ."\n";63 $message = "Skipped sentence on line ". $line .": ". $sentence; 64 64 error_log($message); 65 65 if($debug > 0) 66 print $message ;66 print $message ."\n"; 67 67 } 68 68 } … … 75 75 $sentence = trim($sentence); 76 76 if(empty($sentence)){ 77 $message = "Empty sentence \n";77 $message = "Empty sentence"; 78 78 error_log($message); 79 79 if($debug > 0) 80 print $message ;80 print $message ."\n"; 81 81 return null; 82 82 } … … 85 85 $result = preg_match('/^[\$!]{1}([\w]{2})([\w]{3})([^\*]+)\*([\da-zA-Z]+)$/', $sentence, $matches); 86 86 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; 88 88 error_log($message); 89 89 if($debug > 0) 90 print $message ;90 print $message ."\n"; 91 91 return null; 92 92 } … … 97 97 98 98 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; 100 100 error_log($message); 101 101 if($debug > 0) 102 print $message ;102 print $message ."\n"; 103 103 return null; 104 104 } -
src/webapp/webservice/inc/GnuBoat/Nmea/NmeaSentence.php
rfc63b30 r008bce9 48 48 public function type() 49 49 { 50 return $this->_type;50 return strtolower($this->_type); 51 51 } 52 52 -
src/webapp/webservice/inc/GnuBoat/Service.php
rfc63b30 r008bce9 44 44 $this->process(); 45 45 } 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 } 46 57 47 58 /** -
src/webapp/webservice/inc/GnuBoat/ServiceData.php
rfc63b30 r008bce9 49 49 50 50 if(!file_exists($dbFile)){ 51 echo json_encode("");52 51 if($debug > 0) 53 52 echo "Database file ". $dbFile ." does not exist!"; 54 53 error_log("Database file ". $dbFile ." does not exist"); 55 exit;54 return; 56 55 } 57 56 // Fetch entries of the last 30s with maximum (available) resolution of 2s -
src/webapp/webservice/inc/GnuBoat/ServiceLogFiles.php
rfc63b30 r008bce9 32 32 $debug = $this->debug(); 33 33 $config = new Config(); 34 if($debug > 1) 35 print "Log directory: ". $config->logDirectory() ."\n"; 34 36 35 37 if(!array_key_exists("logfilesSelected", $_POST)){ -
src/webapp/webservice/inc/GnuBoat/Webservice.php
rfc63b30 r008bce9 23 23 class WebService 24 24 { 25 function __construct( )25 function __construct($debug) 26 26 { 27 27 $this->_requests = array(); … … 30 30 $this->_requests["logfiles"] = "GnuBoat\ServiceLogFiles"; 31 31 $this->_requests["map"] = "GnuBoat\ServiceMap"; 32 $this->_requests["replay"] = "GnuBoat\ServiceReplay"; 33 34 $this->_debug = $debug; 32 35 } 33 36 34 37 public function process() 35 38 { 36 $debug = 0;37 if(is_array($_GET) && array_key_exists("debug", $_GET))38 $debug = $_GET["debug"];39 40 39 $request = array_keys($this->_requests)[0]; 41 40 if(is_array($_GET) && array_key_exists("request", $_GET)){ … … 44 43 45 44 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"); 52 46 } 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); 55 49 } 56 50 57 51 private $_requests; 52 private $_debug; 58 53 } 59 54 -
src/webapp/webservice/index.php
rfc63b30 r008bce9 19 19 require_once(__DIR__ ."/inc/autoloader.php"); 20 20 21 $webservice = new GnuBoat\Webservice(); 21 $debug = 0; 22 if(array_key_exists("debug", $_GET)) 23 $debug = $_GET["debug"]; 24 25 $webservice = new GnuBoat\Webservice($debug); 22 26 $webservice->process(); 23 27 -
src/webapp/webservice/tests/Nmea0183DptTest.php
rfc63b30 r008bce9 46 46 { 47 47 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], 52 52 ]; 53 53 } -
src/webapp/webservice/tests/Nmea0183MtwTest.php
rfc63b30 r008bce9 46 46 { 47 47 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], 52 52 ]; 53 53 } -
src/webapp/webservice/tests/Nmea0183RmcTest.php
rfc63b30 r008bce9 49 49 $this->assertEquals($sentence->status(), $status); 50 50 $this->assertEquals($latitude, $sentence->latitude()); 51 $this->assertEquals($latitudeDirection, $sentence->latitudeDirection());52 51 $this->assertEquals($longitude, $sentence->longitude()); 53 $this->assertEquals($longitudeDirection, $sentence->longitudeDirection());54 52 $this->assertEquals($speedOverGround, $sentence->speedOverGround()); 55 53 $this->assertEquals($courseOverGround, $sentence->courseOverGround()); … … 71 69 "wrong_data_count" => [ 72 70 '$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, 74 72 GnuBoat\Nmea\Nmea0183\Nmea0183RmcStatus::V, 0, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::Invalid, 75 73 0, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::Invalid, … … 79 77 "wrong_checksum" => [ 80 78 '$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")), 82 80 GnuBoat\Nmea\Nmea0183\Nmea0183RmcStatus::A, 5230.59, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::North, 83 81 1322.39, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East, … … 87 85 "valid1" => [ 88 86 '$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")), 90 88 GnuBoat\Nmea\Nmea0183\Nmea0183RmcStatus::A, 5230.59, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::North, 91 89 1322.39, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East, … … 94 92 ], 95 93 "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, 100 98 10, 90, 1.2, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East, 101 GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::AutonomousMode, 13, true99 GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::AutonomousMode, '1c', true 102 100 ], 103 101 "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")), 106 104 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, 108 106 10, 90, 1.2, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East, 109 GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::AutonomousMode, ' d', true107 GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::AutonomousMode, '1f', true 110 108 ] 111 109 ]; -
src/webapp/webservice/tests/NmeaTest.php
rfc63b30 r008bce9 20 20 // declare(Strict_types=1); 21 21 22 /** 23 * @brief Covers Parser.php 24 */ 25 final class NmeaTest extends PHPUnit_Framework_TestCase 22 namespace GnuBoat\Nmea 26 23 { 24 27 25 /** 28 * @dataProvider formatsProvider29 */30 public function testFormats($format)26 * @brief Covers Parser.php 27 */ 28 final class NmeaTest extends \PHPUnit_Framework_TestCase 31 29 { 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 } 41 94 } 42 95 43 /** 44 * @dataProvider nmeaSentenceProvider 45 */ 46 public function testNmeaSentence($format, $sentence, $classType, $valid) 96 function error_log($msg) 47 97 { 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"; 58 99 } 59 60 public function nmeaSentenceProvider() 100 } 101 102 namespace GnuBoat\Nmea\Nmea0183 103 { 104 function error_log($msg) 61 105 { 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"; 90 107 } 91 108 } -
src/webapp/webservice/tests/ServiceTest.php
rfc63b30 r008bce9 20 20 // declare(Strict_types=1); 21 21 22 namespace GnuBoat; 23 22 24 /** 23 * @brief Covers index.php tests25 * @brief Covers Service.php tests 24 26 */ 25 final class ServiceTest extends PHPUnit_Framework_TestCase27 final class ServiceTest extends \PHPUnit_Framework_TestCase 26 28 { 27 29 public function testData() 28 30 { 29 $webservice = new GnuBoat\Webservice();30 $this->assertInstanceOf( GnuBoat\Webservice::class, $webservice);31 $webservice = new Webservice(0); 32 $this->assertInstanceOf(Webservice::class, $webservice); 31 33 $_POST["request"] = "data"; 32 34 $webservice->process(); … … 35 37 public function testLogFiles() 36 38 { 37 $webservice = new GnuBoat\Webservice();38 $this->assertInstanceOf( GnuBoat\Webservice::class, $webservice);39 $webservice = new Webservice(0); 40 $this->assertInstanceOf(Webservice::class, $webservice); 39 41 $_POST["request"] = "logfiles"; 40 42 $webservice->process(); … … 43 45 public function testShutdown() 44 46 { 45 $webservice = new GnuBoat\Webservice();46 $this->assertInstanceOf( GnuBoat\Webservice::class, $webservice);47 $webservice = new Webservice(0); 48 $this->assertInstanceOf(Webservice::class, $webservice); 47 49 $_POST["request"] = "shutdown"; 48 50 $webservice->process(); … … 51 53 public function testMap() 52 54 { 53 $webservice = new GnuBoat\Webservice();54 $this->assertInstanceOf( GnuBoat\Webservice::class, $webservice);55 $webservice = new Webservice(0); 56 $this->assertInstanceOf(Webservice::class, $webservice); 55 57 $_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"; 56 66 $webservice->process(); 57 67 } 58 68 } 59 69 70 function error_log($msg) 71 { 72 echo "ERR GnuBoat: ". $msg ."\n"; 73 } 74 60 75 ?>
Note:
See TracChangeset
for help on using the changeset viewer.
