PhpIniSensor implements Sensor { @Override public void execute(SensorContext context) { Checks<PhpIniCheck> checks = checkFactory .<PhpIniCheck>create(CheckList.REPOSITORY_KEY) .addAnnotatedChecks(CheckList.getPhpIniChecks()); execute(context, checks); } PhpIniSensor(CheckFactory checkFactory); @Override void describe(SensorDescriptor descriptor); @Override void execute(SensorContext context);  }
@Test public void single_file() throws Exception { File baseDir = new File("src/test/resources/phpini"); SensorContextTester context = SensorContextTester.create(baseDir); DefaultInputFile file1 = setupSingleFile(baseDir, context); sensor().execute(context, checks()); Collection<Issue> issues = context.allIssues(); assertThat(issues).hasSize(1); Issue issue = issues.iterator().next(); assertThat(issue.ruleKey().rule()).isEqualTo("rule1"); assertThat(issue.primaryLocation().inputComponent()).isEqualTo(file1); assertThat(issue.primaryLocation().message()).isEqualTo("message1"); TextRange textRange = issue.primaryLocation().textRange(); assertThat(textRange).isNotNull(); assertThat(textRange.start().line()).isEqualTo(2); }
@Test public void parse_error() throws Exception { File baseDir = new File("src/test/resources/phpini-error"); SensorContextTester context = SensorContextTester.create(baseDir); setupSingleFile(baseDir, context); sensor().execute(context, checks()); assertThat(logTester.logs()).contains("Unable to parse file: php.ini"); }