14 changed files with 1477 additions and 1 deletions
-
42app/src/Controller/Api/v1/MattermostController.php
-
136app/src/Model/Alertmanager/Alert.php
-
171app/src/Model/Alertmanager/AlertmanagerMessage.php
-
51app/src/Model/Alertmanager/Annotation.php
-
102app/src/Model/Alertmanager/Label.php
-
68app/src/Model/Alertmanager/Status.php
-
6app/src/Model/Grafana/EvalMatches.php
-
34app/src/Service/Mattermost/MattermostService.php
-
3app/src/Service/Mattermost/MattermostServiceInterface.php
-
224app/tests/Unit/Model/Alertmanager/AlertTest.php
-
286app/tests/Unit/Model/Alertmanager/AlertmanagerMessageTest.php
-
72app/tests/Unit/Model/Alertmanager/CommonAnnotationTest.php
-
162app/tests/Unit/Model/Alertmanager/CommonLabelTest.php
-
121app/tests/Unit/Model/Alertmanager/StatusTest.php
@ -0,0 +1,136 @@ |
|||||
|
<?php |
||||
|
|
||||
|
declare(strict_types=1); |
||||
|
|
||||
|
namespace App\Model\Alertmanager; |
||||
|
|
||||
|
use OpenApi\Annotations as OA; |
||||
|
|
||||
|
/** |
||||
|
* @OA\Schema( |
||||
|
* required={ |
||||
|
* "status", |
||||
|
* "labels", |
||||
|
* "annotations", |
||||
|
* "startsAt", |
||||
|
* "endsAt", |
||||
|
* "generatorURL", |
||||
|
* "fingerprint" |
||||
|
* } |
||||
|
* ) |
||||
|
*/ |
||||
|
class Alert |
||||
|
{ |
||||
|
/** |
||||
|
* @OA\Property(description="firing") |
||||
|
*/ |
||||
|
protected string $status; |
||||
|
/** |
||||
|
* @OA\Property(description="") |
||||
|
*/ |
||||
|
protected Label $labels; |
||||
|
/** |
||||
|
* @OA\Property(description="") |
||||
|
*/ |
||||
|
protected Annotation $annotations; |
||||
|
/** |
||||
|
* @OA\Property(description="", example="2021-10-11T09:20:26.340165961Z") |
||||
|
*/ |
||||
|
protected string $startsAt; |
||||
|
/** |
||||
|
* @OA\Property(description="", example="2021-10-11T09:24:26.340165961Z") |
||||
|
*/ |
||||
|
protected string $endsAt; |
||||
|
/** |
||||
|
* @OA\Property(description="", example="http://prometheus:9090/graph?g0.expr=node_load1+%3E+1.5&g0.tab=1") |
||||
|
*/ |
||||
|
protected string $generatorURL; |
||||
|
/** |
||||
|
* @OA\Property(description="", example="9419951f83c5c751") |
||||
|
*/ |
||||
|
protected string $fingerprint; |
||||
|
|
||||
|
public function getStatus(): string |
||||
|
{ |
||||
|
return $this->status; |
||||
|
} |
||||
|
|
||||
|
public function setStatus(string $status): self |
||||
|
{ |
||||
|
$this->status = $status; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getLabels(): Label |
||||
|
{ |
||||
|
return $this->labels; |
||||
|
} |
||||
|
|
||||
|
public function setLabels(Label $labels): self |
||||
|
{ |
||||
|
$this->labels = $labels; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getAnnotations(): Annotation |
||||
|
{ |
||||
|
return $this->annotations; |
||||
|
} |
||||
|
|
||||
|
public function setAnnotations(Annotation $annotations): self |
||||
|
{ |
||||
|
$this->annotations = $annotations; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getStartsAt(): string |
||||
|
{ |
||||
|
return $this->startsAt; |
||||
|
} |
||||
|
|
||||
|
public function setStartsAt(string $startsAt): self |
||||
|
{ |
||||
|
$this->startsAt = $startsAt; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getEndsAt(): string |
||||
|
{ |
||||
|
return $this->endsAt; |
||||
|
} |
||||
|
|
||||
|
public function setEndsAt(string $endsAt): self |
||||
|
{ |
||||
|
$this->endsAt = $endsAt; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getGeneratorURL(): string |
||||
|
{ |
||||
|
return $this->generatorURL; |
||||
|
} |
||||
|
|
||||
|
public function setGeneratorURL(string $generatorURL): self |
||||
|
{ |
||||
|
$this->generatorURL = $generatorURL; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getFingerprint(): string |
||||
|
{ |
||||
|
return $this->fingerprint; |
||||
|
} |
||||
|
|
||||
|
public function setFingerprint(string $fingerprint): self |
||||
|
{ |
||||
|
$this->fingerprint = $fingerprint; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
} |
@ -0,0 +1,171 @@ |
|||||
|
<?php |
||||
|
|
||||
|
declare(strict_types=1); |
||||
|
|
||||
|
namespace App\Model\Alertmanager; |
||||
|
|
||||
|
use OpenApi\Annotations as OA; |
||||
|
|
||||
|
/** |
||||
|
* @OA\Schema( |
||||
|
* required={ |
||||
|
* "receiver", |
||||
|
* "message", |
||||
|
* "data", |
||||
|
* "commonLabels", |
||||
|
* "commonAnnotations", |
||||
|
* "externalURL", |
||||
|
* "version", |
||||
|
* "groupKey", |
||||
|
* "truncatedAlerts" |
||||
|
* } |
||||
|
* ) |
||||
|
*/ |
||||
|
class AlertmanagerMessage |
||||
|
{ |
||||
|
/** |
||||
|
* @OA\Property(example="notification-provider") |
||||
|
*/ |
||||
|
protected string $receiver; |
||||
|
/** |
||||
|
* @OA\Property(example="firing") |
||||
|
*/ |
||||
|
protected string $status; |
||||
|
/** |
||||
|
* @var Alert[] |
||||
|
* @OA\Property() |
||||
|
*/ |
||||
|
protected array $alerts; |
||||
|
/** |
||||
|
* @OA\Property(description="") |
||||
|
*/ |
||||
|
protected Label $commonLabels; |
||||
|
/** |
||||
|
* @OA\Property(description="") |
||||
|
*/ |
||||
|
protected Annotation $commonAnnotations; |
||||
|
/** |
||||
|
* @OA\Property(example="http://alertmanager:9093") |
||||
|
*/ |
||||
|
protected string $externalURL; |
||||
|
/** |
||||
|
* @OA\Property(example="4") |
||||
|
*/ |
||||
|
protected string $version; |
||||
|
/** |
||||
|
* @OA\Property(example="{}:{}") |
||||
|
*/ |
||||
|
protected string $groupKey; |
||||
|
/** |
||||
|
* @OA\Property(example=0) |
||||
|
*/ |
||||
|
protected int $truncatedAlerts; |
||||
|
|
||||
|
public function getReceiver(): string |
||||
|
{ |
||||
|
return $this->receiver; |
||||
|
} |
||||
|
|
||||
|
public function setReceiver(string $receiver): self |
||||
|
{ |
||||
|
$this->receiver = $receiver; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getStatus(): string |
||||
|
{ |
||||
|
return $this->status; |
||||
|
} |
||||
|
|
||||
|
public function setStatus(string $status): self |
||||
|
{ |
||||
|
$this->status = $status; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getAlerts(): array |
||||
|
{ |
||||
|
return $this->alerts; |
||||
|
} |
||||
|
|
||||
|
public function setAlerts(array $alerts): self |
||||
|
{ |
||||
|
$this->alerts = $alerts; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getCommonLabels(): Label |
||||
|
{ |
||||
|
return $this->commonLabels; |
||||
|
} |
||||
|
|
||||
|
public function setCommonLabels(Label $commonLabels): self |
||||
|
{ |
||||
|
$this->commonLabels = $commonLabels; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getCommonAnnotations(): Annotation |
||||
|
{ |
||||
|
return $this->commonAnnotations; |
||||
|
} |
||||
|
|
||||
|
public function setCommonAnnotations(Annotation $commonAnnotations): self |
||||
|
{ |
||||
|
$this->commonAnnotations = $commonAnnotations; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getExternalURL(): string |
||||
|
{ |
||||
|
return $this->externalURL; |
||||
|
} |
||||
|
|
||||
|
public function setExternalURL(string $externalURL): self |
||||
|
{ |
||||
|
$this->externalURL = $externalURL; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getVersion(): string |
||||
|
{ |
||||
|
return $this->version; |
||||
|
} |
||||
|
|
||||
|
public function setVersion(string $version): self |
||||
|
{ |
||||
|
$this->version = $version; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getGroupKey(): string |
||||
|
{ |
||||
|
return $this->groupKey; |
||||
|
} |
||||
|
|
||||
|
public function setGroupKey(string $groupKey): self |
||||
|
{ |
||||
|
$this->groupKey = $groupKey; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getTruncatedAlerts(): int |
||||
|
{ |
||||
|
return $this->truncatedAlerts; |
||||
|
} |
||||
|
|
||||
|
public function setTruncatedAlerts(int $truncatedAlerts): self |
||||
|
{ |
||||
|
$this->truncatedAlerts = $truncatedAlerts; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
} |
@ -0,0 +1,51 @@ |
|||||
|
<?php |
||||
|
|
||||
|
declare(strict_types=1); |
||||
|
|
||||
|
namespace App\Model\Alertmanager; |
||||
|
|
||||
|
use OpenApi\Annotations as OA; |
||||
|
|
||||
|
/** |
||||
|
* @OA\Schema( |
||||
|
* required={ |
||||
|
* "description", |
||||
|
* "summary" |
||||
|
* } |
||||
|
* ) |
||||
|
*/ |
||||
|
class Annotation |
||||
|
{ |
||||
|
/** |
||||
|
* @OA\Property(description="", example="Docker host is under high load, the avg load 1m is at 2.27. Reported by instance nodeexporter:9100 of job nodeexporter.") |
||||
|
*/ |
||||
|
protected string $description; |
||||
|
/** |
||||
|
* @OA\Property(description="", example="Server under high load") |
||||
|
*/ |
||||
|
protected string $summary; |
||||
|
|
||||
|
public function getDescription(): string |
||||
|
{ |
||||
|
return $this->description; |
||||
|
} |
||||
|
|
||||
|
public function setDescription(string $description): self |
||||
|
{ |
||||
|
$this->description = $description; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getSummary(): string |
||||
|
{ |
||||
|
return $this->summary; |
||||
|
} |
||||
|
|
||||
|
public function setSummary(string $summary): self |
||||
|
{ |
||||
|
$this->summary = $summary; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
} |
@ -0,0 +1,102 @@ |
|||||
|
<?php |
||||
|
|
||||
|
declare(strict_types=1); |
||||
|
|
||||
|
namespace App\Model\Alertmanager; |
||||
|
|
||||
|
use OpenApi\Annotations as OA; |
||||
|
|
||||
|
/** |
||||
|
* @OA\Schema( |
||||
|
* required={ |
||||
|
* "alertname", |
||||
|
* "instance", |
||||
|
* "job", |
||||
|
* "monitor", |
||||
|
* "severity" |
||||
|
* } |
||||
|
* ) |
||||
|
*/ |
||||
|
class Label |
||||
|
{ |
||||
|
/** |
||||
|
* @OA\Property(description="", example="high_cpu_load") |
||||
|
*/ |
||||
|
protected string $alertname; |
||||
|
/** |
||||
|
* @OA\Property(description="", example="nodeexporter:9100") |
||||
|
*/ |
||||
|
protected string $instance; |
||||
|
/** |
||||
|
* @OA\Property(description="", example="nodeexporter") |
||||
|
*/ |
||||
|
protected string $job; |
||||
|
/** |
||||
|
* @OA\Property(description="", example="docker-host-alpha") |
||||
|
*/ |
||||
|
protected string $monitor; |
||||
|
/** |
||||
|
* @OA\Property(description="", example="warning") |
||||
|
*/ |
||||
|
protected string $severity; |
||||
|
|
||||
|
public function getAlertName(): string |
||||
|
{ |
||||
|
return $this->alertname; |
||||
|
} |
||||
|
|
||||
|
public function setAlertName(string $alertName): self |
||||
|
{ |
||||
|
$this->alertname = $alertName; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getInstance(): string |
||||
|
{ |
||||
|
return $this->instance; |
||||
|
} |
||||
|
|
||||
|
public function setInstance(string $instance): self |
||||
|
{ |
||||
|
$this->instance = $instance; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getJob(): string |
||||
|
{ |
||||
|
return $this->job; |
||||
|
} |
||||
|
|
||||
|
public function setJob(string $job): self |
||||
|
{ |
||||
|
$this->job = $job; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getMonitor(): string |
||||
|
{ |
||||
|
return $this->monitor; |
||||
|
} |
||||
|
|
||||
|
public function setMonitor(string $monitor): self |
||||
|
{ |
||||
|
$this->monitor = $monitor; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getSeverity(): string |
||||
|
{ |
||||
|
return $this->severity; |
||||
|
} |
||||
|
|
||||
|
public function setSeverity(string $severity): self |
||||
|
{ |
||||
|
$this->severity = $severity; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
} |
@ -0,0 +1,68 @@ |
|||||
|
<?php |
||||
|
|
||||
|
declare(strict_types=1); |
||||
|
|
||||
|
namespace App\Model\Alertmanager; |
||||
|
|
||||
|
use OpenApi\Annotations as OA; |
||||
|
|
||||
|
/** |
||||
|
* @OA\Schema( |
||||
|
* required={ |
||||
|
* "state", |
||||
|
* "silencedBy", |
||||
|
* "inhibitedBy" |
||||
|
* } |
||||
|
* ) |
||||
|
*/ |
||||
|
class Status |
||||
|
{ |
||||
|
/** |
||||
|
* @OA\Property(description="", example="active") |
||||
|
*/ |
||||
|
protected string $state; |
||||
|
/** |
||||
|
* @OA\Property(description="") |
||||
|
*/ |
||||
|
protected ?string $silencedBy; |
||||
|
/** |
||||
|
* @OA\Property(description="") |
||||
|
*/ |
||||
|
protected ?string $inhibitedBy; |
||||
|
|
||||
|
public function getState(): string |
||||
|
{ |
||||
|
return $this->state; |
||||
|
} |
||||
|
|
||||
|
public function setState(string $state): self |
||||
|
{ |
||||
|
$this->state = $state; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getSilencedBy(): ?string |
||||
|
{ |
||||
|
return $this->silencedBy; |
||||
|
} |
||||
|
|
||||
|
public function setSilencedBy(?string $silencedBy): self |
||||
|
{ |
||||
|
$this->silencedBy = $silencedBy; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
|
||||
|
public function getInhibitedBy(): ?string |
||||
|
{ |
||||
|
return $this->inhibitedBy; |
||||
|
} |
||||
|
|
||||
|
public function setInhibitedBy(?string $inhibitedBy): self |
||||
|
{ |
||||
|
$this->inhibitedBy = $inhibitedBy; |
||||
|
|
||||
|
return $this; |
||||
|
} |
||||
|
} |
@ -0,0 +1,224 @@ |
|||||
|
<?php |
||||
|
|
||||
|
declare(strict_types=1); |
||||
|
|
||||
|
namespace App\Tests\Unit\Model\Alertmanager; |
||||
|
|
||||
|
use App\Model\Alertmanager\Annotation; |
||||
|
use App\Model\Alertmanager\Label; |
||||
|
use App\Model\Alertmanager\Alert; |
||||
|
use App\Tests\Unit\UnitTester; |
||||
|
use ReflectionException; |
||||
|
|
||||
|
final class AlertTest extends UnitTester |
||||
|
{ |
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetStatus(): void |
||||
|
{ |
||||
|
$alert = new Alert(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
$property = $this->getClassProperty($alert, 'status'); |
||||
|
$property->setValue($alert, $value); |
||||
|
|
||||
|
self::assertEquals($value, $alert->getStatus()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetStatus(): void |
||||
|
{ |
||||
|
$alert = new Alert(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
self::assertEquals($alert, $alert->setStatus($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($alert, 'status')) |
||||
|
->getValue($alert) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetLabels(): void |
||||
|
{ |
||||
|
$alert = new Alert(); |
||||
|
$value = new Label(); |
||||
|
|
||||
|
$property = $this->getClassProperty($alert, 'labels'); |
||||
|
$property->setValue($alert, $value); |
||||
|
|
||||
|
self::assertEquals($value, $alert->getLabels()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetLabels(): void |
||||
|
{ |
||||
|
$alert = new Alert(); |
||||
|
$value = new Label(); |
||||
|
|
||||
|
self::assertEquals($alert, $alert->setLabels($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($alert, 'labels')) |
||||
|
->getValue($alert) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetCommonAnnotations(): void |
||||
|
{ |
||||
|
$alert = new Alert(); |
||||
|
$value = new Annotation(); |
||||
|
|
||||
|
$property = $this->getClassProperty($alert, 'annotations'); |
||||
|
$property->setValue($alert, $value); |
||||
|
|
||||
|
self::assertEquals($value, $alert->getAnnotations()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetCommonAnnotations(): void |
||||
|
{ |
||||
|
$alert = new Alert(); |
||||
|
$value = new Annotation(); |
||||
|
|
||||
|
self::assertEquals($alert, $alert->setAnnotations($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($alert, 'annotations')) |
||||
|
->getValue($alert) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetStartsAt(): void |
||||
|
{ |
||||
|
$alert = new Alert(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
$property = $this->getClassProperty($alert, 'startsAt'); |
||||
|
$property->setValue($alert, $value); |
||||
|
|
||||
|
self::assertEquals($value, $alert->getStartsAt()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetStartsAt(): void |
||||
|
{ |
||||
|
$alert = new Alert(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
self::assertEquals($alert, $alert->setStartsAt($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($alert, 'startsAt')) |
||||
|
->getValue($alert) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetEndsAt(): void |
||||
|
{ |
||||
|
$alert = new Alert(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
$property = $this->getClassProperty($alert, 'endsAt'); |
||||
|
$property->setValue($alert, $value); |
||||
|
|
||||
|
self::assertEquals($value, $alert->getEndsAt()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetEndsAt(): void |
||||
|
{ |
||||
|
$alert = new Alert(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
self::assertEquals($alert, $alert->setEndsAt($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($alert, 'endsAt')) |
||||
|
->getValue($alert) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetGeneratorURL(): void |
||||
|
{ |
||||
|
$alert = new Alert(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
$property = $this->getClassProperty($alert, 'generatorURL'); |
||||
|
$property->setValue($alert, $value); |
||||
|
|
||||
|
self::assertEquals($value, $alert->getGeneratorURL()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetGeneratorURL(): void |
||||
|
{ |
||||
|
$alert = new Alert(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
self::assertEquals($alert, $alert->setGeneratorURL($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($alert, 'generatorURL')) |
||||
|
->getValue($alert) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetFingerprint(): void |
||||
|
{ |
||||
|
$alert = new Alert(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
$property = $this->getClassProperty($alert, 'fingerprint'); |
||||
|
$property->setValue($alert, $value); |
||||
|
|
||||
|
self::assertEquals($value, $alert->getFingerprint()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetFingerprint(): void |
||||
|
{ |
||||
|
$alert = new Alert(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
self::assertEquals($alert, $alert->setFingerprint($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($alert, 'fingerprint')) |
||||
|
->getValue($alert) |
||||
|
); |
||||
|
} |
||||
|
} |
@ -0,0 +1,286 @@ |
|||||
|
<?php |
||||
|
|
||||
|
declare(strict_types=1); |
||||
|
|
||||
|
namespace App\Tests\Unit\Model\Alertmanager; |
||||
|
|
||||
|
use App\Model\Alertmanager\AlertmanagerMessage; |
||||
|
use App\Model\Alertmanager\Alert; |
||||
|
use App\Model\Alertmanager\Annotation; |
||||
|
use App\Model\Alertmanager\Label; |
||||
|
use App\Tests\Unit\UnitTester; |
||||
|
use ReflectionException; |
||||
|
|
||||
|
final class AlertmanagerMessageTest extends UnitTester |
||||
|
{ |
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetReceiver(): void |
||||
|
{ |
||||
|
$alertmanagerMessage = new AlertmanagerMessage(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
$property = $this->getClassProperty($alertmanagerMessage, 'receiver'); |
||||
|
$property->setValue($alertmanagerMessage, $value); |
||||
|
|
||||
|
self::assertEquals($value, $alertmanagerMessage->getReceiver()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetReceiver(): void |
||||
|
{ |
||||
|
$alertmanagerMessage = new AlertmanagerMessage(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
self::assertEquals($alertmanagerMessage, $alertmanagerMessage->setReceiver($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($alertmanagerMessage, 'receiver')) |
||||
|
->getValue($alertmanagerMessage) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetStatus(): void |
||||
|
{ |
||||
|
$alertmanagerMessage = new AlertmanagerMessage(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
$property = $this->getClassProperty($alertmanagerMessage, 'status'); |
||||
|
$property->setValue($alertmanagerMessage, $value); |
||||
|
|
||||
|
self::assertEquals($value, $alertmanagerMessage->getStatus()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetStatus(): void |
||||
|
{ |
||||
|
$alertmanagerMessage = new AlertmanagerMessage(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
self::assertEquals($alertmanagerMessage, $alertmanagerMessage->setStatus($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($alertmanagerMessage, 'status')) |
||||
|
->getValue($alertmanagerMessage) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetAlerts(): void |
||||
|
{ |
||||
|
$alertmanagerMessage = new AlertmanagerMessage(); |
||||
|
$value = [new Alert()]; |
||||
|
|
||||
|
$property = $this->getClassProperty($alertmanagerMessage, 'alerts'); |
||||
|
$property->setValue($alertmanagerMessage, $value); |
||||
|
|
||||
|
self::assertEquals($value, $alertmanagerMessage->getAlerts()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetAlerts(): void |
||||
|
{ |
||||
|
$alertmanagerMessage = new AlertmanagerMessage(); |
||||
|
$value = [new Alert()]; |
||||
|
|
||||
|
self::assertEquals($alertmanagerMessage, $alertmanagerMessage->setAlerts($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($alertmanagerMessage, 'alerts')) |
||||
|
->getValue($alertmanagerMessage) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetLabels(): void |
||||
|
{ |
||||
|
$alertmanagerMessage = new AlertmanagerMessage(); |
||||
|
$value = new Label(); |
||||
|
|
||||
|
$property = $this->getClassProperty($alertmanagerMessage, 'commonLabels'); |
||||
|
$property->setValue($alertmanagerMessage, $value); |
||||
|
|
||||
|
self::assertEquals($value, $alertmanagerMessage->getCommonLabels()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetLabels(): void |
||||
|
{ |
||||
|
$alertmanagerMessage = new AlertmanagerMessage(); |
||||
|
$value = new Label(); |
||||
|
|
||||
|
self::assertEquals($alertmanagerMessage, $alertmanagerMessage->setCommonLabels($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($alertmanagerMessage, 'commonLabels')) |
||||
|
->getValue($alertmanagerMessage) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetCommonAnnotations(): void |
||||
|
{ |
||||
|
$alertmanagerMessage = new AlertmanagerMessage(); |
||||
|
$value = new Annotation(); |
||||
|
|
||||
|
$property = $this->getClassProperty($alertmanagerMessage, 'commonAnnotations'); |
||||
|
$property->setValue($alertmanagerMessage, $value); |
||||
|
|
||||
|
self::assertEquals($value, $alertmanagerMessage->getCommonAnnotations()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetCommonAnnotations(): void |
||||
|
{ |
||||
|
$alertmanagerMessage = new AlertmanagerMessage(); |
||||
|
$value = new Annotation(); |
||||
|
|
||||
|
self::assertEquals($alertmanagerMessage, $alertmanagerMessage->setCommonAnnotations($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($alertmanagerMessage, 'commonAnnotations')) |
||||
|
->getValue($alertmanagerMessage) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetExternalURL(): void |
||||
|
{ |
||||
|
$alertmanagerMessage = new AlertmanagerMessage(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
$property = $this->getClassProperty($alertmanagerMessage, 'externalURL'); |
||||
|
$property->setValue($alertmanagerMessage, $value); |
||||
|
|
||||
|
self::assertEquals($value, $alertmanagerMessage->getExternalURL()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetExternalURL(): void |
||||
|
{ |
||||
|
$alertmanagerMessage = new AlertmanagerMessage(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
self::assertEquals($alertmanagerMessage, $alertmanagerMessage->setExternalURL($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($alertmanagerMessage, 'externalURL')) |
||||
|
->getValue($alertmanagerMessage) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetVersion(): void |
||||
|
{ |
||||
|
$alertmanagerMessage = new AlertmanagerMessage(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
$property = $this->getClassProperty($alertmanagerMessage, 'version'); |
||||
|
$property->setValue($alertmanagerMessage, $value); |
||||
|
|
||||
|
self::assertEquals($value, $alertmanagerMessage->getVersion()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetVersion(): void |
||||
|
{ |
||||
|
$alertmanagerMessage = new AlertmanagerMessage(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
self::assertEquals($alertmanagerMessage, $alertmanagerMessage->setVersion($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($alertmanagerMessage, 'version')) |
||||
|
->getValue($alertmanagerMessage) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetGroupKey(): void |
||||
|
{ |
||||
|
$alertmanagerMessage = new AlertmanagerMessage(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
$property = $this->getClassProperty($alertmanagerMessage, 'groupKey'); |
||||
|
$property->setValue($alertmanagerMessage, $value); |
||||
|
|
||||
|
self::assertEquals($value, $alertmanagerMessage->getGroupKey()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetGroupKey(): void |
||||
|
{ |
||||
|
$alertmanagerMessage = new AlertmanagerMessage(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
self::assertEquals($alertmanagerMessage, $alertmanagerMessage->setGroupKey($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($alertmanagerMessage, 'groupKey')) |
||||
|
->getValue($alertmanagerMessage) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetTruncatedAlerts(): void |
||||
|
{ |
||||
|
$alertmanagerMessage = new AlertmanagerMessage(); |
||||
|
$value = $this->faker->randomNumber(); |
||||
|
|
||||
|
$property = $this->getClassProperty($alertmanagerMessage, 'truncatedAlerts'); |
||||
|
$property->setValue($alertmanagerMessage, $value); |
||||
|
|
||||
|
self::assertEquals($value, $alertmanagerMessage->getTruncatedAlerts()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetTruncatedAlerts(): void |
||||
|
{ |
||||
|
$alertmanagerMessage = new AlertmanagerMessage(); |
||||
|
$value = $this->faker->randomNumber(); |
||||
|
|
||||
|
self::assertEquals($alertmanagerMessage, $alertmanagerMessage->setTruncatedAlerts($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($alertmanagerMessage, 'truncatedAlerts')) |
||||
|
->getValue($alertmanagerMessage) |
||||
|
); |
||||
|
} |
||||
|
} |
@ -0,0 +1,72 @@ |
|||||
|
<?php |
||||
|
|
||||
|
declare(strict_types=1); |
||||
|
|
||||
|
namespace App\Tests\Unit\Model\Alertmanager; |
||||
|
|
||||
|
use App\Model\Alertmanager\Annotation; |
||||
|
use App\Tests\Unit\UnitTester; |
||||
|
use ReflectionException; |
||||
|
|
||||
|
final class CommonAnnotationTest extends UnitTester |
||||
|
{ |
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetDescription(): void |
||||
|
{ |
||||
|
$commonAnnotation = new Annotation(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
$property = $this->getClassProperty($commonAnnotation, 'description'); |
||||
|
$property->setValue($commonAnnotation, $value); |
||||
|
|
||||
|
self::assertEquals($value, $commonAnnotation->getDescription()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetDescription(): void |
||||
|
{ |
||||
|
$commonAnnotation = new Annotation(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
self::assertEquals($commonAnnotation, $commonAnnotation->setDescription($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($commonAnnotation, 'description')) |
||||
|
->getValue($commonAnnotation) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetSummary(): void |
||||
|
{ |
||||
|
$commonAnnotation = new Annotation(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
$property = $this->getClassProperty($commonAnnotation, 'summary'); |
||||
|
$property->setValue($commonAnnotation, $value); |
||||
|
|
||||
|
self::assertEquals($value, $commonAnnotation->getSummary()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetSummary(): void |
||||
|
{ |
||||
|
$commonAnnotation = new Annotation(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
self::assertEquals($commonAnnotation, $commonAnnotation->setSummary($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($commonAnnotation, 'summary')) |
||||
|
->getValue($commonAnnotation) |
||||
|
); |
||||
|
} |
||||
|
} |
@ -0,0 +1,162 @@ |
|||||
|
<?php |
||||
|
|
||||
|
declare(strict_types=1); |
||||
|
|
||||
|
namespace App\Tests\Unit\Model\Alertmanager; |
||||
|
|
||||
|
use App\Model\Alertmanager\Label; |
||||
|
use App\Tests\Unit\UnitTester; |
||||
|
use ReflectionException; |
||||
|
|
||||
|
final class CommonLabelTest extends UnitTester |
||||
|
{ |
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetAlertName(): void |
||||
|
{ |
||||
|
$commonLabel = new Label(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
$property = $this->getClassProperty($commonLabel, 'alertname'); |
||||
|
$property->setValue($commonLabel, $value); |
||||
|
|
||||
|
self::assertEquals($value, $commonLabel->getAlertName()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetAlertName(): void |
||||
|
{ |
||||
|
$commonLabel = new Label(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
self::assertEquals($commonLabel, $commonLabel->setAlertName($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($commonLabel, 'alertname')) |
||||
|
->getValue($commonLabel) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetInstance(): void |
||||
|
{ |
||||
|
$commonLabel = new Label(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
$property = $this->getClassProperty($commonLabel, 'instance'); |
||||
|
$property->setValue($commonLabel, $value); |
||||
|
|
||||
|
self::assertEquals($value, $commonLabel->getInstance()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetInstance(): void |
||||
|
{ |
||||
|
$commonLabel = new Label(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
self::assertEquals($commonLabel, $commonLabel->setInstance($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($commonLabel, 'instance')) |
||||
|
->getValue($commonLabel) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetJob(): void |
||||
|
{ |
||||
|
$commonLabel = new Label(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
$property = $this->getClassProperty($commonLabel, 'job'); |
||||
|
$property->setValue($commonLabel, $value); |
||||
|
|
||||
|
self::assertEquals($value, $commonLabel->getJob()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetJob(): void |
||||
|
{ |
||||
|
$commonLabel = new Label(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
self::assertEquals($commonLabel, $commonLabel->setJob($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($commonLabel, 'job')) |
||||
|
->getValue($commonLabel) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetMonitor(): void |
||||
|
{ |
||||
|
$commonLabel = new Label(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
$property = $this->getClassProperty($commonLabel, 'monitor'); |
||||
|
$property->setValue($commonLabel, $value); |
||||
|
|
||||
|
self::assertEquals($value, $commonLabel->getMonitor()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetMonitor(): void |
||||
|
{ |
||||
|
$commonLabel = new Label(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
self::assertEquals($commonLabel, $commonLabel->setMonitor($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($commonLabel, 'monitor')) |
||||
|
->getValue($commonLabel) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetSeverity(): void |
||||
|
{ |
||||
|
$commonLabel = new Label(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
$property = $this->getClassProperty($commonLabel, 'severity'); |
||||
|
$property->setValue($commonLabel, $value); |
||||
|
|
||||
|
self::assertEquals($value, $commonLabel->getSeverity()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetSeverity(): void |
||||
|
{ |
||||
|
$commonLabel = new Label(); |
||||
|
$value = $this->faker->sha256(); |
||||
|
|
||||
|
self::assertEquals($commonLabel, $commonLabel->setSeverity($value)); |
||||
|
self::assertEquals( |
||||
|
$value, |
||||
|
($this->getClassProperty($commonLabel, 'severity')) |
||||
|
->getValue($commonLabel) |
||||
|
); |
||||
|
} |
||||
|
} |
@ -0,0 +1,121 @@ |
|||||
|
<?php |
||||
|
|
||||
|
declare(strict_types=1); |
||||
|
|
||||
|
namespace App\Tests\Unit\Model\Alertmanager; |
||||
|
|
||||
|
use App\Model\Alertmanager\Annotation; |
||||
|
use App\Model\Alertmanager\Label; |
||||
|
use App\Model\Alertmanager\Message; |
||||
|
use App\Model\Alertmanager\Status; |
||||
|
use App\Tests\Unit\UnitTester; |
||||
|
use ReflectionException; |
||||
|
|
||||
|
final class StatusTest extends UnitTester |
||||
|
{ |
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetState(): void |
||||
|
{ |
||||
|
$status = new Status(); |
||||
|
$state = $this->faker->sha256(); |
||||
|
|
||||
|
$property = $this->getClassProperty($status, 'state'); |
||||
|
$property->setValue($status, $state); |
||||
|
|
||||
|
self::assertEquals($state, $status->getState()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetLabels(): void |
||||
|
{ |
||||
|
$status = new Status(); |
||||
|
$state = $this->faker->sha256(); |
||||
|
|
||||
|
self::assertEquals($status, $status->setState($state)); |
||||
|
self::assertEquals( |
||||
|
$state, |
||||
|
($this->getClassProperty($status, 'state')) |
||||
|
->getValue($status) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @dataProvider dataProviderSilencedBy |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetSilencedBy(?string $silencedBy): void |
||||
|
{ |
||||
|
$status = new Status(); |
||||
|
|
||||
|
$property = $this->getClassProperty($status, 'silencedBy'); |
||||
|
$property->setValue($status, $silencedBy); |
||||
|
|
||||
|
self::assertEquals($silencedBy, $status->getSilencedBy()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @dataProvider dataProviderSilencedBy |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetSilencedBy(?string $silencedBy): void |
||||
|
{ |
||||
|
$status = new Status(); |
||||
|
|
||||
|
self::assertEquals($status, $status->setSilencedBy($silencedBy)); |
||||
|
self::assertEquals( |
||||
|
$silencedBy, |
||||
|
($this->getClassProperty($status, 'silencedBy')) |
||||
|
->getValue($status) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
public function dataProviderSilencedBy(): array |
||||
|
{ |
||||
|
return [ |
||||
|
['silencedBy' => null], |
||||
|
['silencedBy' => $this->faker->sha256()], |
||||
|
]; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @dataProvider dataProviderInhibitedBy |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testGetInhibitedBy(?string $inhibitedBy): void |
||||
|
{ |
||||
|
$status = new Status(); |
||||
|
|
||||
|
$property = $this->getClassProperty($status, 'inhibitedBy'); |
||||
|
$property->setValue($status, $inhibitedBy); |
||||
|
|
||||
|
self::assertEquals($inhibitedBy, $status->getInhibitedBy()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @dataProvider dataProviderInhibitedBy |
||||
|
* @throws ReflectionException |
||||
|
*/ |
||||
|
public function testSetInhibitedBy(?string $inhibitedBy): void |
||||
|
{ |
||||
|
$status = new Status(); |
||||
|
|
||||
|
self::assertEquals($status, $status->setInhibitedBy($inhibitedBy)); |
||||
|
self::assertEquals( |
||||
|
$inhibitedBy, |
||||
|
($this->getClassProperty($status, 'inhibitedBy')) |
||||
|
->getValue($status) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
public function dataProviderInhibitedBy(): array |
||||
|
{ |
||||
|
return [ |
||||
|
['inhibitedBy' => null], |
||||
|
['inhibitedBy' => $this->faker->sha256()], |
||||
|
]; |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue