source: src/webapp/webservice/tests/Nmea0183MtwTest.php@ 37f674d

debian/bullseye
Last change on this file since 37f674d 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: 1.9 KB
Line 
1<?php
2/*
3 Copyright (C) 2017 - 2018 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
20declare(Strict_types=1);
21use PHPUnit\Framework\TestCase;
22
23/**
24 * @brief Covers Nmea0183Mtw.php
25 */
26final class Nmea0183MtwTest extends TestCase
27{
28 /**
29 * @dataProvider mtwProvider
30 */
31 public function testMtw($sentence, $talker, $type, $temperature, $unit, $checksum, $valid)
32 {
33 $parser = new GnuBoat\Nmea\Parser(0);
34 $sentence = $parser->parseSentence($sentence, "0183");
35 $this->assertInstanceOf(GnuBoat\Nmea\Nmea0183\Nmea0183Mtw::class, $sentence);
36 $this->assertEquals($talker, $sentence->talker());
37 $this->assertEquals($type, $sentence->type());
38 $this->assertEquals($temperature, $sentence->temperature());
39 $this->assertEquals($unit, $sentence->unit());
40 $this->assertEquals($checksum, $sentence->checksum());
41 $message = "";
42 $result = $sentence->valid($message);
43 $this->assertEquals($valid, $result, $message);
44 }
45
46 public function mtwProvider()
47 {
48 return [
49 "wrong_data_count" => ['$YXMTW,C*15', 'YX', 'mtw', 0, '', 15, false],
50 "wrong_checksum" => ['$YXMTW,26.3,C*22', 'YX', 'mtw', 26.3, 'C', 22, false],
51 "valid1" => ['$YXMTW,26.3,C*15', 'YX', 'mtw', 26.3, 'C', 15, true],
52 "valid2" => ['!YXMTW,26.3,C*15', 'YX', 'mtw', 26.3, 'C', 15, true],
53 ];
54 }
55}
56
57?>
Note: See TracBrowser for help on using the repository browser.