source: src/webapp/webservice/tests/Nmea0183RmcTest.php@ 0662b2d

0.5 debian/bullseye debian/jessie
Last change on this file since 0662b2d was 008bce9, checked in by Joachim Langenbach <joachim.langenbach@…>, 9 years ago

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

  • Property mode set to 100644
File size: 5.0 KB
RevLine 
[86442cb]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
22/**
23 * @brief Covers Nmea0183Rmc.php
24 */
25final class Nmea0183RmcTest extends PHPUnit_Framework_TestCase
26{
27 /**
28 * @dataProvider rmcProvider
29 */
30 public function testRmc($sentence, $talker, $type, $dateTimeUtc, $status, $latitude, $latitudeDirection,
31 $longitude, $longitudeDirection, $speedOverGround, $courseOverGround,
32 $magneticalDeclination, $magneticalDeclinationDirection, $signalIntegrity,
33 $checksum, $valid)
34 {
35 $format = 'Y-m-d H:i:s';
36
37 $parser = new GnuBoat\Nmea\Parser();
38 $sentence = $parser->parseSentence($sentence, "0183");
39 $this->assertInstanceOf(GnuBoat\Nmea\Nmea0183\Nmea0183Rmc::class, $sentence);
40 $this->assertEquals($talker, $sentence->talker());
41 $this->assertEquals($type, $sentence->type());
42 $dateTime = $sentence->dateTime();
43 if($dateTimeUtc == null)
44 $this->assertNull($dateTime);
45 else{
46 $this->assertInstanceOf(DateTime::class, $dateTime);
47 $this->assertEquals($dateTimeUtc->format($format), $dateTime->format($format));
48 }
49 $this->assertEquals($sentence->status(), $status);
50 $this->assertEquals($latitude, $sentence->latitude());
51 $this->assertEquals($longitude, $sentence->longitude());
52 $this->assertEquals($speedOverGround, $sentence->speedOverGround());
53 $this->assertEquals($courseOverGround, $sentence->courseOverGround());
54 $this->assertEquals($magneticalDeclination, $sentence->magneticDeclination());
55 $this->assertEquals($magneticalDeclinationDirection, $sentence->magneticDeclinationDirection());
56 $this->assertEquals($signalIntegrity, $sentence->signalIntegrity());
57 $this->assertEquals($checksum, $sentence->checksum());
58 $message = "";
59 $result = $sentence->valid($message);
60 $this->assertEquals($valid, $result, $message);
61 }
62
63 public function rmcProvider()
64 {
65 $format = 'Y-m-d H:i:s';
66 $formatMilli = 'Y-m-d H:i:s.u';
67
68 return [
69 "wrong_data_count" => [
70 '$GPRMC,162614,A,N,01322.3900,E,10.0,90.0,131006,1.2,E,A*13',
[008bce9]71 "GP", "rmc", null,
[86442cb]72 GnuBoat\Nmea\Nmea0183\Nmea0183RmcStatus::V, 0, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::Invalid,
73 0, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::Invalid,
74 0, 0, 0, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::Invalid,
75 GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::DataNotValid, 13, false
76 ],
77 "wrong_checksum" => [
78 '$GPRMC,162614,A,5230.5900,N,01322.3900,E,10.0,90.0,131006,1.2,E,A*22',
[008bce9]79 "GP", "rmc", DateTime::createFromFormat($format, "2006-10-13 16:26:14", new DateTimeZone("UTC")),
[86442cb]80 GnuBoat\Nmea\Nmea0183\Nmea0183RmcStatus::A, 5230.59, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::North,
81 1322.39, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
82 10, 90, 1.2, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
83 GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::AutonomousMode, 22, false
84 ],
85 "valid1" => [
86 '$GPRMC,162614,A,5230.5900,N,01322.3900,E,10.0,90.0,131006,1.2,E,A*13',
[008bce9]87 "GP", "rmc", DateTime::createFromFormat($format, "2006-10-13 16:26:14", new DateTimeZone("UTC")),
[86442cb]88 GnuBoat\Nmea\Nmea0183\Nmea0183RmcStatus::A, 5230.59, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::North,
89 1322.39, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
90 10, 90, 1.2, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
91 GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::AutonomousMode, 13, true
92 ],
93 "valid2" => [
[008bce9]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,
[86442cb]98 10, 90, 1.2, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
[008bce9]99 GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::AutonomousMode, '1c', true
[86442cb]100 ],
101 "valid3" => [
[008bce9]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")),
[86442cb]104 GnuBoat\Nmea\Nmea0183\Nmea0183RmcStatus::A, 5230.59, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::North,
[008bce9]105 -1322.39, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
[86442cb]106 10, 90, 1.2, GnuBoat\Nmea\Nmea0183\Nmea0183Direction::East,
[008bce9]107 GnuBoat\Nmea\Nmea0183\Nmea0183RmcSignal::AutonomousMode, '1f', true
[86442cb]108 ]
109 ];
110 }
111}
112
113?>
Note: See TracBrowser for help on using the repository browser.