コード例 #1
0
  @Test
  public void ok() throws Exception {
    SourceFile file =
        PHPAstScanner.scanSingleFile(TestUtils.getCheckFile(TEST_DIR + "ok.php"), check);

    checkMessagesVerifier.verify(file.getCheckMessages()).noMore();
  }
  @Test
  public void test() throws Exception {
    SourceFile file =
        PHPAstScanner.scanSingleFile(
            TestUtils.getCheckFile("PHP5DeprecatedFunctionUsageCheck.php"),
            new PHP5DeprecatedFunctionUsageCheck());

    checkMessagesVerifier
        .verify(file.getCheckMessages())
        .next()
        .atLine(3)
        .withMessage(
            "Replace this \"call_user_method()\" call with a call to \"call_user_func()\".")
        .next()
        .atLine(4)
        .withMessage("Remove this \"define_syslog_variables()\" call.")
        .next()
        .atLine(6)
        .next()
        .atLine(8)
        .withMessage("Use the \"LC_ALL\" constant instead of a string literal.")
        .next()
        .atLine(9)
        .noMore();
  }
 @Test
 public void custom() throws Exception {
   check.max = 5;
   PHPCheckTest.check(
       check,
       TestUtils.getCheckFile(FILE_NAME),
       ImmutableList.<Issue>of(new PHPIssue(check, null).line(10)));
 }
コード例 #4
0
  @Test
  public void defaultValue() throws Exception {
    SourceFile file =
        PHPAstScanner.scanSingleFile(
            TestUtils.getCheckFile("PhpSapiNameFunctionUsageCheck.php"),
            new PhpSapiNameFunctionUsageCheck());

    checkMessagesVerifier
        .verify(file.getCheckMessages())
        .next()
        .atLine(3)
        .withMessage("Use the \"PHP_SAPI\" constant instead.")
        .noMore();
  }
コード例 #5
0
  @Test
  public void test() throws Exception {
    SourceFile file =
        PHPAstScanner.scanSingleFile(
            TestUtils.getCheckFile("ElseIfSequenceKeywordUsageCheck.php"),
            new ElseIfSequenceKeywordUsageCheck());

    checkMessagesVerifier
        .verify(file.getCheckMessages())
        .next()
        .atLine(5)
        .withMessage("Replace this \"else if\" keyword sequence by \"elseif\" keyword.")
        .noMore();
  }
コード例 #6
0
  @Test
  public void ko3() throws Exception {
    SourceFile file =
        PHPAstScanner.scanSingleFile(TestUtils.getCheckFile(TEST_DIR + "ko3.php"), check);

    checkMessagesVerifier
        .verify(file.getCheckMessages())
        .next()
        .atLine(null)
        .withCost(2.0)
        .withMessage(
            "There are 1 independent classes and 2 independent interfaces in this file; move all but one of them to other files.")
        .noMore();
  }
コード例 #7
0
  @Test
  public void test() throws Exception {
    SourceFile file =
        PHPAstScanner.scanSingleFile(
            TestUtils.getCheckFile("SelfAssignmentCheck.php"), new SelfAssignmentCheck());

    checkMessagesVerifier
        .verify(file.getCheckMessages())
        .next()
        .atLine(3)
        .withMessage("Remove or correct this useless self-assignment")
        .next()
        .atLine(5)
        .next()
        .atLine(7);
  }
コード例 #8
0
  @Test
  public void test() throws Exception {
    SourceFile file =
        PHPAstScanner.scanSingleFile(
            TestUtils.getCheckFile("NonEmptyCaseWithoutBreakCheck.php"),
            new NonEmptyCaseWithoutBreakCheck());

    checkMessagesVerifier
        .verify(file.getCheckMessages())
        .next()
        .atLine(5)
        .withMessage(
            "End this switch case with an unconditional break, continue, return or throw statement.")
        .next()
        .atLine(7)
        .next()
        .atLine(17)
        .next()
        .atLine(44)
        .next()
        .atLine(46)
        .noMore();
  }
コード例 #9
0
 @Test
 public void test() throws Exception {
   PHPCheckTest.check(
       new DuplicateBranchImplementationCheck(),
       TestUtils.getCheckFile("DuplicateBranchImplementationCheck.php"));
 }
コード例 #10
0
 @Before
 public void setUp() throws Exception {
   TEST_FILE = TestUtils.getCheckFile(TEST_DIR + "PunctuatorSpacingCheck.php");
 }
コード例 #11
0
 @Test
 public void test() throws Exception {
   PHPCheckTest.check(
       new OneStatementPerLineCheck(), TestUtils.getCheckFile("OneStatementPerLineCheck.php"));
 }
コード例 #12
0
 @Test
 public void test() throws Exception {
   PHPCheckTest.check(
       new UnusedFunctionParametersCheck(),
       TestUtils.getCheckFile("UnusedFunctionParametersCheck.php"));
 }
コード例 #13
0
 @Test
 public void defaultValue() throws Exception {
   PHPCheckTest.check(check, TestUtils.getCheckFile(FILE_NAME));
 }