@@ -19,43 +19,61 @@ public function setUp(): void {
1919 } );
2020 }
2121
22+ protected function get_last_request () {
23+ $ request = App::getVar ( 'mocked_request ' );
24+
25+ if ( ! is_array ( $ request ) ) {
26+ return $ request ;
27+ }
28+
29+ if ( ! empty ( $ request ['post_body ' ]['wordpress_version ' ] ) ) {
30+ $ request ['post_body ' ]['wordpress_version ' ] = 'X.X.X ' ;
31+ }
32+
33+ if ( ! empty ( $ request ['post_body ' ]['woocommerce_version ' ] ) ) {
34+ $ request ['post_body ' ]['woocommerce_version ' ] = 'X.X.X ' ;
35+ }
36+
37+ return $ request ;
38+ }
39+
2240 public function test_run_with_additional_plugins () {
2341 App::setVar ( sprintf ( 'mock_%s ' , get_manager_url () . '/wp-json/cd/v1/enqueue-woo-e2e ' ), json_encode ( [
2442 'test_run_id ' => 123456 ,
2543 'test_results_manager_url ' => ''
2644 ] ) );
2745
2846 $ this ->application_tester ->run ( [
29- 'command ' => 'run:woo-e2e ' ,
30- 'woo_extension ' => 'foo-extension ' , // Using slug.
47+ 'command ' => 'run:woo-e2e ' ,
48+ 'woo_extension ' => 'foo-extension ' , // Using slug.
3149 '--additional_plugins ' => '456,789 ' , // Using IDs.
3250 ], [ 'capture_stderr_separately ' => true ] );
3351
3452 $ this ->assertCommandIsSuccessful ( $ this ->application_tester );
35- $ this ->assertMatchesJsonSnapshot ( App:: getVar ( ' mocked_request ' ) );
53+ $ this ->assertMatchesJsonSnapshot ( $ this -> get_last_request ( ) );
3654
3755 $ this ->application_tester ->run ( [
38- 'command ' => 'run:woo-e2e ' ,
39- 'woo_extension ' => '123 ' , // Using ID.
56+ 'command ' => 'run:woo-e2e ' ,
57+ 'woo_extension ' => '123 ' , // Using ID.
4058 '--additional_plugins ' => 'bar-extension,baz-extension ' , // Using Slugs.
4159 ], [ 'capture_stderr_separately ' => true ] );
4260
4361 // If this fails, debug "$this->application_tester->getDisplay()".
4462 $ this ->assertCommandIsSuccessful ( $ this ->application_tester );
45- $ this ->assertMatchesJsonSnapshot ( App:: getVar ( ' mocked_request ' ) );
63+ $ this ->assertMatchesJsonSnapshot ( $ this -> get_last_request ( ) );
4664
4765 $ this ->application_tester ->run ( [
48- 'command ' => 'run:woo-e2e ' ,
49- 'woo_extension ' => 'foo-extension ' , // Using ID.
66+ 'command ' => 'run:woo-e2e ' ,
67+ 'woo_extension ' => 'foo-extension ' , // Using ID.
5068 '--additional_plugins ' => '456,baz-extension ' , // Using mixed.
5169 ], [ 'capture_stderr_separately ' => true ] );
5270
5371 $ this ->assertCommandIsSuccessful ( $ this ->application_tester );
54- $ this ->assertMatchesJsonSnapshot ( App:: getVar ( ' mocked_request ' ) );
72+ $ this ->assertMatchesJsonSnapshot ( $ this -> get_last_request ( ) );
5573
5674 $ this ->application_tester ->run ( [
57- 'command ' => 'run:woo-e2e ' ,
58- 'woo_extension ' => 'foo-extension ' ,
75+ 'command ' => 'run:woo-e2e ' ,
76+ 'woo_extension ' => 'foo-extension ' ,
5977 '--additional_plugins ' => '1234567890 ' , // If the user passes an invalid ID, the Manager should flag that.
6078 ], [ 'capture_stderr_separately ' => true ] );
6179
@@ -73,7 +91,7 @@ public function test_run_with_additional_plugins_invalid() {
7391 'woo_extension ' => 'non-existing-extension ' ,
7492 ], [ 'capture_stderr_separately ' => true ] );
7593 } catch ( \Exception $ e ) {
76- $ this ->assertStringContainsString ('Could not find Woo Extension with slug non-existing-extension. ' , $ e ->getMessage () );
94+ $ this ->assertStringContainsString ( 'Could not find Woo Extension with slug non-existing-extension. ' , $ e ->getMessage () );
7795
7896 throw $ e ;
7997 }
0 commit comments