@@ -16,33 +16,83 @@ public function testIdCanBeSet()
1616 $ action = new Action (array ('ActionID ' => '123 ' ));
1717
1818 $ this ->assertEquals ('123 ' , $ action ->getActionId ());
19+
20+ $ this ->assertEquals ('123 ' , $ action ->getFieldValue ('ActionID ' ));
21+ $ this ->assertEquals ('123 ' , $ action ->getFieldValue ('aCtIoNiD ' ));
22+
23+ $ this ->assertNull ($ action ->getFieldValue ('unknown ' ));
1924 }
2025
21- public function testSerializeSimple ()
26+ public function testOneFieldValue ()
2227 {
2328 $ action = new Action (array ('Action ' => 'name ' ));
2429
2530 $ this ->assertEquals ("Action: name \r\n\r\n" , $ action ->getMessageSerialized ());
31+
32+ $ this ->assertEquals ('name ' , $ action ->getFieldValue ('Action ' ));
33+ $ this ->assertEquals (array ('name ' ), $ action ->getFieldValues ('Action ' ));
34+
35+ $ this ->assertEquals (null , $ action ->getFieldValue ('unknown ' ));
36+ $ this ->assertEquals (array (), $ action ->getFieldValues ('unknown ' ));
2637 }
2738
28- public function testSerializeKeySingle ()
39+ public function testMultipleFieldsSingleValue ()
2940 {
3041 $ action = new Action (array ('Action ' => 'name ' , 'Key ' => 'Value ' ));
3142
3243 $ this ->assertEquals ("Action: name \r\nKey: Value \r\n\r\n" , $ action ->getMessageSerialized ());
3344 }
3445
35- public function testSerializeKeyMultipleValues ()
46+ public function testOneFieldNoValue ()
47+ {
48+ $ action = new Action (array ('Key ' => null ));
49+
50+ $ this ->assertEquals ("\r\n" , $ action ->getMessageSerialized ());
51+
52+ $ this ->assertNull ($ action ->getFieldValue ('Key ' ));
53+ $ this ->assertEquals (array (), $ action ->getFieldValues ('Key ' ));
54+ }
55+
56+ public function testOneFieldNoValues ()
57+ {
58+ $ action = new Action (array ('Key ' => array ()));
59+
60+ $ this ->assertEquals ("\r\n" , $ action ->getMessageSerialized ());
61+
62+ $ this ->assertNull ($ action ->getFieldValue ('Key ' ));
63+ $ this ->assertEquals (array (), $ action ->getFieldValues ('Key ' ));
64+ }
65+
66+ public function testOneFieldMultipleValues ()
3667 {
37- $ action = new Action (array ('Action ' => ' name ' , ' Key ' => array ('Value1 ' , 'Value2 ' )));
68+ $ action = new Action (array ('Key ' => array ('Value1 ' , 'Value2 ' )));
3869
39- $ this ->assertEquals ("Action: name \r\nKey: Value1 \r\nKey: Value2 \r\n\r\n" , $ action ->getMessageSerialized ());
70+ $ this ->assertEquals ("Key: Value1 \r\nKey: Value2 \r\n\r\n" , $ action ->getMessageSerialized ());
71+
72+ $ this ->assertEquals ('Value1 ' , $ action ->getFieldValue ('Key ' ));
73+ $ this ->assertEquals (array ('Value1 ' , 'Value2 ' ), $ action ->getFieldValues ('Key ' ));
4074 }
4175
42- public function testSerializeKeyMultipleKeyValues ()
76+ public function testOneFieldMultipleValuesIgnoreNulls ()
4377 {
44- $ action = new Action (array ('Action ' => 'name ' , 'Variables ' => array ('first ' => 'on ' , 'second ' => 'off ' )));
78+ $ action = new Action (array ('Key ' => array (null , 'value ' , null )));
79+
80+ $ this ->assertEquals ("Key: value \r\n\r\n" , $ action ->getMessageSerialized ());
81+
82+ $ this ->assertEquals ('value ' , $ action ->getFieldValue ('Key ' ));
83+ $ this ->assertEquals (array ('value ' ), $ action ->getFieldValues ('Key ' ));
84+ }
85+
86+ public function testOneFieldMultipleKeyValues ()
87+ {
88+ $ action = new Action (array ('Variables ' => array ('first ' => 'on ' , 'second ' => 'off ' )));
89+
90+ $ this ->assertEquals ("Variables: first=on \r\nVariables: second=off \r\n\r\n" , $ action ->getMessageSerialized ());
91+
92+ $ this ->assertEquals ('first=on ' , $ action ->getFieldValue ('Variables ' ));
93+ $ this ->assertEquals (array ('first=on ' , 'second=off ' ), $ action ->getFieldValues ('Variables ' ));
4594
46- $ this ->assertEquals ("Action: name \r\nVariables: first=on \r\nVariables: second=off \r\n\r\n" , $ action ->getMessageSerialized ());
95+ $ this ->assertEquals (array ('first ' => 'on ' , 'second ' => 'off ' ), $ action ->getFieldVariables ('Variables ' ));
96+ $ this ->assertEquals (array (), $ action ->getFieldVariables ('unknown ' ));
4797 }
4898}
0 commit comments