Skip to content
Browse files

implemented filter_list

  • Loading branch information...
1 parent c8fe63b commit 7202f3edd07f906cb3c5bd672327a988665a5f93 @ahamid ahamid committed
View
5 src/main/java/com/caucho/quercus/lib/filter/FilterModule.java
@@ -29,6 +29,7 @@
package com.caucho.quercus.lib.filter;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@@ -39,6 +40,7 @@
import com.caucho.quercus.env.CompiledConstStringValue;
import com.caucho.quercus.env.Env;
import com.caucho.quercus.env.EnvVar;
+import com.caucho.quercus.env.JavaCollectionAdapter;
import com.caucho.quercus.env.LongValue;
import com.caucho.quercus.env.StringValue;
import com.caucho.quercus.env.Value;
@@ -318,7 +320,8 @@ public Value filter_input(Env env, IntegerValue type,
*/
public ArrayValue filter_list(Env env)
{
- throw new UnimplementedException();
+ ArrayList<Object> filter_names = new ArrayList<Object>(_filterList.keySet());
+ return new JavaCollectionAdapter(filter_names, env.getJavaClassDefinition(filter_names.getClass()));
}
/**
View
13 src/test/java/com/caucho/quercus/lib/filter/TestQuercusFilter.java
@@ -1,6 +1,10 @@
package com.caucho.quercus.lib.filter;
import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
import java.util.Map;
import javax.script.ScriptException;
@@ -50,4 +54,13 @@ public void test_filter_id() throws ScriptException {
Assert.assertEquals(entry.getValue().longValue(), eval("return filter_id(''{0}'');",entry.getKey()));
}
}
+
+ @Test
+ public void test_filter_list() throws ScriptException {
+ List<String> result = new ArrayList<String>((Collection<String>) eval("return filter_list();"));
+ List<String> expected = new ArrayList<String>(FilterModule._filterList.keySet());
+ Collections.sort(result);
+ Collections.sort(expected);
+ Assert.assertEquals(expected, result);
+ }
}

0 comments on commit 7202f3e

Please sign in to comment.
Something went wrong with that request. Please try again.