codeint-lang-php 0.10.2

Built-in PHP Language plugin for codeint
Documentation
use codeint_model::language::SourceSet;
use codeint_model::{LanguagePlugin, RepoPath};

use super::{classify, is_tooling_file};
use crate::Php;

#[test]
fn classifies_generated_test_and_production_php_files() {
    assert_eq!(
        classify("src/Proxy.php", "// @generated by doctrine\n"),
        SourceSet::Generated
    );
    assert_eq!(
        classify("tests/ProxyTest.php", "/* DO NOT EDIT */\n"),
        SourceSet::Generated
    );
    for path in [
        "tests/Feature/AuthTest.php",
        "test/Unit/Helper.php",
        "app/Services/OrderTest.php",
        "src/order.test.php",
    ] {
        assert_eq!(classify(path, ""), SourceSet::Test, "{path}");
    }
    for path in [
        "app/Models/User.php",
        "src/Test.php",
        "src/TestingHelper.php",
    ] {
        assert_eq!(classify(path, ""), SourceSet::Production, "{path}");
    }
}

#[test]
fn classifies_php_cs_fixer_configs_as_tooling_files() {
    assert!(is_tooling_file(".php-cs-fixer.php"));
    assert!(is_tooling_file(".php-cs-fixer.dist.php"));
    assert!(is_tooling_file("packages/api/.php-cs-fixer.dist.php"));
    assert!(!is_tooling_file("config/app.config.php"));
    assert!(!is_tooling_file("app/Models/User.php"));
    let path = RepoPath::new(".php-cs-fixer.dist.php").expect("valid path");
    assert!(
        Php.lower(&path, "<?php\nreturn [];\n", None)
            .unwrap()
            .is_tooling_file
    );
}