Php extends AbstractLanguage { public boolean hasValidSuffixes(String fileName) { String pathLowerCase = StringUtils.lowerCase(fileName); for (String suffix : getFileSuffixes()) { if (pathLowerCase.endsWith("." + StringUtils.lowerCase(suffix))) { return true; } } return false; } Php(Configuration settings); @Override String[] getFileSuffixes(); boolean hasValidSuffixes(String fileName); static final String NAME; static final String KEY; static final String DEFAULT_FILE_SUFFIXES; }
@Test public void shouldCheckDefaultValidPhpExtensions() { Php php = new Php(new MapSettings().asConfig()); assertTrue(php.hasValidSuffixes("goodExtension.php")); assertTrue(php.hasValidSuffixes("goodExtension.php5")); assertTrue(php.hasValidSuffixes("goodExtension.inc")); assertFalse(php.hasValidSuffixes("wrong.extension")); assertFalse(php.hasValidSuffixes("goodExtension.java")); assertFalse(php.hasValidSuffixes("goodExtension.cs")); assertFalse(php.hasValidSuffixes("goodExtension.php7")); }
@Test public void shouldCheckCustomValidPhpExtensions() { MapSettings settings = new MapSettings(); settings.setProperty(PhpPlugin.FILE_SUFFIXES_KEY, " php6 , php7, , "); Php php = new Php(settings.asConfig()); assertTrue(php.hasValidSuffixes("goodExtension.php6")); assertTrue(php.hasValidSuffixes("goodExtension.php7")); }