@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();
  }
コード例 #2
0
  @Test
  public void custom() throws IllegalAccessException {
    deactivateAll();

    SourceFile file = PHPAstScanner.scanSingleFile(TEST_FILE, check);
    checkMessagesVerifier.verify(file.getCheckMessages()).noMore();
  }
コード例 #3
0
  @Test
  public void defaultValue() throws IllegalAccessException {
    activeOnly("isOneSpaceBetweenRParentAndLCurly", "isNoSpaceParenthesis");

    SourceFile file = PHPAstScanner.scanSingleFile(TEST_FILE, check);
    checkMessagesVerifier
        .verify(file.getCheckMessages())
        .next()
        .atLine(6)
        .withMessage("Put one space between the closing parenthesis and the opening curly brace.")
        .next()
        .atLine(8)
        .withMessage(
            "Put only one space between the closing parenthesis and the opening curly brace.")
        .next()
        .atLine(24)
        .withMessage("Remove all space after the opening parenthesis.")
        .next()
        .atLine(25)
        .withMessage("Remove all space before the closing parenthesis.")
        .next()
        .atLine(26)
        .withMessage(
            "Remove all space after the opening parenthesis and before the closing parenthesis.")
        .noMore();
  }
コード例 #4
0
  @Test
  public void ok() throws Exception {
    SourceFile file =
        PHPAstScanner.scanSingleFile(TestUtils.getCheckFile(TEST_DIR + "ok.php"), check);

    checkMessagesVerifier.verify(file.getCheckMessages()).noMore();
  }
コード例 #5
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();
  }
コード例 #6
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();
  }
コード例 #7
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();
  }
コード例 #8
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);
  }
コード例 #9
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();
  }