88use PHPUnit \Framework \TestCase ;
99use Prophecy \Argument ;
1010use Prophecy \PhpUnit \ProphecyTrait ;
11+ use Prophecy \Prophecy \ObjectProphecy ;
1112use Psr \EventDispatcher \EventDispatcherInterface ;
1213use Symfony \Component \Console \Output \OutputInterface ;
1314use Symfony \Component \Console \Tester \CommandTester ;
@@ -29,10 +30,13 @@ class RunJobCommandTest extends TestCase
2930
3031 private const JOBNAME = 'testing ' ;
3132
33+ private JobInterface |ObjectProphecy $ job ;
34+ private JobExecutionAccessor $ accessor ;
35+ private JobExecutor $ executor ;
36+
3237 protected function setUp (): void
3338 {
3439 $ this ->job = $ this ->prophesize (JobInterface::class);
35- $ this ->dispatcher = $ this ->prophesize (EventDispatcherInterface::class);
3640
3741 $ this ->accessor = new JobExecutionAccessor (
3842 new JobExecutionFactory (new UniqidJobExecutionIdGenerator ()),
@@ -41,24 +45,10 @@ protected function setUp(): void
4145 $ this ->executor = new JobExecutor (
4246 JobRegistry::fromJobArray ([self ::JOBNAME => $ this ->job ->reveal ()]),
4347 new InMemoryJobExecutionStorage (),
44- $ this -> dispatcher -> reveal ()
48+ null
4549 );
4650 }
4751
48- private function execute (string $ configuration = null , int $ verbosity = OutputInterface::VERBOSITY_NORMAL ): array
49- {
50- $ options = ['verbosity ' => $ verbosity ];
51- $ input = ['job ' => self ::JOBNAME ];
52- if ($ configuration !== null ) {
53- $ input ['configuration ' ] = $ configuration ;
54- }
55-
56- $ tester = new CommandTester (new RunJobCommand ($ this ->accessor , $ this ->executor ));
57- $ tester ->execute ($ input , $ options );
58-
59- return [$ tester ->getStatusCode (), $ tester ->getDisplay ()];
60- }
61-
6252 public function testRunWithMalformedConfiguration (): void
6353 {
6454 $ this ->expectException (JsonException::class);
@@ -164,4 +154,18 @@ public function verbosity(): \Generator
164154 yield 'very verbose ' => [OutputInterface::VERBOSITY_VERY_VERBOSE ];
165155 yield 'debug ' => [OutputInterface::VERBOSITY_DEBUG ];
166156 }
157+
158+ private function execute (string $ configuration = null , int $ verbosity = OutputInterface::VERBOSITY_NORMAL ): array
159+ {
160+ $ options = ['verbosity ' => $ verbosity ];
161+ $ input = ['job ' => self ::JOBNAME ];
162+ if ($ configuration !== null ) {
163+ $ input ['configuration ' ] = $ configuration ;
164+ }
165+
166+ $ tester = new CommandTester (new RunJobCommand ($ this ->accessor , $ this ->executor ));
167+ $ tester ->execute ($ input , $ options );
168+
169+ return [$ tester ->getStatusCode (), $ tester ->getDisplay ()];
170+ }
167171}
0 commit comments