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