source: src/webapp/webservice/tests/Nmea0183DptTest.php@ 9f5877d

debian/bullseye
Last change on this file since 9f5877d was c0e66e6, checked in by Joachim Langenbach <joachim.langenbach@…>, 8 years ago
  • Updated Tests to work with PHP 7
    • Added phing phar which works with PHP7 as a choice for the developer
    • Updated phpunit to 7.4.3 which works with PHP7 and removed old PHPUnit version
    • Updated test cases to work with PHPUnit 7.4.3
  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[86442cb]1<?php
2/*
[c0e66e6]3 Copyright (C) 2017 - 2018 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
[86442cb]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]20declare(Strict_types=1);
21use PHPUnit\Framework\TestCase;
[86442cb]22
23/**
24 * @brief Covers Nmea0183Dpt.php
25 */
[c0e66e6]26final class Nmea0183DptTest extends TestCase
[86442cb]27{
28 /**
29 * @dataProvider dptProvider
30 */
31 public function testDpt($sentence, $talker, $type, $depth, $offset, $checksum, $valid)
32 {
33 $parser = new GnuBoat\Nmea\Parser(0);
34 $sentence = $parser->parseSentence($sentence, "0183");
35 $this->assertInstanceOf(GnuBoat\Nmea\Nmea0183\Nmea0183Dpt::class, $sentence);
36 $this->assertEquals($talker, $sentence->talker());
37 $this->assertEquals($type, $sentence->type());
38 $this->assertEquals($depth, $sentence->depth());
39 $this->assertEquals($offset, $sentence->offset());
40 $this->assertEquals($checksum, $sentence->checksum());
41 $message = "";
42 $result = $sentence->valid($message);
43 $this->assertEquals($valid, $result, $message);
44 }
45
46 public function dptProvider()
47 {
48 return [
[008bce9]49 "wrong_data_count" => ['$SDDPT,00.71,00.71,00.00*51', 'SD', 'dpt', 0, 0, 51, false],
50 "wrong_checksum" => ['$SDDPT,00.71,00.00*22', 'SD', 'dpt', 0.71, 0.0, 22, false],
51 "valid1" => ['$SDDPT,00.71,00.00*51', 'SD', 'dpt', 0.71, 0.0, 51, true],
52 "valid2" => ['!SDDPT,00.71,00.00*51', 'SD', 'dpt', 0.71, 0.0, 51, true],
[86442cb]53 ];
54 }
55}
56
57?>
Note: See TracBrowser for help on using the repository browser.