PhpPlugin implements Plugin { @Override public void define(Context context) { context.addExtensions( Php.class, PHPSensor.class, PhpIniSensor.class, PHPRulesDefinition.class, PHPProfileDefinition.class, PSR2ProfileDefinition.class, DrupalProfileDefinition.class, PhpExclusionsFileFilter.class, PropertyDefinition.builder(FILE_SUFFIXES_KEY) .defaultValue(Php.DEFAULT_FILE_SUFFIXES) .name("File Suffixes") .description("List of suffixes of PHP files to analyze.") .onQualifiers(Qualifiers.MODULE, Qualifiers.PROJECT) .category(PHP_CATEGORY) .multiValues(true) .subCategory(GENERAL_SUBCATEGORY) .build(), PropertyDefinition.builder(PHP_EXCLUSIONS_KEY) .defaultValue(PHP_EXCLUSIONS_DEFAULT_VALUE) .name("PHP Exclusions") .description("List of file path patterns to be excluded from analysis of PHP files.") .onQualifiers(Qualifiers.MODULE, Qualifiers.PROJECT) .category(PHP_CATEGORY) .subCategory(GENERAL_SUBCATEGORY) .multiValues(true) .build() ); if (context.getRuntime().getProduct() != SonarProduct.SONARLINT) { context.addExtension( PropertyDefinition.builder(PHPUNIT_TESTS_REPORT_PATH_KEY) .name("Unit Test Report") .description("Path to the PHPUnit unit test execution report file. The path may be either absolute or relative to the project base directory.") .onQualifiers(Qualifiers.MODULE, Qualifiers.PROJECT) .category(PHP_CATEGORY) .subCategory(PHPUNIT_SUBCATEGORY) .build()); } context.addExtension(PropertyDefinition.builder(PHPUNIT_COVERAGE_REPORT_PATHS_KEY) .name("Coverage Reports") .description("List of PHPUnit code coverage report files. Each path can be either absolute or relative.") .onQualifiers(Qualifiers.MODULE, Qualifiers.PROJECT) .category(PHP_CATEGORY) .multiValues(true) .subCategory(PHPUNIT_SUBCATEGORY) .build()); }  @Override void define(Context context); static final String FILE_SUFFIXES_KEY; static final String PHPUNIT_COVERAGE_REPORT_PATHS_KEY; static final String PHPUNIT_TESTS_REPORT_PATH_KEY; static final String PHP_EXCLUSIONS_KEY; static final String PHP_EXCLUSIONS_DEFAULT_VALUE; static final String PHP_CATEGORY; static final String GENERAL_SUBCATEGORY; static final String PHPUNIT_SUBCATEGORY; }
@Test public void test() { Plugin.Context context = qubeContext(Version.create(6, 7)); plugin.define(context); assertThat(context.getExtensions()).hasSize(12); }
@Test public void test_sonarlint() { SonarRuntime runtime = SonarRuntimeImpl.forSonarLint(Version.create(6, 7)); Plugin.Context context = new Plugin.Context(runtime); plugin.define(context); assertThat(context.getExtensions()).hasSize(11); }
@Test public void should_contain_REPORT_PATHS_from_6_2() throws Exception { Plugin.Context context67 = qubeContext(Version.create(6, 7)); plugin.define(context67); assertThat(extensionKeysOf(context67)).contains(PhpPlugin.PHPUNIT_COVERAGE_REPORT_PATHS_KEY); assertThat(extensionKeysOf(context67)).doesNotContain("sonar.php.coverage.reportPath"); }