diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-21 01:14:02 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-21 01:14:02 +0900 |
| commit | e050356c9ba8e1a2c20d2fc842924e189f3cc89e (patch) | |
| tree | 3a0a6829379c1469b6922a924be831e3e1d15448 /crates/shirabe/tests/common | |
| parent | f8e4e41956d0a2c59249a02be6e532939266fb9e (diff) | |
| download | php-shirabe-e050356c9ba8e1a2c20d2fc842924e189f3cc89e.tar.gz php-shirabe-e050356c9ba8e1a2c20d2fc842924e189f3cc89e.tar.zst php-shirabe-e050356c9ba8e1a2c20d2fc842924e189f3cc89e.zip | |
test(dependency-resolver): port PoolTest with shared TestCase helpers
Add tests/common/test_case.rs (get_package, get_version_constraint) ported from
the PHP TestCase, included into the dependency_resolver binary via #[path].
PoolTest's testPool/testPackageById/testWhatProvidesWhenPackageCannotBeFound
pass; testWhatProvidesPackageWithConstraint is #[ignore] (constraint matching
reaches a todo!() in the php-shim).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests/common')
| -rw-r--r-- | crates/shirabe/tests/common/test_case.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/crates/shirabe/tests/common/test_case.rs b/crates/shirabe/tests/common/test_case.rs new file mode 100644 index 0000000..4a54195 --- /dev/null +++ b/crates/shirabe/tests/common/test_case.rs @@ -0,0 +1,25 @@ +//! Shared test helpers ported from composer/tests/Composer/Test/TestCase.php. +//! +//! Included into each integration-test binary that needs them via +//! `#[path = "../common/test_case.rs"] mod test_case;`. +#![allow(dead_code)] + +use shirabe::package::handle::{CompletePackageHandle, PackageInterfaceHandle}; +use shirabe_semver::constraint::{AnyConstraint, SimpleConstraint}; +use shirabe_semver::version_parser::VersionParser; + +/// ref: TestCase::getPackage (default class CompletePackage) +pub fn get_package(name: &str, version: &str) -> PackageInterfaceHandle { + let norm_version = VersionParser.normalize(version, None).unwrap(); + CompletePackageHandle::new(name.to_string(), norm_version, version.to_string()).into() +} + +/// ref: TestCase::getVersionConstraint +pub fn get_version_constraint(operator: &str, version: &str) -> AnyConstraint { + let normalized = VersionParser.normalize(version, None).unwrap(); + AnyConstraint::Simple(SimpleConstraint::new( + operator.to_string(), + normalized, + Some(format!("{} {}", operator, version)), + )) +} |
