aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/command/self_update_command_test.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/tests/command/self_update_command_test.rs')
-rw-r--r--crates/shirabe/tests/command/self_update_command_test.rs54
1 files changed, 41 insertions, 13 deletions
diff --git a/crates/shirabe/tests/command/self_update_command_test.rs b/crates/shirabe/tests/command/self_update_command_test.rs
index 8e51580..094eb5e 100644
--- a/crates/shirabe/tests/command/self_update_command_test.rs
+++ b/crates/shirabe/tests/command/self_update_command_test.rs
@@ -1,39 +1,67 @@
//! ref: composer/tests/Composer/Test/Command/SelfUpdateCommandTest.php
-/// Returns the path to the copied composer.phar used by the test bodies.
-fn set_up() -> String {
- // Depends on initTempComposer and the composer-test.phar fixture, neither ported yet.
- todo!()
+use crate::test_case::{RunOptions, get_application_tester, init_temp_composer};
+use serial_test::serial;
+use shirabe_php_shim::PhpMixed;
+
+/// ref: SelfUpdateCommandTest::setUp (portable part: initTempComposer; the composer-test.phar copy
+/// is omitted because the phar fixture and Symfony Process are not ported).
+fn set_up() -> crate::test_case::TearDown {
+ init_temp_composer(None, None, None, true)
}
#[test]
-#[ignore = "depends on initTempComposer, composer-test.phar fixture, and Symfony Process to spawn the phar; none ported"]
+#[serial]
+#[ignore = "spawns `new Process([PHP_BINARY, $this->phar, 'self-update'])` running composer-test.phar \
+ over HTTP; requires Symfony Process and the composer-test.phar fixture, neither ported"]
fn test_successful_update() {
- let _phar = set_up();
+ let _tear_down = set_up();
todo!()
}
#[test]
-#[ignore = "depends on initTempComposer, composer-test.phar fixture, and Symfony Process to spawn the phar; none ported"]
+#[serial]
+#[ignore = "spawns `new Process([PHP_BINARY, $this->phar, 'self-update', '2.4.0'])` running \
+ composer-test.phar over HTTP; requires Symfony Process and the composer-test.phar \
+ fixture, neither ported"]
fn test_update_to_specific_version() {
- let _phar = set_up();
+ let _tear_down = set_up();
todo!()
}
#[test]
-#[ignore = "depends on getApplicationTester (ApplicationTester) which is not ported"]
+#[serial]
fn test_update_with_invalid_option_throws_exception() {
- let _phar = set_up();
+ let _tear_down = set_up();
- todo!()
+ let mut app_tester = get_application_tester();
+ let err = app_tester
+ .run(
+ vec![
+ (PhpMixed::from("command"), PhpMixed::from("self-update")),
+ (PhpMixed::from("invalid-option"), PhpMixed::from(true)),
+ ],
+ RunOptions::default(),
+ )
+ .expect_err("expected InvalidArgumentException for the unknown argument");
+
+ assert!(
+ err.to_string()
+ .contains("The \"invalid-option\" argument does not exist."),
+ "expected error about unknown argument, got: {:?}",
+ err,
+ );
}
#[test]
-#[ignore = "depends on initTempComposer, composer-test.phar fixture, and Symfony Process to spawn the phar; none ported"]
+#[serial]
+#[ignore = "spawns `new Process([PHP_BINARY, $this->phar, 'self-update', $option])` running \
+ composer-test.phar over HTTP (data provider: --stable/--preview/--snapshot); requires \
+ Symfony Process and the composer-test.phar fixture, neither ported"]
fn test_update_to_different_channel() {
- let _phar = set_up();
+ let _tear_down = set_up();
todo!()
}