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

Function strategy_require_dev_phpcodesniffer

src/formatting.rs:743–774  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

741
742 #[test]
743 fn strategy_require_dev_phpcodesniffer() {
744 let dir = tempfile::tempdir().unwrap();
745 let vendor_bin = dir.path().join("vendor/bin");
746 std::fs::create_dir_all(&vendor_bin).unwrap();
747
748 let p = vendor_bin.join("phpcbf");
749 std::fs::write(&p, "#!/bin/sh\n").unwrap();
750 #[cfg(unix)]
751 {
752 use std::os::unix::fs::PermissionsExt;
753 std::fs::set_permissions(&p, std::fs::Permissions::from_mode(0o755)).unwrap();
754 }
755
756 let composer: crate::composer::ComposerPackage =
757 serde_json::from_value(serde_json::json!({
758 "require-dev": {
759 "squizlabs/php_codesniffer": "^3.0"
760 }
761 }))
762 .unwrap();
763
764 let config = FormattingConfig::default();
765 let strategy = resolve_strategy(Some(dir.path()), &config, Some(&composer), None);
766 match &strategy {
767 FormattingStrategy::External(tools) => {
768 assert_eq!(tools.len(), 1);
769 assert_eq!(tools[0].name, "phpcbf");
770 assert_eq!(tools[0].path, vendor_bin.join("phpcbf"));
771 }
772 other => panic!("Expected External, got {:?}", other),
773 }
774 }
775
776 #[test]
777 fn strategy_require_dev_both_tools() {

Callers

nothing calls this directly

Calls 2

resolve_strategyFunction · 0.85
unwrapMethod · 0.45

Tested by

no test coverage detected