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

tochka-developers / queue-promises / 9935584685

15 Jul 2024 07:44AM UTC coverage: 47.259% (-18.3%) from 65.524%
9935584685

push

github

darkdarin
fix: tests

4 of 4 new or added lines in 2 files covered. (100.0%)

431 existing lines in 40 files now uncovered.

612 of 1295 relevant lines covered (47.26%)

2.53 hits per line

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

95.45
/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
/**
18
 * @api
19
 */
20
class BasePromise implements StatesContract, ConditionTransitionsContract
21
{
22
    use ConditionTransitions;
23
    use SerializesModels;
24
    use States;
25
    use Time;
26

27
    private ?int $id = null;
28
    private ?int $parentJobId;
29
    private PromiseHandler $promiseHandler;
30
    private Promise $model;
31
    private Carbon $watchAt;
32
    private Carbon $timeoutAt;
33

34
    public function __construct(PromiseHandler $promiseHandler)
35
    {
36
        $this->promiseHandler = $promiseHandler;
6✔
37
        $this->parentJobId = $promiseHandler->getBaseJobId();
6✔
38
        $this->state = StateEnum::WAITING();
6✔
39
        $this->model = new Promise();
6✔
40
        $this->watchAt = Carbon::now()->addSeconds(watcher_watch_timeout());
6✔
41
        $this->timeoutAt = Carbon::now()->addSeconds(Config::get('promises.global_promise_timeout', 432000));
6✔
42
        $this->created_at = Carbon::now();
6✔
43
        $this->updated_at = Carbon::now();
6✔
44
    }
45

46
    public function getPromiseHandler(): PromiseHandler
47
    {
48
        return $this->promiseHandler;
9✔
49
    }
50

51
    public function setPromiseHandler(PromiseHandler $promiseHandler): void
52
    {
53
        $this->promiseHandler = $promiseHandler;
3✔
54
    }
55

56
    /**
57
     * @psalm-ignore-nullable-return
58
     */
59
    public function getPromiseId(): ?int
60
    {
61
        return $this->id;
3✔
62
    }
63

64
    public function setPromiseId(int $id): void
65
    {
66
        $this->id = $id;
6✔
67
    }
68

69
    public function getParentJobId(): ?int
70
    {
71
        return $this->parentJobId;
3✔
72
    }
73

74
    public function setParentJobId(?int $id): void
75
    {
UNCOV
76
        $this->parentJobId = $id;
×
77
    }
78

79
    public function getAttachedModel(): Promise
80
    {
81
        return $this->model;
6✔
82
    }
83

84
    public function setAttachedModel(Promise $model): void
85
    {
86
        $this->model = $model;
6✔
87
    }
88

89
    public function getWatchAt(): Carbon
90
    {
91
        return $this->watchAt;
9✔
92
    }
93

94
    public function setWatchAt(Carbon $watchAt): void
95
    {
96
        $this->watchAt = $watchAt;
3✔
97
    }
98

99
    public function getTimeoutAt(): Carbon
100
    {
101
        return $this->timeoutAt;
9✔
102
    }
103

104
    public function setTimeoutAt(Carbon $timeoutAt): void
105
    {
106
        $this->timeoutAt = $timeoutAt;
3✔
107
    }
108

109
    public function dispatch(): void
110
    {
111
        $this->setState(StateEnum::RUNNING());
3✔
112

113
        Promise::saveBasePromise($this);
3✔
114
    }
115
}
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

© 2025 Coveralls, Inc