1010namespace Tests \Unit \Commands \Schedule ;
1111
1212use Mockery as m ;
13- use Carbon \ Carbon ;
13+ use Cake \ Chronos \ Chronos ;
1414use Pterodactyl \Models \Task ;
1515use Pterodactyl \Models \Schedule ;
1616use Tests \Unit \Commands \CommandTestCase ;
2020
2121class ProcessRunnableCommandTest extends CommandTestCase
2222{
23- /**
24- * @var \Carbon\Carbon
25- */
26- protected $ carbon ;
27-
2823 /**
2924 * @var \Pterodactyl\Console\Commands\Schedule\ProcessRunnableCommand
3025 */
@@ -47,11 +42,12 @@ public function setUp()
4742 {
4843 parent ::setUp ();
4944
50- $ this ->carbon = m::mock (Carbon::class);
45+ Chronos::setTestNow (Chronos::now ());
46+
5147 $ this ->processScheduleService = m::mock (ProcessScheduleService::class);
5248 $ this ->repository = m::mock (ScheduleRepositoryInterface::class);
5349
54- $ this ->command = new ProcessRunnableCommand ($ this ->carbon , $ this -> processScheduleService , $ this ->repository );
50+ $ this ->command = new ProcessRunnableCommand ($ this ->processScheduleService , $ this ->repository );
5551 }
5652
5753 /**
@@ -62,9 +58,7 @@ public function testScheduleIsQueued()
6258 $ schedule = factory (Schedule::class)->make ();
6359 $ schedule ->tasks = collect ([factory (Task::class)->make ()]);
6460
65- $ this ->carbon ->shouldReceive ('now ' )->withNoArgs ()->once ()->andReturnSelf ()
66- ->shouldReceive ('toAtomString ' )->withNoArgs ()->once ()->andReturn ('00:00:00 ' );
67- $ this ->repository ->shouldReceive ('getSchedulesToProcess ' )->with ('00:00:00 ' )->once ()->andReturn (collect ([$ schedule ]));
61+ $ this ->repository ->shouldReceive ('getSchedulesToProcess ' )->with (Chronos::now ()->toAtomString ())->once ()->andReturn (collect ([$ schedule ]));
6862 $ this ->processScheduleService ->shouldReceive ('handle ' )->with ($ schedule )->once ()->andReturnNull ();
6963
7064 $ display = $ this ->runCommand ($ this ->command );
@@ -84,9 +78,7 @@ public function testScheduleWithNoTasksIsNotProcessed()
8478 $ schedule = factory (Schedule::class)->make ();
8579 $ schedule ->tasks = collect ([]);
8680
87- $ this ->carbon ->shouldReceive ('now ' )->withNoArgs ()->once ()->andReturnSelf ()
88- ->shouldReceive ('toAtomString ' )->withNoArgs ()->once ()->andReturn ('00:00:00 ' );
89- $ this ->repository ->shouldReceive ('getSchedulesToProcess ' )->with ('00:00:00 ' )->once ()->andReturn (collect ([$ schedule ]));
81+ $ this ->repository ->shouldReceive ('getSchedulesToProcess ' )->with (Chronos::now ()->toAtomString ())->once ()->andReturn (collect ([$ schedule ]));
9082
9183 $ display = $ this ->runCommand ($ this ->command );
9284
@@ -104,9 +96,7 @@ public function testScheduleWithTasksObjectThatIsNotInstanceOfCollectionIsNotPro
10496 {
10597 $ schedule = factory (Schedule::class)->make (['tasks ' => null ]);
10698
107- $ this ->carbon ->shouldReceive ('now ' )->withNoArgs ()->once ()->andReturnSelf ()
108- ->shouldReceive ('toAtomString ' )->withNoArgs ()->once ()->andReturn ('00:00:00 ' );
109- $ this ->repository ->shouldReceive ('getSchedulesToProcess ' )->with ('00:00:00 ' )->once ()->andReturn (collect ([$ schedule ]));
99+ $ this ->repository ->shouldReceive ('getSchedulesToProcess ' )->with (Chronos::now ()->toAtomString ())->once ()->andReturn (collect ([$ schedule ]));
110100
111101 $ display = $ this ->runCommand ($ this ->command );
112102
0 commit comments