Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Support\Testing\Fakes;
4
 
5
use Carbon\CarbonImmutable;
6
use Illuminate\Bus\Batch;
7
use Illuminate\Bus\UpdatedBatchJobCounts;
8
use Illuminate\Support\Carbon;
9
 
10
class BatchFake extends Batch
11
{
12
    /**
13
     * The jobs that have been added to the batch.
14
     *
15
     * @var array
16
     */
17
    public $added = [];
18
 
19
    /**
20
     * Indicates if the batch has been deleted.
21
     *
22
     * @var bool
23
     */
24
    public $deleted = false;
25
 
26
    /**
27
     * Create a new batch instance.
28
     *
29
     * @param  string  $id
30
     * @param  string  $name
31
     * @param  int  $totalJobs
32
     * @param  int  $pendingJobs
33
     * @param  int  $failedJobs
34
     * @param  array  $failedJobIds
35
     * @param  array  $options
36
     * @param  \Carbon\CarbonImmutable  $createdAt
37
     * @param  \Carbon\CarbonImmutable|null  $cancelledAt
38
     * @param  \Carbon\CarbonImmutable|null  $finishedAt
39
     * @return void
40
     */
41
    public function __construct(string $id,
42
                                string $name,
43
                                int $totalJobs,
44
                                int $pendingJobs,
45
                                int $failedJobs,
46
                                array $failedJobIds,
47
                                array $options,
48
                                CarbonImmutable $createdAt,
49
                                ?CarbonImmutable $cancelledAt = null,
50
                                ?CarbonImmutable $finishedAt = null)
51
    {
52
        $this->id = $id;
53
        $this->name = $name;
54
        $this->totalJobs = $totalJobs;
55
        $this->pendingJobs = $pendingJobs;
56
        $this->failedJobs = $failedJobs;
57
        $this->failedJobIds = $failedJobIds;
58
        $this->options = $options;
59
        $this->createdAt = $createdAt;
60
        $this->cancelledAt = $cancelledAt;
61
        $this->finishedAt = $finishedAt;
62
    }
63
 
64
    /**
65
     * Get a fresh instance of the batch represented by this ID.
66
     *
67
     * @return self
68
     */
69
    public function fresh()
70
    {
71
        return $this;
72
    }
73
 
74
    /**
75
     * Add additional jobs to the batch.
76
     *
77
     * @param  \Illuminate\Support\Enumerable|object|array  $jobs
78
     * @return self
79
     */
80
    public function add($jobs)
81
    {
82
        foreach ($jobs as $job) {
83
            $this->added[] = $job;
84
        }
85
 
86
        return $this;
87
    }
88
 
89
    /**
90
     * Record that a job within the batch finished successfully, executing any callbacks if necessary.
91
     *
92
     * @param  string  $jobId
93
     * @return void
94
     */
95
    public function recordSuccessfulJob(string $jobId)
96
    {
97
        //
98
    }
99
 
100
    /**
101
     * Decrement the pending jobs for the batch.
102
     *
103
     * @param  string  $jobId
104
     * @return \Illuminate\Bus\UpdatedBatchJobCounts
105
     */
106
    public function decrementPendingJobs(string $jobId)
107
    {
108
        //
109
    }
110
 
111
    /**
112
     * Record that a job within the batch failed to finish successfully, executing any callbacks if necessary.
113
     *
114
     * @param  string  $jobId
115
     * @param  \Throwable  $e
116
     * @return void
117
     */
118
    public function recordFailedJob(string $jobId, $e)
119
    {
120
        //
121
    }
122
 
123
    /**
124
     * Increment the failed jobs for the batch.
125
     *
126
     * @param  string  $jobId
127
     * @return \Illuminate\Bus\UpdatedBatchJobCounts
128
     */
129
    public function incrementFailedJobs(string $jobId)
130
    {
131
        return new UpdatedBatchJobCounts;
132
    }
133
 
134
    /**
135
     * Cancel the batch.
136
     *
137
     * @return void
138
     */
139
    public function cancel()
140
    {
141
        $this->cancelledAt = Carbon::now();
142
    }
143
 
144
    /**
145
     * Delete the batch from storage.
146
     *
147
     * @return void
148
     */
149
    public function delete()
150
    {
151
        $this->deleted = true;
152
    }
153
 
154
    /**
155
     * Determine if the batch has been deleted.
156
     *
157
     * @return bool
158
     */
159
    public function deleted()
160
    {
161
        return $this->deleted;
162
    }
163
}