• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tochka-developers / queue-promises / 5133778705

pending completion
5133778705

push

github

darkdarin
fix: set next watch time at timeout_at for correct timeout promises

669 of 1021 relevant lines covered (65.52%)

2.33 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.0
/src/Core/BasePromise.php
1
<?php
2

3
namespace Tochka\Promises\Core;
4

5
use Carbon\Carbon;
6
use Illuminate\Queue\SerializesModels;
7
use Illuminate\Support\Facades\Config;
8
use Tochka\Promises\Contracts\ConditionTransitionsContract;
9
use Tochka\Promises\Contracts\PromiseHandler;
10
use Tochka\Promises\Contracts\StatesContract;
11
use Tochka\Promises\Core\Support\ConditionTransitions;
12
use Tochka\Promises\Core\Support\States;
13
use Tochka\Promises\Core\Support\Time;
14
use Tochka\Promises\Enums\StateEnum;
15
use Tochka\Promises\Models\Promise;
16

17
class BasePromise implements StatesContract, ConditionTransitionsContract
18
{
19
    use ConditionTransitions;
20
    use SerializesModels;
21
    use States;
22
    use Time;
23

24
    private ?int $id = null;
25
    private ?int $parentJobId;
26
    private PromiseHandler $promiseHandler;
27
    private Promise $model;
28
    private Carbon $watchAt;
29
    private Carbon $timeoutAt;
30

31
    public function __construct(PromiseHandler $promiseHandler)
32
    {
33
        $this->promiseHandler = $promiseHandler;
4✔
34
        $this->parentJobId = $promiseHandler->getBaseJobId();
4✔
35
        $this->state = StateEnum::WAITING();
4✔
36
        $this->model = new Promise();
4✔
37
        $this->watchAt = Carbon::now()->addSeconds(watcher_watch_timeout());
4✔
38
        $this->timeoutAt = Carbon::now()->addSeconds(Config::get('promises.global_promise_timeout', 432000));
4✔
39
    }
40

41
    public function getPromiseHandler(): PromiseHandler
42
    {
43
        return $this->promiseHandler;
6✔
44
    }
45

46
    public function setPromiseHandler(PromiseHandler $promiseHandler): void
47
    {
48
        $this->promiseHandler = $promiseHandler;
2✔
49
    }
50

51
    public function getPromiseId(): ?int
52
    {
53
        return $this->id;
2✔
54
    }
55

56
    public function setPromiseId(int $id): void
57
    {
58
        $this->id = $id;
4✔
59
    }
60

61
    public function getParentJobId(): ?int
62
    {
63
        return $this->parentJobId;
2✔
64
    }
65

66
    public function setParentJobId(?int $id): void
67
    {
68
        $this->parentJobId = $id;
×
69
    }
70

71
    public function getAttachedModel(): Promise
72
    {
73
        return $this->model;
4✔
74
    }
75

76
    public function setAttachedModel(Promise $model): void
77
    {
78
        $this->model = $model;
4✔
79
    }
80

81
    public function getWatchAt(): Carbon
82
    {
83
        return $this->watchAt;
6✔
84
    }
85

86
    public function setWatchAt(Carbon $watchAt): void
87
    {
88
        $this->watchAt = $watchAt;
2✔
89
    }
90

91
    public function getTimeoutAt(): Carbon
92
    {
93
        return $this->timeoutAt;
6✔
94
    }
95

96
    public function setTimeoutAt(Carbon $timeoutAt): void
97
    {
98
        $this->timeoutAt = $timeoutAt;
2✔
99
    }
100

101
    public function dispatch(): void
102
    {
103
        $this->setState(StateEnum::RUNNING());
2✔
104

105
        Promise::saveBasePromise($this);
2✔
106
    }
107
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc