tmysik commented on a change in pull request #2535:
URL: https://github.com/apache/netbeans/pull/2535#discussion_r527877072



##########
File path: 
php/php.editor/test/unit/src/org/netbeans/modules/php/editor/CodeUtilsTest.java
##########
@@ -179,4 +183,43 @@ public void testCommonNamespacePrefixes11() {
         assertEquals(0, prefixes.size());
     }
 
+    public void testGetParamDefaultValueEmptyArray() {
+        List<ArrayElement> emptyArray = Collections.emptyList();
+        FormalParameter param = 
createFormalParameterWithDefaultArray(emptyArray);
+        assertEquals("[]", CodeUtils.getParamDefaultValue(param));
+    }
+
+    public void testGetParamDefaultValueArrayOneItem() {
+        Scalar value = new Scalar(1, 1, "'a'", Scalar.Type.STRING);
+        ArrayElement item = new ArrayElement(1, 1, null, value);
+        List<ArrayElement> array = Arrays.asList(item);
+        FormalParameter param = createFormalParameterWithDefaultArray(array);
+        assertEquals("['a']", CodeUtils.getParamDefaultValue(param));
+    }
+
+    public void testGetParamDefaultValueArrayTwoItems() {
+        Scalar value1 = new Scalar(1, 1, "'a'", Scalar.Type.STRING);
+        ArrayElement item1 = new ArrayElement(1, 1, null, value1);
+        Scalar value2 = new Scalar(1, 1, "'b'", Scalar.Type.STRING);
+        ArrayElement item2 = new ArrayElement(1, 1, null, value2);
+        List<ArrayElement> array = Arrays.asList(item1, item2);
+        FormalParameter param = createFormalParameterWithDefaultArray(array);
+        assertEquals("['a',...]", CodeUtils.getParamDefaultValue(param));
+    }
+
+    public void testGetParamDefaultValueArrayItemWithKey() {
+        Scalar key = new Scalar(1, 1, "3", Scalar.Type.INT);
+        Scalar value = new Scalar(1, 1, "'a'", Scalar.Type.STRING);
+        ArrayElement item = new ArrayElement(1, 1, key, value);
+        List<ArrayElement> array = Arrays.asList(item);
+        FormalParameter param = createFormalParameterWithDefaultArray(array);
+        assertEquals("[3 => 'a']", CodeUtils.getParamDefaultValue(param));
+    }
+
+    private FormalParameter 
createFormalParameterWithDefaultArray(List<ArrayElement> arrayContent) {
+        ArrayCreation defaultValue = new ArrayCreation(1, 1, arrayContent, 
ArrayCreation.Type.NEW);
+        FormalParameter param = new FormalParameter(1, 1, null, null, 
defaultValue);
+        return param;
+    }
+

Review comment:
       No. I meant his the tooltip would look like for array e.g. `[0 => new 
DateTime()]`. Just to verify that it still looks ok. Thanks and sorry for not 
being clear.
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to