@@ -16,6 +16,11 @@ 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
2126 public function testOneFieldValue ()
@@ -32,17 +37,46 @@ public function testMultipleFieldsSingleValue()
3237 $ this ->assertEquals ("Action: name \r\nKey: Value \r\n\r\n" , $ action ->getMessageSerialized ());
3338 }
3439
40+ public function testOneFieldNoValue ()
41+ {
42+ $ action = new Action (array ('Key ' => null ));
43+
44+ $ this ->assertEquals ("\r\n" , $ action ->getMessageSerialized ());
45+
46+ $ this ->assertNull ($ action ->getFieldValue ('Key ' ));
47+ }
48+
49+ public function testOneFieldNoValues ()
50+ {
51+ $ action = new Action (array ('Key ' => array ()));
52+
53+ $ this ->assertEquals ("\r\n" , $ action ->getMessageSerialized ());
54+
55+ $ this ->assertNull ($ action ->getFieldValue ('Key ' ));
56+ }
57+
3558 public function testOneFieldMultipleValues ()
3659 {
3760 $ action = new Action (array ('Key ' => array ('Value1 ' , 'Value2 ' )));
3861
3962 $ this ->assertEquals ("Key: Value1 \r\nKey: Value2 \r\n\r\n" , $ action ->getMessageSerialized ());
4063 }
4164
65+ public function testOneFieldMultipleValuesIgnoreNulls ()
66+ {
67+ $ action = new Action (array ('Key ' => array (null , 'value ' , null )));
68+
69+ $ this ->assertEquals ("Key: value \r\n\r\n" , $ action ->getMessageSerialized ());
70+
71+ $ this ->assertEquals ('value ' , $ action ->getFieldValue ('Key ' ));
72+ }
73+
4274 public function testOneFieldMultipleKeyValues ()
4375 {
4476 $ action = new Action (array ('Variables ' => array ('first ' => 'on ' , 'second ' => 'off ' )));
4577
4678 $ this ->assertEquals ("Variables: first=on \r\nVariables: second=off \r\n\r\n" , $ action ->getMessageSerialized ());
79+
80+ $ this ->assertEquals ('first=on ' , $ action ->getFieldValue ('Variables ' ));
4781 }
4882}
0 commit comments