MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / strategy_require_dev_both_tools

Function strategy_require_dev_both_tools

src/formatting.rs:777–811  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

775
776 #[test]
777 fn strategy_require_dev_both_tools() {
778 let dir = tempfile::tempdir().unwrap();
779 let vendor_bin = dir.path().join("vendor/bin");
780 std::fs::create_dir_all(&vendor_bin).unwrap();
781
782 for name in &["php-cs-fixer", "phpcbf"] {
783 let p = vendor_bin.join(name);
784 std::fs::write(&p, "#!/bin/sh\n").unwrap();
785 #[cfg(unix)]
786 {
787 use std::os::unix::fs::PermissionsExt;
788 std::fs::set_permissions(&p, std::fs::Permissions::from_mode(0o755)).unwrap();
789 }
790 }
791
792 let composer: crate::composer::ComposerPackage =
793 serde_json::from_value(serde_json::json!({
794 "require-dev": {
795 "friendsofphp/php-cs-fixer": "^3.0",
796 "squizlabs/php_codesniffer": "^3.0"
797 }
798 }))
799 .unwrap();
800
801 let config = FormattingConfig::default();
802 let strategy = resolve_strategy(Some(dir.path()), &config, Some(&composer), None);
803 match &strategy {
804 FormattingStrategy::External(tools) => {
805 assert_eq!(tools.len(), 2);
806 assert_eq!(tools[0].name, "php-cs-fixer");
807 assert_eq!(tools[1].name, "phpcbf");
808 }
809 other => panic!("Expected External, got {:?}", other),
810 }
811 }
812
813 #[test]
814 fn strategy_require_dev_binary_missing_falls_back_to_builtin() {

Callers

nothing calls this directly

Calls 2

resolve_strategyFunction · 0.85
unwrapMethod · 0.45

Tested by

no test coverage detected