@@ -689,6 +689,78 @@ public function testDispatchShellArgsParser()
689
689
$ this ->assertEquals ($ expected , $ result );
690
690
}
691
691
692
+ /**
693
+ * test calling a shell that dispatch another one
694
+ *
695
+ * @return void
696
+ */
697
+ public function testDispatchShell ()
698
+ {
699
+ $ Shell = new TestingDispatchShell ();
700
+ ob_start ();
701
+ $ Shell ->runCommand (['test_task ' ], true );
702
+ $ result = ob_get_clean ();
703
+
704
+ $ expected = <<<TEXT
705
+ <info>Welcome to CakePHP Console</info>
706
+ I am a test task, I dispatch another Shell
707
+ I am a dispatched Shell
708
+
709
+ TEXT ;
710
+ $ this ->assertEquals ($ expected , $ result );
711
+
712
+ ob_start ();
713
+ $ Shell ->runCommand (['test_task_dispatch_array ' ], true );
714
+ $ result = ob_get_clean ();
715
+ $ this ->assertEquals ($ expected , $ result );
716
+
717
+ ob_start ();
718
+ $ Shell ->runCommand (['test_task_dispatch_command_string ' ], true );
719
+ $ result = ob_get_clean ();
720
+ $ this ->assertEquals ($ expected , $ result );
721
+
722
+ ob_start ();
723
+ $ Shell ->runCommand (['test_task_dispatch_command_array ' ], true );
724
+ $ result = ob_get_clean ();
725
+ $ this ->assertEquals ($ expected , $ result );
726
+
727
+ $ expected = <<<TEXT
728
+ <info>Welcome to CakePHP Console</info>
729
+ I am a test task, I dispatch another Shell
730
+ I am a dispatched Shell. My param `foo` has the value `bar`
731
+
732
+ TEXT ;
733
+
734
+ ob_start ();
735
+ $ Shell ->runCommand (['test_task_dispatch_with_param ' ], true );
736
+ $ result = ob_get_clean ();
737
+ $ this ->assertEquals ($ expected , $ result );
738
+
739
+ $ expected = <<<TEXT
740
+ <info>Welcome to CakePHP Console</info>
741
+ I am a test task, I dispatch another Shell
742
+ I am a dispatched Shell. My param `foo` has the value `bar`
743
+ My param `fooz` has the value `baz`
744
+
745
+ TEXT ;
746
+ ob_start ();
747
+ $ Shell ->runCommand (['test_task_dispatch_with_multiple_params ' ], true );
748
+ $ result = ob_get_clean ();
749
+ $ this ->assertEquals ($ expected , $ result );
750
+
751
+ $ expected = <<<TEXT
752
+ <info>Welcome to CakePHP Console</info>
753
+ I am a test task, I dispatch another Shell
754
+ <info>Welcome to CakePHP Console</info>
755
+ I am a dispatched Shell
756
+
757
+ TEXT ;
758
+ ob_start ();
759
+ $ Shell ->runCommand (['test_task_dispatch_with_requested_off ' ], true );
760
+ $ result = ob_get_clean ();
761
+ $ this ->assertEquals ($ expected , $ result );
762
+ }
763
+
692
764
/**
693
765
* Test that runCommand() doesn't call public methods when the second arg is false.
694
766
*
@@ -897,27 +969,6 @@ public function testRunCommandHittingTaskInSubcommand()
897
969
$ shell ->runCommand (['slice ' , 'one ' ]);
898
970
}
899
971
900
- /**
901
- * test calling a shell that dispatch another one
902
- *
903
- * @return void
904
- */
905
- public function testDispatchShell ()
906
- {
907
- $ Shell = new TestingDispatchShell ();
908
- ob_start ();
909
- $ Shell ->runCommand (['test_task ' ], true );
910
- $ result = ob_get_clean ();
911
-
912
- $ expected = <<<TEXT
913
- <info>Welcome to CakePHP Console</info>
914
- I am a test task, I dispatch another Shell
915
- I am a dispatched Shell
916
-
917
- TEXT ;
918
- $ this ->assertEquals ($ expected , $ result );
919
- }
920
-
921
972
/**
922
973
* test wrapBlock wrapping text.
923
974
*
0 commit comments