Search in sources :

Example 1 with PhpIniFile

use of org.sonar.php.ini.tree.PhpIniFile in project sonar-php by SonarSource.

the class PhpIniCheckTestUtils method check.

public static void check(PhpIniCheck check, File file) {
    PhpFile inputFile = TestUtils.getFile(file);
    PhpIniFile phpIniFile = new PhpIniParser().parse(inputFile);
    List<PhpIniIssue> actualIssues = check.analyze(phpIniFile);
    List<PhpIniIssue> expectedIssues = expectedIssues(file);
    compare(actualIssues, expectedIssues);
}
Also used : PhpIniFile(org.sonar.php.ini.tree.PhpIniFile) PhpFile(org.sonar.plugins.php.api.visitors.PhpFile) BasePhpIniIssue(org.sonar.php.ini.BasePhpIniIssue) PhpIniIssue(org.sonar.php.ini.PhpIniIssue) PhpIniParser(org.sonar.php.ini.PhpIniParser)

Example 2 with PhpIniFile

use of org.sonar.php.ini.tree.PhpIniFile in project sonar-php by SonarSource.

the class PhpIniParserTest method directive_by_name.

@Test
public void directive_by_name() {
    PhpIniFile phpIniFile = parse("\n  name1=value1 \n name2=value2 \n name1=value3");
    assertThat(phpIniFile.directivesForName("name1")).extracting(Directive::value).extracting(SyntaxToken::text).containsOnly("value1", "value3");
    assertThat(phpIniFile.directivesForName("x")).isEmpty();
}
Also used : PhpIniFile(org.sonar.php.ini.tree.PhpIniFile) Directive(org.sonar.php.ini.tree.Directive) Test(org.junit.Test)

Example 3 with PhpIniFile

use of org.sonar.php.ini.tree.PhpIniFile in project sonar-php by SonarSource.

the class PhpIniParserTest method parse_file.

@Test
public void parse_file() throws Exception {
    PhpFile file = FileTestUtils.getFile(new File("src/test/resources/phpini/php.ini"));
    PhpIniFile phpIni = new PhpIniParser().parse(file);
    assertThat(phpIni.directives()).hasSize(1);
    assertThat(phpIni.directives().get(0).name().text()).isEqualTo("max_execution_time");
}
Also used : PhpIniFile(org.sonar.php.ini.tree.PhpIniFile) PhpFile(org.sonar.plugins.php.api.visitors.PhpFile) PhpIniFile(org.sonar.php.ini.tree.PhpIniFile) File(java.io.File) PhpFile(org.sonar.plugins.php.api.visitors.PhpFile) Test(org.junit.Test)

Example 4 with PhpIniFile

use of org.sonar.php.ini.tree.PhpIniFile in project sonar-php by SonarSource.

the class PhpIniCheckTestUtils method check.

public static void check(PhpIniCheck check, File file, List<PhpIniIssue> expectedIssues) {
    PhpFile inputFile = TestUtils.getFile(file);
    PhpIniFile phpIniFile = new PhpIniParser().parse(inputFile);
    List<PhpIniIssue> actualIssues = check.analyze(phpIniFile);
    compare(actualIssues, expectedIssues);
}
Also used : PhpIniFile(org.sonar.php.ini.tree.PhpIniFile) PhpFile(org.sonar.plugins.php.api.visitors.PhpFile) BasePhpIniIssue(org.sonar.php.ini.BasePhpIniIssue) PhpIniIssue(org.sonar.php.ini.PhpIniIssue) PhpIniParser(org.sonar.php.ini.PhpIniParser)

Example 5 with PhpIniFile

use of org.sonar.php.ini.tree.PhpIniFile in project sonar-php by SonarSource.

the class PhpIniParserTest method checkSingleDirective.

private static void checkSingleDirective(String toParse, String expectedName, String expectedValue) {
    PhpIniFile file = parse(toParse);
    assertThat(file.directives()).hasSize(1);
    Directive directive = file.directives().get(0);
    checkDirective(directive, expectedName, expectedValue);
}
Also used : PhpIniFile(org.sonar.php.ini.tree.PhpIniFile) Directive(org.sonar.php.ini.tree.Directive)

Aggregations

PhpIniFile (org.sonar.php.ini.tree.PhpIniFile)6 PhpIniIssue (org.sonar.php.ini.PhpIniIssue)3 PhpIniParser (org.sonar.php.ini.PhpIniParser)3 PhpFile (org.sonar.plugins.php.api.visitors.PhpFile)3 Test (org.junit.Test)2 BasePhpIniIssue (org.sonar.php.ini.BasePhpIniIssue)2 Directive (org.sonar.php.ini.tree.Directive)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 RecognitionException (com.sonar.sslr.api.RecognitionException)1 File (java.io.File)1 FileSystem (org.sonar.api.batch.fs.FileSystem)1 InputFile (org.sonar.api.batch.fs.InputFile)1 PhpFileImpl (org.sonar.php.compat.PhpFileImpl)1 PhpIniCheck (org.sonar.php.ini.PhpIniCheck)1