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

php-bug-catcher / bug-catcher / 10983401053

22 Sep 2024 06:21PM UTC coverage: 76.842% (+1.9%) from 74.904%
10983401053

push

github

tito10047
created tests for Importance.php

5 of 7 new or added lines in 4 files covered. (71.43%)

803 of 1045 relevant lines covered (76.84%)

11.43 hits per line

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

65.85
/src/Entity/Project.php
1
<?php
2

3
namespace BugCatcher\Entity;
4

5
use ApiPlatform\Metadata\ApiResource;
6
use Doctrine\Common\Collections\ArrayCollection;
7
use Doctrine\Common\Collections\Collection;
8
use Doctrine\ORM\Mapping as ORM;
9
use BugCatcher\Enum\Importance;
10
use BugCatcher\Repository\ProjectRepository;
11
use Symfony\Bridge\Doctrine\Types\UuidType;
12
use Symfony\Component\Uid\Uuid;
13
use Symfony\Component\Validator\Constraints as Assert;
14

15
#[ApiResource(
16
        operations: [],
17
        denormalizationContext: ['groups' => ['record:write']],
18
        validationContext: ['groups' => ['api']],
19
)]
20
class Project {
21
        private ?Uuid $id = null;
22

23
        #[Assert\NotBlank()]
24
        #[Assert\Length(min: 3, max: 255)]
25
        private ?string $code = null;
26

27
        #[Assert\NotBlank()]
28
        #[Assert\Length(min: 3, max: 255)]
29
        private ?string $name = null;
30

31
        private bool $enabled = true;
32

33
        #[Assert\Length(min: 3, max: 255)]
34
        private ?string $url = null;
35

36
        #[Assert\Length(min: 3, max: 255)]
37
        private ?string $dbConnection = null;
38

39
        private ?string $pingCollector = null;
40

41
        /**
42
         * @var Collection<int, User>
43
         */
44
        private Collection $users;
45

46

47
        /**
48
         * @var Collection<int, Notifier>
49
         */
50
        private Collection $notifiers;
51

52

53
        public function __construct() {
54
                $this->users     = new ArrayCollection();
36✔
55
                $this->notifiers = new ArrayCollection();
36✔
56
        }
57

58
        public function getId(): ?Uuid {
59
                return $this->id;
18✔
60
        }
61

62
        public function getCode(): ?string {
63
                return $this->code;
1✔
64
        }
65

66
        public function setCode(string $code): static {
67
                $this->code = $code;
36✔
68

69
                return $this;
36✔
70
        }
71

72
        public function getName(): ?string {
73
                return $this->name;
1✔
74
        }
75

76
        public function setName(string $name): static {
77
                $this->name = $name;
36✔
78

79
                return $this;
36✔
80
        }
81

82
        public function isEnabled(): ?bool {
83
                return $this->enabled;
9✔
84
        }
85

86
        public function setEnabled(bool $enabled): static {
87
                $this->enabled = $enabled;
36✔
88

89
                return $this;
36✔
90
        }
91

92
        public function getUrl(): ?string {
93
                return $this->url;
3✔
94
        }
95

96
        public function setUrl(string $url): static {
97
                $this->url = $url;
2✔
98

99
                return $this;
2✔
100
        }
101

102
        public function getDbConnection(): ?string {
103
                return $this->dbConnection;
3✔
104
        }
105

106
        public function setDbConnection(string $dbConnection): static {
107
                $this->dbConnection = $dbConnection;
2✔
108

109
                return $this;
2✔
110
        }
111

112
        public function getPingCollector(): ?string {
113
                return $this->pingCollector;
8✔
114
        }
115

116
        public function setPingCollector(?string $pingCollector): static {
117
                $this->pingCollector = $pingCollector;
7✔
118

119
                return $this;
7✔
120
        }
121

122
        /**
123
         * @return Collection<int, User>
124
         */
125
        public function getUsers(): array {
126
                return $this->users->toArray();
5✔
127
        }
128

129
        public function addUser(User $user): static {
130
                if (!$this->users->contains($user)) {
4✔
131
                        $this->users->add($user);
4✔
132
                        $user->addProject($this);
4✔
133
                }
134

135
                return $this;
4✔
136
        }
137

138
        public function removeUser(User $user): static {
139
                if ($this->users->removeElement($user)) {
×
140
                        $user->removeProject($this);
×
141
                }
142

143
                return $this;
×
144
        }
145

146
        /**
147
         * @psalm-param class-string<T> $class
148
         * @psalm-return Collection<int, T>
149
         * @template T of Notifier
150
         */
151
        public function findNotifiers(string $class, Importance $minimalImportance = Importance::Normal): Collection {
152
                return $this->notifiers->filter(function (Notifier $notifier) use ($class, $minimalImportance) {
×
NEW
153
            return $notifier instanceof $class && $notifier->getMinimalImportance()->isHigherOrEqualThan($minimalImportance);
×
154
                });
×
155
        }
156

157
        /**
158
         * @return Notifier[]
159
         */
160
        public function getNotifiers(): array {
161
                return $this->notifiers->toArray();
×
162
        }
163

164
        public function addNotifier(Notifier $notifier): self {
165
                if (!$this->notifiers->contains($notifier)) {
×
166
                        $this->notifiers->add($notifier);
×
167
                        $notifier->addProject($this);
×
168
                }
169

170
                return $this;
×
171
        }
172

173
        public function removeNotifier(Notifier $notifier): self {
174
                if ($this->notifiers->removeElement($notifier)) {
×
175
                        $notifier->removeProject($this);
×
176
                }
177

178

179
                return $this;
×
180
        }
181

182
        public function __toString(): string {
183
                return $this->name??'Project';
2✔
184
        }
185

186

187
}
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