dummy callref support
[auerswald-callnotifier.git] / tests / callnotifier / EDSS1 / ParserTest.php
1 <?php
2 namespace callnotifier;
3
4 class EDSS1_ParserTest extends \PHPUnit_Framework_TestCase
5 {
6     protected function parseMsg($bs)
7     {
8         $p = new EDSS1_Parser();
9         $msg = $p->parse(MessageHandler::getBytesFromHexString($bs));
10         self::assertInstanceOf('callnotifier\EDSS1_Message', $msg);
11         return $msg;
12     }
13
14     public function testParse()
15     {
16         $msg = $this->parseMsg(
17             '00 A3 02 02 08 01 01 7B 70 0C 81 30 31 36 33 34 37 37 39 38 37 38 FF 0A'
18         );
19
20         self::assertEquals(0, $msg->sapi, 'SAPI is wrong');
21         self::assertEquals(81, $msg->tei, 'TEI is wrong');
22         self::assertEquals(123, $msg->type, 'Message type is wrong');
23
24         self::assertEquals(1, $msg->callRef, 'Call reference is wrong');
25         self::assertEquals(0, $msg->callRefType, 'Call reference type is wrong');
26
27         self::assertEquals(1, count($msg->parameters), 'Wrong parameter count');
28         $p = $msg->parameters[0];
29         self::assertInstanceOf('callnotifier\EDSS1_Parameter', $p);
30         self::assertEquals(112, $p->type, 'Type of 1st parameter is wrong');
31         self::assertEquals("\x8101634779878", $p->data, 'Parameter data is wrong');
32     }
33
34     public function testParseSAPI()
35     {
36         $msg = $this->parseMsg('FC A3 02 02 08 FF 0A');
37
38         //SAPI: 0xFC = 252. 252 >> 2 = 63
39         self::assertEquals(63, $msg->sapi, 'SAPI is wrong');
40         self::assertEquals(0, $msg->callResponse, 'CR-bit is wrong');
41     }
42
43     public function testParseCallResponse()
44     {
45         $msg = $this->parseMsg('FE A3 02 02 08 FF 0A');
46
47         //SAPI: 0xFE = 254. 254 & 2 = 2 -> cr bit set
48         self::assertEquals(63, $msg->sapi, 'SAPI is wrong');
49         self::assertEquals(1, $msg->callResponse, 'CR-bit is wrong');
50     }
51
52     public function testParseCallRefType()
53     {
54         $msg = $this->parseMsg('00 97 16 4C 08 01 81 45 08 02 80 90 FF 0A');
55         self::assertEquals(1, $msg->callRef, 'Call reference is wrong');
56         self::assertEquals(1, $msg->callRefType, 'Call reference type is wrong');
57
58         $msg = $this->parseMsg('00 97 16 4C 08 01 85 45 08 02 80 90 FF 0A');
59         self::assertEquals(5, $msg->callRef, 'Call reference is wrong');
60         self::assertEquals(1, $msg->callRefType, 'Call reference type is wrong');
61
62         $msg = $this->parseMsg('00 97 16 4C 08 01 05 45 08 02 80 90 FF 0A');
63         self::assertEquals(5, $msg->callRef, 'Call reference is wrong');
64         self::assertEquals(0, $msg->callRefType, 'Call reference type is wrong');
65     }
66
67     public function testParseCallRefLong()
68     {
69         $msg = $this->parseMsg('00 97 16 4C 08 02 05 06 45 08 02 80 90 FF 0A');
70         self::assertEquals(0x0506, $msg->callRef, 'Call reference is wrong');
71         self::assertEquals(0, $msg->callRefType, 'Call reference type is wrong');
72
73         $msg = $this->parseMsg('00 97 16 4C 08 02 85 06 45 08 02 80 90 FF 0A');
74         self::assertEquals(0x0506, $msg->callRef, 'Call reference is wrong');
75         self::assertEquals(1, $msg->callRefType, 'Call reference type is wrong');
76
77         $msg = $this->parseMsg('00 97 16 4C 08 03 85 06 07 45 08 02 80 90 FF 0A');
78         self::assertEquals(0x050607, $msg->callRef, 'Call reference is wrong');
79         self::assertEquals(1, $msg->callRefType, 'Call reference type is wrong');
80     }
81
82     public function testParseCallRefDummy()
83     {
84         $msg = $this->parseMsg(
85             '02 FF FF 03 08 00 62 1C 12 91 A1 0F 02 02 41 06 06 06 04 00 82 67 01 0A 02 01 01 70 0B A1 33 34 32 36 31 34 30 38 36 32 FF 0A'
86         );
87     }
88 }
89
90 ?>