IncidentRecordTest::testSuppress()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Spiral\Tests\Snapshotter\AggregationHandler\Database;
4
5
use Spiral\Snapshotter\AggregationHandler\Database\Sources\IncidentSource;
6
use Spiral\Snapshotter\AggregationHandler\Database\IncidentRecord;
7
use Spiral\Snapshotter\AggregationHandler;
8
use Spiral\Tests\BaseTest;
9
10
class IncidentRecordTest extends BaseTest
11
{
12
    /**
13
     * Test suppression.
14
     */
15
    public function testSuppress()
16
    {
17
        /** @var IncidentSource $source */
18
        $source = $this->container->get(IncidentSource::class);
19
        $incident = $this->createIncident($source);
20
21
        $this->assertTrue($incident->status->isLast());
22
        $this->assertNotEmpty($incident->getExceptionSource());
23
24
        $incident->suppress();
25
        $this->assertTrue($incident->status->isSuppressed());
26
        $this->assertEmpty($incident->getExceptionSource());
27
    }
28
29
    /**
30
     * @param IncidentSource $source
31
     * @return IncidentRecord
32
     */
33 View Code Duplication
    private function createIncident(IncidentSource $source): IncidentRecord
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
    {
35
        $snapshot = $this->makeSnapshot('custom error', 123);
36
        $incident = $source->createFromSnapshot($snapshot);
37
38
        $incident->save();
39
40
        return $incident;
41
    }
42
}