@Test
  public void testShouldNotRunOnJavaProject() {
    when(fs.files(any(FileQuery.class))).thenReturn(ImmutableList.<java.io.File>of());
    assertThat(sensor.shouldExecuteOnProject(null)).isFalse();

    when(fs.files(any(FileQuery.class))).thenReturn(ImmutableList.of(new java.io.File("file.php")));
    assertThat(sensor.shouldExecuteOnProject(null)).isTrue();
  }
  @Test
  public void testAnalyseEmptySourceFiles() {
    File fakeFile = new File("fake.php");
    ModuleFileSystem localFs = mock(ModuleFileSystem.class);
    when(fs.sourceDirs()).thenReturn(ImmutableList.of(new File("fake/directory/")));
    when(fs.files(any(FileQuery.class))).thenReturn(ImmutableList.of(fakeFile, new File("fake")));

    NoSonarAndCommentedOutLocSensor localSensor =
        new NoSonarAndCommentedOutLocSensor(localFs, noSonarFilter);
    localSensor.analyse(project, context);
    verify(context, never())
        .saveMeasure(
            any(Resource.class), any(org.sonar.api.measures.Metric.class), any(Double.class));
  }
 @Test
 public void testAnalyseSourceCodeWithNoNoSonar() {
   File file = new File(this.getClass().getResource("/Math3.php").getPath());
   Source source = NoSonarAndCommentedOutLocSensor.analyseSourceCode(file);
   assertEquals(0, source.getNoSonarTagLines().size());
   assertEquals(5, source.getMeasure(Metric.COMMENTED_OUT_CODE_LINES));
 }
  // TEST for SONARPLUGINS-662
  @Test
  public void testAnalyseSourceCodeWithMultiLineString() {
    File file = new File(this.getClass().getResource("/Math4.php").getPath());
    Source source = NoSonarAndCommentedOutLocSensor.analyseSourceCode(file);
    assertEquals(1, source.getNoSonarTagLines().size());
    assertEquals(91, (int) source.getNoSonarTagLines().iterator().next());

    assertEquals(5, source.getMeasure(Metric.COMMENTED_OUT_CODE_LINES));
  }
  @Test
  public void testAnalyse() {
    File phpFile = TestUtils.getResource("/Mail.php");
    when(fs.sourceDirs()).thenReturn(ImmutableList.of(phpFile.getParentFile()));
    when(fs.files(any(FileQuery.class)))
        .thenReturn(ImmutableList.of(TestUtils.getResource("/Mail.php")));

    org.sonar.api.resources.File sonarFile = new org.sonar.api.resources.File("Mail.php");
    doReturn(sonarFile).when(sensor).getSonarResource(any(Project.class), any(File.class));

    sensor.analyse(project, context);
    // Mail.php contains 9 commented oud code lines.
    verify(context).saveMeasure(sonarFile, CoreMetrics.COMMENTED_OUT_CODE_LINES, 9d);
  }