()
| 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() { |
nothing calls this directly
no test coverage detected