Skip to content

Commit dc64b70

Browse files
sashaskrAlex Skripov
andauthored
Import fix for BatchFake + tests (#44435)
Co-authored-by: Alex Skripov <[email protected]>
1 parent 5f89ab0 commit dc64b70

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/Illuminate/Support/Testing/Fakes/BatchFake.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Carbon\CarbonImmutable;
66
use Illuminate\Bus\Batch;
7+
use Illuminate\Bus\UpdatedBatchJobCounts;
78
use Illuminate\Support\Carbon;
89

910
class BatchFake extends Batch

tests/Support/SupportTestingBusFakeTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,38 @@ public function testDispatchFakeBatch()
540540
$this->assertSame('', $batch->name);
541541
$this->assertSame(0, $batch->totalJobs);
542542
}
543+
544+
public function testIncrementFailedJobsInFakeBatch()
545+
{
546+
$this->fake->assertNothingBatched();
547+
$batch = $this->fake->dispatchFakeBatch('my fake job batch');
548+
549+
$this->fake->assertBatchCount(1);
550+
$this->assertInstanceOf(Batch::class, $batch);
551+
$this->assertSame('my fake job batch', $batch->name);
552+
$this->assertSame(0, $batch->totalJobs);
553+
554+
$batch->incrementFailedJobs($batch->id);
555+
556+
$this->assertSame(0, $batch->failedJobs);
557+
$this->assertSame(0, $batch->pendingJobs);
558+
}
559+
560+
public function testDecrementPendingJobsInFakeBatch()
561+
{
562+
$this->fake->assertNothingBatched();
563+
$batch = $this->fake->dispatchFakeBatch('my fake job batch');
564+
565+
$this->fake->assertBatchCount(1);
566+
$this->assertInstanceOf(Batch::class, $batch);
567+
$this->assertSame('my fake job batch', $batch->name);
568+
$this->assertSame(0, $batch->totalJobs);
569+
570+
$batch->decrementPendingJobs($batch->id);
571+
572+
$this->assertSame(0, $batch->failedJobs);
573+
$this->assertSame(0, $batch->pendingJobs);
574+
}
543575
}
544576

545577
class BusJobStub

0 commit comments

Comments
 (0)