()
| 836 | |
| 837 | #[test] |
| 838 | fn strategy_explicit_overrides_require_dev() { |
| 839 | let dir = tempfile::tempdir().unwrap(); |
| 840 | let vendor_bin = dir.path().join("vendor/bin"); |
| 841 | std::fs::create_dir_all(&vendor_bin).unwrap(); |
| 842 | |
| 843 | let p = vendor_bin.join("php-cs-fixer"); |
| 844 | std::fs::write(&p, "#!/bin/sh\n").unwrap(); |
| 845 | #[cfg(unix)] |
| 846 | { |
| 847 | use std::os::unix::fs::PermissionsExt; |
| 848 | std::fs::set_permissions(&p, std::fs::Permissions::from_mode(0o755)).unwrap(); |
| 849 | } |
| 850 | |
| 851 | let composer: crate::composer::ComposerPackage = |
| 852 | serde_json::from_value(serde_json::json!({ |
| 853 | "require-dev": { |
| 854 | "friendsofphp/php-cs-fixer": "^3.0" |
| 855 | } |
| 856 | })) |
| 857 | .unwrap(); |
| 858 | |
| 859 | // User explicitly set a different path. |
| 860 | let config = FormattingConfig { |
| 861 | pint: None, |
| 862 | php_cs_fixer: Some("/opt/php-cs-fixer".to_string()), |
| 863 | phpcbf: Some(String::new()), |
| 864 | timeout: None, |
| 865 | }; |
| 866 | let strategy = resolve_strategy(Some(dir.path()), &config, Some(&composer), None); |
| 867 | match &strategy { |
| 868 | FormattingStrategy::External(tools) => { |
| 869 | assert_eq!(tools.len(), 1); |
| 870 | assert_eq!(tools[0].path, PathBuf::from("/opt/php-cs-fixer")); |
| 871 | } |
| 872 | other => panic!("Expected External, got {:?}", other), |
| 873 | } |
| 874 | } |
| 875 | |
| 876 | #[test] |
| 877 | fn strategy_custom_bin_dir() { |
nothing calls this directly
no test coverage detected