@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))); }
@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(); }
@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(); }
@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(); }
@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); }
@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(); }
@Test public void test() throws Exception { PHPCheckTest.check( new DuplicateBranchImplementationCheck(), TestUtils.getCheckFile("DuplicateBranchImplementationCheck.php")); }
@Before public void setUp() throws Exception { TEST_FILE = TestUtils.getCheckFile(TEST_DIR + "PunctuatorSpacingCheck.php"); }
@Test public void test() throws Exception { PHPCheckTest.check( new OneStatementPerLineCheck(), TestUtils.getCheckFile("OneStatementPerLineCheck.php")); }
@Test public void test() throws Exception { PHPCheckTest.check( new UnusedFunctionParametersCheck(), TestUtils.getCheckFile("UnusedFunctionParametersCheck.php")); }
@Test public void defaultValue() throws Exception { PHPCheckTest.check(check, TestUtils.getCheckFile(FILE_NAME)); }